From patchwork Sun Nov 12 12: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: 118643 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp679680qgn; Sun, 12 Nov 2017 04:06:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ8R9V9KQEgv5g0G0WxZSChhiOEj9vuGhpiRcPihEsMvRa5dMAQZwJoWm1Hwyx6EMgXPxBa X-Received: by 10.200.28.69 with SMTP id j5mr8887324qtk.220.1510488401514; Sun, 12 Nov 2017 04:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510488401; cv=none; d=google.com; s=arc-20160816; b=BoF9peVcmG76ZwGvhFNlenpZt5QsaO+lO/fhFJtzeInUO88Yx+Z9FykkOLQBaj4sjJ g5WDoSZygWgV/ABlgYgfUprYaeYt+YLjdykJy2JpK9GMBK0ezGGh/gQRR/Qdc9SJpoQ0 HlJR5PT0Xm3L0X+I7PugLvY1q+qs7/W69kI4tenxI3lQphpzO+6NCnvy4O1e+jsc3PWL Zu6CZRafNkjuHh0fPzsZz5omEp8kTAKZuKks2mtmrEEgFP7YPO9dzvC1jyqZzzrepyWr 7I1FLpG3kMUGcGSE5keBzSWCsiqBHwqgSt5jmHDGbjb+dLDHDuNP75H6u+tTPHlccchG DmcA== 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=SY4T0RkhfUyGqhgUMq8mBQ3cLAxVc05eup8OoDq6hDk=; b=mfHSqaJA7keVWH8bz0ryKUJkq3QYC4uf+UpeMO3tz/z1CGHPr9FVhvfUgu2glvslNF CcfDgEji06pE/d3RotqiidVqukapldPapZBh8Bzvz01uYb3aJ9laM3RlHdtyBpry3l8h FPyXUQPGQWXsgoihsIjDB9mE85hAM5VYSq3nVjsJDCGjDrKxKBGOeXFSBQWMXkqi/2/A lUgG3jqv1WTHe4cwRBiey3kAKghg8BpUI785h+29O1MDxo/Go3IvFYJJXNH0GLGQA14f g75d3Es56zedEs7Ebn9uOsYluFpztjuCsrce7ANZtneqPePAECq3qVMB7PQapbPgX4hv 7siA== 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 l3si102406qtb.307.2017.11.12.04.06.41; Sun, 12 Nov 2017 04:06:41 -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 15F2B60B4C; Sun, 12 Nov 2017 12:06:41 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 6B48060B4E; Sun, 12 Nov 2017 12:01:34 +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 395A4607E1; Sun, 12 Nov 2017 12:00:59 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 1479660A41 for ; Sun, 12 Nov 2017 12:00:13 +0000 (UTC) Received: from mxback18j.mail.yandex.net (mxback18j.mail.yandex.net [IPv6:2a02:6b8:0:1619::94]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 12F142D887BD for ; Sun, 12 Nov 2017 15:00:12 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback18j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id bO7sMHlYfR-0BZSbLBj; Sun, 12 Nov 2017 15:00:12 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id r6E8l2cXPM-0BW4XJfe; Sun, 12 Nov 2017 15: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: Sun, 12 Nov 2017 15:00:05 +0300 Message-Id: <1510488007-21101-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510488007-21101-1-git-send-email-odpbot@yandex.ru> References: <1510488007-21101-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v4 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: a908a4dead95321e84d6a8a23de060051dcd8969 ** Merge commit sha: 9fff58cf77d87306efed89f77e84f957850623d5 **/ platform/linux-generic/odp_ipsec_sad.c | 66 +++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index b2d12eada..e76c7a195 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -263,6 +263,40 @@ 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; + crypto_param.iv.length = 0; + break; + case ODP_CIPHER_ALG_DES: + case ODP_CIPHER_ALG_3DES_CBC: + ipsec_sa->esp_iv_len = 8; + ipsec_sa->esp_block_len = 8; + crypto_param.iv.length = 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; + crypto_param.iv.length = 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; + crypto_param.iv.length = 12; + break; + default: + goto error; + } + switch (crypto_param.auth_alg) { case ODP_AUTH_ALG_NULL: ipsec_sa->icv_len = 0; @@ -291,37 +325,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; - crypto_param.iv.length = 0; - break; - case ODP_CIPHER_ALG_DES: - case ODP_CIPHER_ALG_3DES_CBC: - ipsec_sa->esp_iv_len = 8; - ipsec_sa->esp_block_len = 8; - crypto_param.iv.length = 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; - crypto_param.iv.length = 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; + ipsec_sa->icv_len = 16; crypto_param.iv.length = 12; break; default: