From patchwork Tue Nov 14 20:00:05 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: 118885 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3463876qgn; Tue, 14 Nov 2017 12:04:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMY2aDi3tH9/RwUXwkXbq4ExRC+ooElLY5YdMHFWafBnAAgrbvN+Yyht+Fj+nJPE7Mq2/f8n X-Received: by 10.233.222.135 with SMTP id s129mr922998qkf.261.1510689856624; Tue, 14 Nov 2017 12:04:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689856; cv=none; d=google.com; s=arc-20160816; b=JFGXKWtZphEF1qqOkG25j5bziBwlQK0BFOr9JAt77m1aScxE99SRzGUBX24704+S3P j/IGXbEPRVgLImxC9H+pIAFlwzp2eWQfqCS5KzlS00rl5xwt/Ah4FampQPdmEzZZVGPu XS2Bhh6+R1d+2BUm//qSTGbeyWvGE4Vx4plshjP2nZZBRxCsyq0lzb+5Wh+km73Scwx3 RuexjxWg0cgTFe/PihWQLnuKImMv3S42Akfo45535zKu2SBJsxcUUWwx5f5u9H+5G2bo qERxzGNaRD8DGN8lPKed5MCCFveWeh/NU1Txv43oaoKhvgxef+4z5XigBGVxcrd87T5p S3tA== 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=TaWBzoViElhvj1z52zEzR6yvseED0ZSIfgI6tXZTxD8=; b=xJuKaPZVFckMbhB8WOiDDCjtjG/ZfvrLVw/xtDsj2Mh615cji8fVnboEOCUQFBCSFs 0tIBWJomWjYyJi86ACQ1p6SNiFOQ8HgXGC1xsUKtyfrMbXIpzXWTUAyZ858B6KnwQqWf HCkabcz4oAMScGfNgCpaKAswZWMq0g+HdMKQPVQYgpfrcmidKfRlatkyvzhgfOHDqse+ K9c0likMPpqKNKretZ5y0zRtff7VLxB9pg9V4RRq54UilIFYz6ausmiIVUSjKc8fOt/Z ls8+KlG1B5k/H/2gTfqfrBeby37GfhsWixUkxAV4f/bPh95lny+2bGGoA1QxnZ9Z1pDm R9xg== 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 u37si733486qtj.406.2017.11.14.12.04.16; Tue, 14 Nov 2017 12:04:16 -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 3CBD86068A; Tue, 14 Nov 2017 20:04:16 +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,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 DE110606A4; Tue, 14 Nov 2017 20:00:44 +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 E6A8E6063A; Tue, 14 Nov 2017 20:00:23 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id EC2B360606 for ; Tue, 14 Nov 2017 20:00:15 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 1513721841E8 for ; Tue, 14 Nov 2017 23:00:14 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id bOXGYNxmdQ-0EpGgvgS; Tue, 14 Nov 2017 23:00:14 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0Dp4KH4s; Tue, 14 Nov 2017 23:00:13 +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: Tue, 14 Nov 2017 23:00:05 +0300 Message-Id: <1510689611-17861-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 4/10] linux-gen: ipsec: add support for AES-GMAC-ESP 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 Implement AES-GMAC-ESP support. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 288 (lumag:gmac) ** https://github.com/Linaro/odp/pull/288 ** Patch: https://github.com/Linaro/odp/pull/288.patch ** Base sha: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ platform/linux-generic/odp_ipsec_sad.c | 73 +++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index 8eaa4f902..f1fde5e69 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -267,38 +267,6 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) crypto_param.auth_alg = param->crypto.auth_alg; crypto_param.auth_key = param->crypto.auth_key; - switch (crypto_param.auth_alg) { - case ODP_AUTH_ALG_NULL: - ipsec_sa->icv_len = 0; - break; -#if ODP_DEPRECATED_API - case ODP_AUTH_ALG_MD5_96: -#endif - case ODP_AUTH_ALG_MD5_HMAC: - ipsec_sa->icv_len = 12; - break; - case ODP_AUTH_ALG_SHA1_HMAC: - ipsec_sa->icv_len = 12; - break; -#if ODP_DEPRECATED_API - case ODP_AUTH_ALG_SHA256_128: -#endif - case ODP_AUTH_ALG_SHA256_HMAC: - ipsec_sa->icv_len = 16; - break; - case ODP_AUTH_ALG_SHA512_HMAC: - ipsec_sa->icv_len = 32; - break; -#if ODP_DEPRECATED_API - case ODP_AUTH_ALG_AES128_GCM: -#endif - case ODP_AUTH_ALG_AES_GCM: - ipsec_sa->icv_len = 16; - break; - default: - goto error; - } - switch (crypto_param.cipher_alg) { case ODP_CIPHER_ALG_NULL: ipsec_sa->esp_iv_len = 0; @@ -339,6 +307,47 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) goto error; } + switch (crypto_param.auth_alg) { + case ODP_AUTH_ALG_NULL: + ipsec_sa->icv_len = 0; + break; +#if ODP_DEPRECATED_API + case ODP_AUTH_ALG_MD5_96: +#endif + case ODP_AUTH_ALG_MD5_HMAC: + ipsec_sa->icv_len = 12; + break; + case ODP_AUTH_ALG_SHA1_HMAC: + ipsec_sa->icv_len = 12; + break; +#if ODP_DEPRECATED_API + case ODP_AUTH_ALG_SHA256_128: +#endif + case ODP_AUTH_ALG_SHA256_HMAC: + ipsec_sa->icv_len = 16; + break; + case ODP_AUTH_ALG_SHA512_HMAC: + ipsec_sa->icv_len = 32; + break; +#if ODP_DEPRECATED_API + case ODP_AUTH_ALG_AES128_GCM: +#endif + case ODP_AUTH_ALG_AES_GCM: + ipsec_sa->icv_len = 16; + break; + case ODP_AUTH_ALG_AES_GMAC: + if (ODP_CIPHER_ALG_NULL != crypto_param.cipher_alg) + return ODP_IPSEC_SA_INVALID; + ipsec_sa->use_counter_iv = 1; + ipsec_sa->esp_iv_len = 8; + ipsec_sa->esp_block_len = 16; + ipsec_sa->icv_len = 16; + crypto_param.iv.length = 12; + break; + default: + goto error; + } + if (1 == ipsec_sa->use_counter_iv && ODP_IPSEC_DIR_OUTBOUND == param->dir) odp_atomic_init_u64(&ipsec_sa->out.counter, 1);