From patchwork Mon Jul 31 08:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 108979 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1993029qge; Mon, 31 Jul 2017 01:01:19 -0700 (PDT) X-Received: by 10.200.46.194 with SMTP id i2mr21524821qta.89.1501488079419; Mon, 31 Jul 2017 01:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501488079; cv=none; d=google.com; s=arc-20160816; b=v2W7WIDDkI73NFiZTqOurR5e+yJ7P+gi+SoGe3qsWfTnWU408rE/9r+cqHLFG+IuBX Rj3Izd2klfksMb/Awe6HjkecKjEkkY97vbMMQKzPD+8wcwyg9zWgkR45vWRyFZJJE27V 4hIkau4HxvieGe8vIXVKLJk7N3IwTudqKzNvPWJyiHgkHCbubZKbZ8i1xKrKss9bKQbq +LXefkH9CoOU8Pf2goqOOvcJD4JimM2vCgwBxtMAdDUUPLgAf/s7O/b2HgasIuSApLwx b7yT/rosJ0Hz+g4CPuurEjAbzpiZODUJ+zDemNRB1Rm671ZsVvPMg0eXIKRWWfjThCCk eseQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=s2VC7MRkkTPNDJBlIH+eagnZKTBDhPawpaJht0/uaFw=; b=tOwVfnVYFJ4vjgK3GclPBwgTE8LFcBeKnzILd4I4/S73wEaw7IuNtCNbBKnz16rw1c 7iwBPukH+FEPGCCO56EuNe9QEvhNZy36GSlvFDu6lKmwrOTisI7GzNF8dpkNVib3y/ss 0cM3QAcPa3+qZCIzTHZAsr2FOw8az6T/6+l5vgjso/nkaDGpgZkfatTPObprWgFhjoj8 CjjaPOdlPn5MLu/o99/FziHj+rSMf0CGuewvpZoJcshz9HGgw5eOXRD3RpluMHcbKT5c DiN8welbgPHTCCfJPpc+PQ21/sbhypy5e6drXa1xolFpfjItrnJqOPUEd+L8pPFYCmHU +M0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m65si15637487qkm.541.2017.07.31.01.01.19; Mon, 31 Jul 2017 01:01:19 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id DBF6D6445B; Mon, 31 Jul 2017 08:01:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6AC0660639; Mon, 31 Jul 2017 08:00:41 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 43DEC6447C; Mon, 31 Jul 2017 08:00:33 +0000 (UTC) Received: from forward2o.cmail.yandex.net (forward2o.cmail.yandex.net [37.9.109.243]) by lists.linaro.org (Postfix) with ESMTPS id A641764484 for ; Mon, 31 Jul 2017 08:00:17 +0000 (UTC) Received: from smtp2m.mail.yandex.net (smtp2m.mail.yandex.net [77.88.61.129]) by forward2o.cmail.yandex.net (Yandex) with ESMTP id 4B9EB20724 for ; Mon, 31 Jul 2017 11:00:16 +0300 (MSK) Received: from smtp2m.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2m.mail.yandex.net (Yandex) with ESMTP id E89822300F8C for ; Mon, 31 Jul 2017 11:00:11 +0300 (MSK) Received: by smtp2m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OAO8bgJOSo-0Ak8qMiS; Mon, 31 Jul 2017 11:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 31 Jul 2017 11:00:05 +0300 Message-Id: <1501488005-10405-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501488005-10405-1-git-send-email-odpbot@yandex.ru> References: <1501488005-10405-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 91 Subject: [lng-odp] [PATCH v1 1/1] linux-gen: crypto: add support for AES-192 and AES-256 X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Add support for AES with keys of 192 and 256 bits. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 91 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/91 ** Patch: https://github.com/Linaro/odp/pull/91.patch ** Base sha: 79336f5eaee25168a5e4ad7fc0aee07395d4ca1f ** Merge commit sha: 9b9beb78a684ad396775ebbe56d38626767cdf97 **/ platform/linux-generic/odp_crypto.c | 44 ++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 68fc5658..00ad0946 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -44,10 +44,14 @@ static const odp_crypto_cipher_capability_t cipher_capa_trides_cbc[] = { {.key_len = 24, .iv_len = 8} }; static const odp_crypto_cipher_capability_t cipher_capa_aes_cbc[] = { -{.key_len = 16, .iv_len = 16} }; +{.key_len = 16, .iv_len = 16}, +{.key_len = 24, .iv_len = 16}, +{.key_len = 32, .iv_len = 16} }; static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = { -{.key_len = 16, .iv_len = 12} }; +{.key_len = 16, .iv_len = 12}, +{.key_len = 24, .iv_len = 12}, +{.key_len = 32, .iv_len = 12} }; /* * Authentication algorithm capabilities @@ -734,23 +738,47 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, case ODP_CIPHER_ALG_3DES_CBC: rc = process_cipher_param(session, EVP_des_ede3_cbc()); break; - case ODP_CIPHER_ALG_AES_CBC: #if ODP_DEPRECATED_API case ODP_CIPHER_ALG_AES128_CBC: + if (param->cipher_key.length == 16) + rc = process_cipher_param(session, EVP_aes_128_cbc()); + else + rc = -1; + break; #endif - rc = process_cipher_param(session, EVP_aes_128_cbc()); + case ODP_CIPHER_ALG_AES_CBC: + if (param->cipher_key.length == 16) + rc = process_cipher_param(session, EVP_aes_128_cbc()); + else if (param->cipher_key.length == 24) + rc = process_cipher_param(session, EVP_aes_192_cbc()); + else if (param->cipher_key.length == 32) + rc = process_cipher_param(session, EVP_aes_256_cbc()); + else + rc = -1; break; #if ODP_DEPRECATED_API case ODP_CIPHER_ALG_AES128_GCM: - if (param->auth_alg == ODP_AUTH_ALG_AES128_GCM) - aes_gcm = 1; - /* Fallthrough */ + /* AES-GCM requires to do both auth and + * cipher at the same time */ + if (param->auth_alg != ODP_AUTH_ALG_AES128_GCM) + rc = -1; + else if (param->cipher_key.length == 16) + rc = process_aes_gcm_param(session, EVP_aes_128_gcm()); + else + rc = -1; + break; #endif case ODP_CIPHER_ALG_AES_GCM: /* AES-GCM requires to do both auth and * cipher at the same time */ - if (param->auth_alg == ODP_AUTH_ALG_AES_GCM || aes_gcm) + if (param->auth_alg != ODP_AUTH_ALG_AES_GCM) + rc = -1; + else if (param->cipher_key.length == 16) rc = process_aes_gcm_param(session, EVP_aes_128_gcm()); + else if (param->cipher_key.length == 24) + rc = process_aes_gcm_param(session, EVP_aes_192_gcm()); + else if (param->cipher_key.length == 32) + rc = process_aes_gcm_param(session, EVP_aes_256_gcm()); else rc = -1; break;