From patchwork Mon Jul 31 22:00:09 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: 109060 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp709926qge; Mon, 31 Jul 2017 15:03:12 -0700 (PDT) X-Received: by 10.237.52.6 with SMTP id w6mr26195064qtd.197.1501538591996; Mon, 31 Jul 2017 15:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501538591; cv=none; d=google.com; s=arc-20160816; b=pWSvLBBc2dW+RpnxAN//D4hHq2Rp2HhDmQyUrVRLInhHtREg47W9wcSi+EDrtIFGGW fvVs+dZfYanE6raORbLxips6H74LorQZzAb8WebX4JRl41te9HnOL7mEBYDuR6Ro0ULe uCJKuZKRHIijrVw37BQHHqnI1/9m/5/AnfdG3UNwNcNhB8Cuj7N9GAhXRTTIgbnqPgvY fS6K8aulQfur/3ZdKnALMY9SGtm3h2mwUcI3bRx468+szKRbS9rAKzKLX0GVCO3IKkvx ZVm3FA6MZgdmJERz1a6IC6R1+bMZA92x7X21ORGpyHR49JDzsfoOGFg/iOWO3Gli/1/P 8j3Q== 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=iuFcwM1s7gU7gDtanRmsrxoDKpeRdD0h1SwYFt7gkqg=; b=ddoC18VaXx8Dw+zAfB5IUqBDHO/b2KkrDuTrvLi9syUfBipg8QcpbKcb9yEq5FCAz9 rnh7ghQSFV1N6rGF0Y4Mq6gWbggxEobKUcBg+tQ8byZdP5SV3zUvQf14AbsS9C3QEENv dpuBFApEgLonIJwWPo3q8rSAKjUeUuM8Yir2UVLthImYZYzRq9gbOedMz17EOStxOI2G 3AeioAGRxR1WJ+gEvOYdz3TDJhYXqRZ3B0J7omw5IrnF7rtTebq7qVy+Qh3NVAWhMsDy AjQiBWhUjBj9/HIDaxG/izAmGa8Zqe1dFTFfmlosZ9bEH03gbcxDG5Oz9+zGENpGvr/z /zWA== 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 z65si1430291qtd.369.2017.07.31.15.03.11; Mon, 31 Jul 2017 15:03:11 -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 A9D6065D0F; Mon, 31 Jul 2017 22:03:11 +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 5D22B61D9B; Mon, 31 Jul 2017 22:01:33 +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 0C96061D9B; Mon, 31 Jul 2017 22:01:29 +0000 (UTC) Received: from forward5j.cmail.yandex.net (forward5j.cmail.yandex.net [5.255.227.23]) by lists.linaro.org (Postfix) with ESMTPS id ED32061D9B for ; Mon, 31 Jul 2017 22:00:25 +0000 (UTC) Received: from smtp2m.mail.yandex.net (smtp2m.mail.yandex.net [IPv6:2a02:6b8:0:2519::122]) by forward5j.cmail.yandex.net (Yandex) with ESMTP id E25C7203BC for ; Tue, 1 Aug 2017 01:00:24 +0300 (MSK) Received: from smtp2m.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2m.mail.yandex.net (Yandex) with ESMTP id C39D42300F92 for ; Tue, 1 Aug 2017 01:00:24 +0300 (MSK) Received: by smtp2m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id prEP5cProO-0NkuF14j; Tue, 01 Aug 2017 01:00:23 +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: Tue, 1 Aug 2017 01:00:09 +0300 Message-Id: <1501538409-20031-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501538409-20031-1-git-send-email-odpbot@yandex.ru> References: <1501538409-20031-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v2 6/6] 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: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 590ab5bff952cbbc145c433c3f40a9189b29cc5b **/ 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 fa8b0a28..a72ebb25 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 @@ -737,23 +741,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;