From patchwork Tue Aug 1 02: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: 109082 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp918715qge; Mon, 31 Jul 2017 19:08:39 -0700 (PDT) X-Received: by 10.233.221.131 with SMTP id r125mr24277723qkf.267.1501553319659; Mon, 31 Jul 2017 19:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501553319; cv=none; d=google.com; s=arc-20160816; b=yiW8fWDR3JxxBTcVJRdQ8py0k4wro5+qie8/xP4u6U5+Q1tUcUbuaULPV+mn99lUTr jnXfDfIO8jQP5sUc8radpGs69CMUHhn36Szdl3jfNOegHYFQyRI4TYHojrqKtaii46gw 4iuvcQ7W85vzjKBi9uw82TX1UmyI7bSnX4ltCOsuNrAg4O6DwmAhkvWXB1DJPF3extVs 0w9gvHHMPFEq7pVWx5lmdV/D/AduKx6dW2Osz25k/YKDHFvNsbjlJuutdMAD79yRXggJ icCRdpbgKU1iVHph2ii61rt4uYDQDsC6yKDl+D+CfwKev+d4aZuXZ9foC3AoryXdrjZw BeJQ== 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=8YrsaSHwIZz/x3EfvKLqERrql9losUM40YNxXhE5jco=; b=R6PdvqwN/6067w4NaiqxFDzncts7mYNjhyQ4l9YQ/xm+7rHLFmE5F7HFni01lTWLDy 7R7cvp6Jr3N80hvtPJroqOKHvVtna/6kdM4OGyxqN+ihdTCMi3ww7SQGHsfnZIVT+Uyw qxSnsfhKzT6TB+ZcWVKRVFg1RUsMVLwssZCLHXKObWekayZY/42ApNWAmT4aNoxVnw19 hQIWURgf6rYRvVBJ0mstIXVCfUwzpDH+ioB/vjg+EIaLE0LU3bP/JX4JuC/tAwVxxge1 tJ3FcEfZvsGD2VfrF60aIeMY3QfXEDLy8NjUb24HqjYLW2xHUtJO+qtvqX9f/W0zZYrp GzJg== 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 g6si12816400qkc.261.2017.07.31.19.08.39; Mon, 31 Jul 2017 19:08:39 -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 5157365C7C; Tue, 1 Aug 2017 02:08:39 +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 0C63665CFA; Tue, 1 Aug 2017 02:01: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 70DF865D07; Tue, 1 Aug 2017 02:01:28 +0000 (UTC) Received: from forward3p.cmail.yandex.net (forward3p.cmail.yandex.net [77.88.31.18]) by lists.linaro.org (Postfix) with ESMTPS id 5707B65C3D for ; Tue, 1 Aug 2017 02:00:29 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [37.140.190.26]) by forward3p.cmail.yandex.net (Yandex) with ESMTP id 1967020C94 for ; Tue, 1 Aug 2017 05:00:27 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id E797F1300C28 for ; Tue, 1 Aug 2017 05:00:26 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cw80aqSarU-0PtS9Cif; Tue, 01 Aug 2017 05:00:25 +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 05:00:09 +0300 Message-Id: <1501552809-14585-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> References: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v3 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: 97de0c6543391f0a758ac472f48e0b407ad1d800 **/ 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;