From patchwork Mon Jul 31 13: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: 109028 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp197297qge; Mon, 31 Jul 2017 06:05:34 -0700 (PDT) X-Received: by 10.237.54.225 with SMTP id f88mr20692800qtb.240.1501506334050; Mon, 31 Jul 2017 06:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501506334; cv=none; d=google.com; s=arc-20160816; b=wPvNDKWlsluaIxlirho0/qgNibjJKBo1uu54Yrj6gEWaioXtukeCGyrg+a/dorLJb5 QoORPweMrfwNWe9IEFY1WvxIYQJzYvglfnNJb8ls7rfQLspXBpU4PAFSXQv5C0Ab3qEv HBRQ6MBxZ8Gj+JI4bRAfT7D9seXP//pAm82C999YknZicTBbJdHJKXnZW2rdXXc39Ty6 ZiPgpkO/VsuuuJeQ6fdpPX90kgjaAouEah+ec9AbM4aC+8HJf6gbadQxKjrqOC7qLHFj KUQ9f/awrK/PI5p+68HeZgWNLSGU6VyCtpPIoUWs+EvQv7a36xhTIG0UdGhRqKpmzKBE nOTw== 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=BBIcuJ6WrPCn7CPsNE/7TtFV5sRMv3f6W9RB1kCNBZM=; b=Jx4AptbAWxjpI1WCb6wJUBeY9Fp5CczFEIogtSlWevAPWDbEWQW/nk15+0uuFxbgk+ 0lAYDo3OuD3MDsYbX27BmqTMrfIBoVjaYhrzf85PIoNOf4Pnz6R8P+3+uHBGqqHLBgPp skL4/Mo5TiGczbT53D/ySTqoZtghSHFq9McpAlLirj9aFojQk7mj8d+Jtj/EZu/aeQjI SYrX4/VexTxxbUHccG/AWObBWCsXJnL7CsyVcozBGr50TOGX3tKfHBrSKTo9IDlcNfsg 8/5MFhmgkZs8UiWFzrxzpHzaqClesw0G/GKqp9pGFI99/7wMW/bOuB2i64ZowdysZyjq V9TA== 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 i53si4846835qti.453.2017.07.31.06.05.33; Mon, 31 Jul 2017 06:05: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 B3F0A609C7; Mon, 31 Jul 2017 13:05:33 +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 7EBA5609ED; Mon, 31 Jul 2017 13:00:48 +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 3A6FF6447E; Mon, 31 Jul 2017 13:00:33 +0000 (UTC) Received: from forward4o.cmail.yandex.net (forward4o.cmail.yandex.net [37.9.109.248]) by lists.linaro.org (Postfix) with ESMTPS id 205F162CE2 for ; Mon, 31 Jul 2017 13:00:29 +0000 (UTC) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::28]) by forward4o.cmail.yandex.net (Yandex) with ESMTP id 8100820F28 for ; Mon, 31 Jul 2017 16:00:27 +0300 (MSK) Received: from smtp4o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4o.mail.yandex.net (Yandex) with ESMTP id 2410C6C0107B for ; Mon, 31 Jul 2017 16:00:26 +0300 (MSK) Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lh14K6cxxM-0QrmTH5v; Mon, 31 Jul 2017 16:00:26 +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 16:00:09 +0300 Message-Id: <1501506009-28910-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501506009-28910-1-git-send-email-odpbot@yandex.ru> References: <1501506009-28910-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v1 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: bab24526ba91a4499aff896c5e82d4ac3f03fea9 **/ 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 6d7d0e2e..caf020f9 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;