From patchwork Thu Nov 9 02: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: 118368 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6016297qgn; Wed, 8 Nov 2017 18:03:45 -0800 (PST) X-Google-Smtp-Source: ABhQp+SAXA/Aok7zjZ8plyKgzgvrHHz/nSjuRg6cRrWKjPjKSvyC1PgoW85bO1q1k5JNPWIYcgV0 X-Received: by 10.200.33.199 with SMTP id 7mr4160757qtz.35.1510193025120; Wed, 08 Nov 2017 18:03:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510193025; cv=none; d=google.com; s=arc-20160816; b=twFhUZ69Ntm/FgLVlaU/PbhSn23oyzOPZQ8rFwx/f0J4NEGAYInRKa3Fo6huS8pJSg Jz6f7vQ1Pj5p3J1XwdcwZ0XW01kCaonZUqSIABh6omaFModrlMjMC7YYohkB6GCDLb5d n8eh2SpPynfAQVoew6nKSf8LQ8aSQfNd9tKZj+Mcbvql1t40Z5lQvjO0OhjeZAKKSzMH sGOqDvuCo0/tb4y+cLcbR7Y6Se0CoXMcFBneeODI0j/oNMPpofPdy4M1qj/TGCES42Eh yqroeyp9Yi5PbTb7+V2DXWWPzTg6IfChzVj06rppYqR/OcujNlMNqV7SDijbAX7Z42vO hSHg== 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=ebboOqeZPS7sLJnxSsiKxdMupjzAsGMBV+XSyNnGuIk=; b=SAqQBP2yYlIh/sFEZWsr17Bn4+n4AiPviQ7W1QCxkL2KKvumX3j5H2EHwAA2uTkWAO kYvOfNEwga9sZnDANLwn/jIQXVF2+zDg9Fmc/eBDIlVDbi/93RE0RMCAY9NRcg9ppUqR rpYJywmxHey/lNNsQFLqF1A53E5P/6i9BPmSCDFM6YwRChToTYSA/OicY/8xZTY6omai pPraRyuv0TR8sWXXeGmQ799Y3PrtjjkEorW+PdVXDLnT1dYqeubnQ1CC7ktdtowlI4u3 3F58m1WFUbDg+i9jg+/Gq6h1vLlk6uy+lo99uUTjzxh44gdU1yPOEKj+q1CfuWHDrbCs ktyg== 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 d31si5723000qkh.314.2017.11.08.18.03.44; Wed, 08 Nov 2017 18:03:45 -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 CFF3860AF8; Thu, 9 Nov 2017 02:03:44 +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 D6E8060B5E; Thu, 9 Nov 2017 02:00:38 +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 0121260890; Thu, 9 Nov 2017 02:00:17 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id D905860605 for ; Thu, 9 Nov 2017 02:00:12 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 8C50C134508A for ; Thu, 9 Nov 2017 05:00:11 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id mRVfX6L3m9-0BsemBko; Thu, 09 Nov 2017 05:00:11 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ftGesT1mbP-0BEq9REr; Thu, 09 Nov 2017 05:00:11 +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: Thu, 9 Nov 2017 05:00:05 +0300 Message-Id: <1510192807-13538-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510192807-13538-1-git-send-email-odpbot@yandex.ru> References: <1510192807-13538-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v2 6/8] 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: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: d0ac0597cf696e17a40a8eba131ad379ba0fa08f **/ platform/linux-generic/odp_ipsec_sad.c | 60 +++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index 457b81d04..369d927ee 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -263,6 +263,36 @@ 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.cipher_alg) { + case ODP_CIPHER_ALG_NULL: + ipsec_sa->esp_iv_len = 0; + ipsec_sa->esp_block_len = 1; + break; + case ODP_CIPHER_ALG_DES: + case ODP_CIPHER_ALG_3DES_CBC: + ipsec_sa->esp_iv_len = 8; + ipsec_sa->esp_block_len = 8; + break; +#if ODP_DEPRECATED_API + case ODP_CIPHER_ALG_AES128_CBC: +#endif + case ODP_CIPHER_ALG_AES_CBC: + ipsec_sa->esp_iv_len = 16; + ipsec_sa->esp_block_len = 16; + break; +#if ODP_DEPRECATED_API + case ODP_CIPHER_ALG_AES128_GCM: +#endif + case ODP_CIPHER_ALG_AES_GCM: + ipsec_sa->use_counter_iv = 1; + ipsec_sa->esp_iv_len = 8; + ipsec_sa->esp_block_len = 16; + ipsec_sa->icv_len = 16; + break; + default: + goto error; + } + switch (crypto_param.auth_alg) { case ODP_AUTH_ALG_NULL: ipsec_sa->icv_len = 0; @@ -291,35 +321,13 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) 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; - ipsec_sa->esp_block_len = 1; - break; - case ODP_CIPHER_ALG_DES: - case ODP_CIPHER_ALG_3DES_CBC: - ipsec_sa->esp_iv_len = 8; - ipsec_sa->esp_block_len = 8; - break; -#if ODP_DEPRECATED_API - case ODP_CIPHER_ALG_AES128_CBC: -#endif - case ODP_CIPHER_ALG_AES_CBC: - ipsec_sa->esp_iv_len = 16; - ipsec_sa->esp_block_len = 16; - break; -#if ODP_DEPRECATED_API - case ODP_CIPHER_ALG_AES128_GCM: -#endif - case ODP_CIPHER_ALG_AES_GCM: + 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; - crypto_param.iv.length = 12; + ipsec_sa->icv_len = 16; break; default: goto error;