From patchwork Mon Aug 21 22:00:17 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: 110591 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1842867qge; Mon, 21 Aug 2017 15:02:23 -0700 (PDT) X-Received: by 10.55.41.10 with SMTP id p10mr26661878qkh.112.1503352943413; Mon, 21 Aug 2017 15:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503352943; cv=none; d=google.com; s=arc-20160816; b=leXW6OGTuPuXO4vChzO9GkqCL3vV/cwPicK8QhDmrcoeq2tzWv4+GEGswIiwcv6EyX yXiwDXVsl8J7jLaGNVp1lxjlY8Mc4rQ2yPZ+Ltbl/x7CHuFfYCwDDnX+sTts/86lRWQN DATqHiijjamLi1sApd2DnS89i6ZTP77fMNxEtQ7529dvVhe4Zjo1vo5UHNJH2ahw+Sm9 aaf1Vbvet1cLKy8QaIMkihp0GwPpComMHnFY1Tm/Tx54f+3chy1HVMCHRrmIHwOa911N fJWkFau9wTAaTftl57UxKYS+e8dqYyVo32GUIAoxzUgX5ljqJGgVes/geLm5gLIl+2G/ KhkA== 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=2xxeI6QZJ+vsYHxEaZLaRIOjOaHuMdaPpQdPgi9O+ro=; b=rV52TO638ZBX5/kCwDYLV1ghwGMHx3WvDkR++/kni1dxo0C+LqoMVYmi/V0vkFA8D1 l09vLul21FADB60KFGeXQCVi3ko6Nyq/oEST7YFvqOaaHy8RxJDo7n1WVHKhywUkYasj xXU0rRPjKZLJS4T8vd/iWlrD/zwvDK/0LPNKRJogyozA99n48R7//6TOxO/zYEkEPDd/ sNtpmCivCIRh4Nll5aBOqkSQSNguD4tMwNAsqFLRKFDck3rq06Oe9fNcn6JFV1uN2sYm BZTa7yk7s8shd1dW1S1y/qiJvHdJgb0OqYBJ+aNhX9X0G0SkE0gtfKXqn/sdx6vez8Ui XWFA== 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 55si12299446qto.323.2017.08.21.15.02.23; Mon, 21 Aug 2017 15:02:23 -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 02E00608D3; Mon, 21 Aug 2017 22:02:22 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 73B6260CD7; Mon, 21 Aug 2017 22:01:35 +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 EA54760CD7; Mon, 21 Aug 2017 22:01:29 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id 640876449C for ; Mon, 21 Aug 2017 22:00:23 +0000 (UTC) Received: from mxback11g.mail.yandex.net (mxback11g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:90]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 5F4A25D83AC2 for ; Tue, 22 Aug 2017 01:00:22 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback11g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id QutltVG0YA-0MoixYcK; Tue, 22 Aug 2017 01:00:22 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1rAWfL7pdM-0Lh8qxTf; Tue, 22 Aug 2017 01:00:21 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 22 Aug 2017 01:00:17 +0300 Message-Id: <1503352817-2136-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503352817-2136-1-git-send-email-odpbot@yandex.ru> References: <1503352817-2136-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v5 3/3] 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 94 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/94 ** Patch: https://github.com/Linaro/odp/pull/94.patch ** Base sha: 3547226b19e6982bf74fc8c258b89db2c5f6a39c ** Merge commit sha: 639b51978ac4cd2c4db537873fee719de65e575b **/ 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 af166c5d..f7d5d013 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 @@ -741,23 +745,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;