From patchwork Sat Jan 27 06:00:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 126041 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp843709ljd; Fri, 26 Jan 2018 22:08:10 -0800 (PST) X-Google-Smtp-Source: AH8x224S2CpnighKJG0dFg1+O/6vIT4Q6lhkVFl/icN03lgWuBM09KZUDrZ+YjETlVWspNblsP0e X-Received: by 10.55.75.151 with SMTP id y145mr25076921qka.281.1517033290277; Fri, 26 Jan 2018 22:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517033290; cv=none; d=google.com; s=arc-20160816; b=cIwBcTazjk+YS105FNSiMUUouSLnCQGZ5tl+CVeNVkhT4x6QHdRw2vz3RbOttzNgqR HmvmykvRZ2XvhHJvSQULwFCalUNjjhLL7K70erGUFxP5BaCYKm3qa7iBfdm/h1Rjmwh6 I0xUnmPrU21HKFwX6AqMki7KchuoBHCOlyV0KZVanxH/GhhOgR2fLNgX3gwQTeCaBCgx lxRUf9IKjPr1mKoT7EW2eZcCmN0s5YiqTlqRKGEGkd5M95cZ/O7o1M7v5EWubcvoDUkh kXpfO5Gxxo+SDNF8HW4Sjf+ZCkcisFO9yd91QF5gHcXVumzrxRVfLrVPoPj+sB2F991a jvvQ== 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=fBCh5XlBE5RLUqjpj6oDz4pdaoq2SoWHfsz7Vgv5wsI=; b=O02o4hS9Kmd0HzwgeHoKpeWBt+S391aD9fAF6+1eI9TZzTJunih19Lxi0MUBUhv4vx ZezhG7NN61ZhPyILB5yFRCqADgMLrNBgIzCArvkPbZ2iMlYXmev5ihOU+BwUnQxwovE4 5biPBPgl0uIqQS5Tzm0o8q4owyMxHJLTvK2r4857hhHm3ADugEAVXJovX5Hh2JufdGLT 3PrFICqnBYFuW0J8FJAXqr/NBOUPllyEGKJD+ldtlMLRAPm1BlbsNoO/4SfevpyZ5R/Z R5teNGS9c9IlA7icjdm/OQxEjgkdOLRL/snM0aOUO3ticHL2Dfe5varBlraMh9UqL5ti SpzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id t129si3709759qkd.110.2018.01.26.22.08.10; Fri, 26 Jan 2018 22:08:10 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 EF15D617E1; Sat, 27 Jan 2018 06:08:09 +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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 C6869617E8; Sat, 27 Jan 2018 06:01:08 +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 8F8AB617BF; Sat, 27 Jan 2018 06:00:30 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id 71F436099A for ; Sat, 27 Jan 2018 06:00:21 +0000 (UTC) Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 12B3D1801D40 for ; Sat, 27 Jan 2018 09:00:20 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id wND1SGe0Kb-0K2CNYMv; Sat, 27 Jan 2018 09:00:20 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id JSKreAboNf-0JN0R4NA; Sat, 27 Jan 2018 09:00:19 +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: Sat, 27 Jan 2018 09:00:05 +0300 Message-Id: <1517032810-971-12-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517032810-971-1-git-send-email-odpbot@yandex.ru> References: <1517032810-971-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 434 Subject: [lng-odp] [PATCH API-NEXT v1 11/16] linux-gen: crypto: support ChaCha20-Poly1305 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 OpenSSL >= 1.1.0 supports ChaCha20-Poly1305 AEAD cipher, so let's support it in linux-generic. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 434 (lumag:crypto-upd) ** https://github.com/Linaro/odp/pull/434 ** Patch: https://github.com/Linaro/odp/pull/434.patch ** Base sha: 0bdad6d2562166eec4abeb957b6bb5067de9fe94 ** Merge commit sha: 8cc286211b098976aafc39992f510742cefc7118 **/ platform/linux-generic/odp_crypto.c | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index e1d1c84b2..574671e07 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -28,6 +28,12 @@ #include #include +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(OPENSSL_NO_POLY1305) +#define _ODP_HAVE_CHACHA20_POLY1305 1 +#else +#define _ODP_HAVE_CHACHA20_POLY1305 0 +#endif + #define MAX_SESSIONS 32 /* @@ -56,6 +62,11 @@ static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = { {.key_len = 24, .iv_len = 12}, {.key_len = 32, .iv_len = 12} }; +#if _ODP_HAVE_CHACHA20_POLY1305 +static const odp_crypto_cipher_capability_t cipher_capa_chacha20_poly1305[] = { +{.key_len = 32, .iv_len = 12} }; +#endif + /* * Authentication algorithm capabilities * @@ -87,6 +98,11 @@ static const odp_crypto_auth_capability_t auth_capa_aes_gmac[] = { {.digest_len = 16, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0}, .iv_len = 12 } }; +#if _ODP_HAVE_CHACHA20_POLY1305 +static const odp_crypto_auth_capability_t auth_capa_chacha20_poly1305[] = { +{.digest_len = 16, .key_len = 0, .aad_len = {.min = 8, .max = 12, .inc = 4} } }; +#endif + /** Forward declaration of session structure */ typedef struct odp_crypto_generic_session_t odp_crypto_generic_session_t; @@ -773,6 +789,9 @@ int odp_crypto_capability(odp_crypto_capability_t *capa) capa->ciphers.bit.aes_cbc = 1; capa->ciphers.bit.aes_ctr = 1; capa->ciphers.bit.aes_gcm = 1; +#if _ODP_HAVE_CHACHA20_POLY1305 + capa->ciphers.bit.chacha20_poly1305 = 1; +#endif capa->auths.bit.null = 1; capa->auths.bit.md5_hmac = 1; @@ -781,6 +800,9 @@ int odp_crypto_capability(odp_crypto_capability_t *capa) capa->auths.bit.sha512_hmac = 1; capa->auths.bit.aes_gcm = 1; capa->auths.bit.aes_gmac = 1; +#if _ODP_HAVE_CHACHA20_POLY1305 + capa->auths.bit.chacha20_poly1305 = 1; +#endif #if ODP_DEPRECATED_API capa->ciphers.bit.aes128_cbc = 1; @@ -824,6 +846,12 @@ int odp_crypto_cipher_capability(odp_cipher_alg_t cipher, src = cipher_capa_aes_gcm; num = sizeof(cipher_capa_aes_gcm) / size; break; +#if _ODP_HAVE_CHACHA20_POLY1305 + case ODP_CIPHER_ALG_CHACHA20_POLY1305: + src = cipher_capa_chacha20_poly1305; + num = sizeof(cipher_capa_chacha20_poly1305) / size; + break; +#endif default: return -1; } @@ -872,6 +900,12 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth, src = auth_capa_aes_gmac; num = sizeof(auth_capa_aes_gmac) / size; break; +#if _ODP_HAVE_CHACHA20_POLY1305 + case ODP_AUTH_ALG_CHACHA20_POLY1305: + src = auth_capa_chacha20_poly1305; + num = sizeof(auth_capa_chacha20_poly1305) / size; + break; +#endif default: return -1; } @@ -993,6 +1027,17 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, else rc = -1; break; +#if _ODP_HAVE_CHACHA20_POLY1305 + case ODP_CIPHER_ALG_CHACHA20_POLY1305: + /* ChaCha20_Poly1305 requires to do both auth and + * cipher at the same time */ + if (param->auth_alg != ODP_AUTH_ALG_CHACHA20_POLY1305) + rc = -1; + else + rc = process_aes_gcm_param(session, + EVP_chacha20_poly1305()); + break; +#endif default: rc = -1; } @@ -1063,6 +1108,18 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, else rc = -1; break; +#if _ODP_HAVE_CHACHA20_POLY1305 + case ODP_AUTH_ALG_CHACHA20_POLY1305: + /* ChaCha20_Poly1305 requires to do both auth and + * cipher at the same time */ + if (param->cipher_alg == ODP_CIPHER_ALG_CHACHA20_POLY1305) { + session->auth.func = null_crypto_routine; + rc = 0; + } else { + rc = -1; + } + break; +#endif default: rc = -1; }