From patchwork Mon Aug 21 15:00:26 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: 110549 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1402987qge; Mon, 21 Aug 2017 08:01:35 -0700 (PDT) X-Received: by 10.55.18.10 with SMTP id c10mr24987390qkh.140.1503327694998; Mon, 21 Aug 2017 08:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503327694; cv=none; d=google.com; s=arc-20160816; b=N4AEAqWK5NK+MPizegwfg2+jfcVaZ8yTNaFbxly6BTCEOVrLEXTpAAminTmkqLc3JX DllZIlMNloSue8mJwwzk7eq6sH31GnzN9NMn1Riuj1kiLpNrsijp5I0ixLbhO4g8rgUh wpzcPbylX6qD0Wn4ygD4lM5S4k2Gwlsk3Aodbb4vC3vHCKJ1giddV39qYRYou3o16+Ss kPyRHkh7ACe7H1P+x8rd/OhdC3jVn5XXj0sCc1R460CE58UsZHL8a2MPfO9smj1+bQMm xhAolV3OdDYU5pFpWjNAm9LYfaXW7v9Jx6zdDELeawcq6OwmjaOY3+d4FWfmJ93OaVkS qKWw== 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=RKIxKmwwOEmOL9kZPBniVGFjK4sC64QJLewE1nO3wxw=; b=LYAOvhM16N1TtBtVinZVwyuUkC+yw2SlSiZk8yhZSsaYf7PpE91nhr8/wQiqTSb+uD TCIz5bYAqxSEMVq3hjQ3xr3r95NONapEggLcOvj3hZ0CPU82IqkW2VhIQasWpG0RM7Hh ep7mZkF2ErYlgpYaTO28AyGlgCyK1K79nfMaAWoBrHN0DZoVYy6BDyFGBeCTKZ2+1Jau hdTewmkQoEH7O7Yg4iWtDpoxvYLG+vCYqQcpO5UK5jND88cGNxzmyvBcgVO7YKYtzYvT VU1yGBcllY5NF4B0IR6Qv2CotCktiJjAXTFgAmJq/jpzZCm8hUzJc70lBwhTRR/LTmGE Hn+A== 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 r36si11248034qtd.3.2017.08.21.08.01.34; Mon, 21 Aug 2017 08:01:34 -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 99D7764450; Mon, 21 Aug 2017 15:01:34 +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 C0DAE60666; Mon, 21 Aug 2017 15:00:54 +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 B5D0464451; Mon, 21 Aug 2017 15:00:44 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id CE9AA64451 for ; Mon, 21 Aug 2017 15:00:36 +0000 (UTC) Received: from mxback4j.mail.yandex.net (mxback4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10d]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 6CCAB5D81D1A for ; Mon, 21 Aug 2017 18:00:35 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback4j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 712vem7BoJ-0ZiC5aJx; Mon, 21 Aug 2017 18:00:35 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id D8YNr1oa4R-0YeSAMTu; Mon, 21 Aug 2017 18:00:34 +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: Mon, 21 Aug 2017 18:00:26 +0300 Message-Id: <1503327626-2552-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503327626-2552-1-git-send-email-odpbot@yandex.ru> References: <1503327626-2552-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v4 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: e5e30dc5f767d77c3e44b6a8f333e563324eceb2 **/ 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;