From patchwork Sun Nov 12 23:00:14 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: 118683 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1157829qgn; Sun, 12 Nov 2017 15:11:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMbFHd18OHK84bjZgjXuudlFva9ahJCanoMqnrfEvj/FBCw+IcWUfXZxdDIqN4OhK06T1TTt X-Received: by 10.55.169.210 with SMTP id s201mr3134702qke.124.1510528267891; Sun, 12 Nov 2017 15:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510528267; cv=none; d=google.com; s=arc-20160816; b=nsLiBH9oEpXoQ3eBI9epHLyIzJjnkexdpszpuQt0bsfCeZ/nZ+yHzSJ8D1/9ifxOtY tEKV4qGln57hgx1/HzAlfIoYt2EYKFNhddEtB9YpzsoNyhEQV22WqCF19usBQ50LR6kp 0C6risoY9qDmnNS2lt5FdKZJu4179fzJz3QqDNMvLy+aNg82S64N9rF0N+ORqxh+C+Vw oSnBaazXWMU5XLHPYa/gSykWXmLWRRdpKQraUfEZumiAkGcddE6MD1HUsZq0ERPJSo/+ LLqKs1llr0j9Lpm8WN7v1EaQ1W2kXqtko8wrsrwU/EXy72Y97jIw/S8E3UfOi4GfhpVO yv4Q== 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=btB/58E+rJ7y0/4lkYtt84Jx9j1grUnw03m+8SijxSo=; b=gocJJd99xMP53eAaQp7PVYdnA7JtUk6OQWQ5bBfsw9ERbx3buomWWvVPWxpFwCAmg9 9mEMtWNkA55xYAXvfaWG7Q8zaMdtPtcGpPeGrpWLqglpqpUBeA8VDXlkwuwlK/sD84Ix K2IM3LtyUhduZbj2EYb6wf6duh1ltvkQpsb4BTbD7PlVJzU9/hRQCs2YuGJlNwtpGEPo r9YVwIUedg2UtzmHu7VzPVSZlPxqUOJpbmrljRkZqPIe36+4eKgUjdTwxliSkvkbHoe2 m4aexxBk7Z8+qj2RjAkdsqdzYqLrakggGGeP6BF/iZX0vuVB2P1xGhpPYr1PHIvz+SAn lSkQ== 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 n24si190918qta.37.2017.11.12.15.11.07; Sun, 12 Nov 2017 15:11:07 -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 8248460BFB; Sun, 12 Nov 2017 23:11:07 +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 3920A60C1A; Sun, 12 Nov 2017 23:01: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 304E160A03; Sun, 12 Nov 2017 23:01:12 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id 61C3660654 for ; Sun, 12 Nov 2017 23:00:26 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward101j.mail.yandex.net (Yandex) with ESMTP id 5CFA1124ED5E for ; Mon, 13 Nov 2017 02:00:25 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id JLqmoPW9Yg-0PQ0g9Ot; Mon, 13 Nov 2017 02:00:25 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 3gEL078gGO-0OjWDarQ; Mon, 13 Nov 2017 02:00:24 +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: Mon, 13 Nov 2017 02:00:14 +0300 Message-Id: <1510527615-30536-18-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510527615-30536-1-git-send-email-odpbot@yandex.ru> References: <1510527615-30536-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v13 17/18] linux-gen: ipsec: add AES-CTR cipher support 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 encrypting packets with AES-CTR cipher. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 243 (lumag:ipsec-packet-impl-3) ** https://github.com/Linaro/odp/pull/243 ** Patch: https://github.com/Linaro/odp/pull/243.patch ** Base sha: a908a4dead95321e84d6a8a23de060051dcd8969 ** Merge commit sha: 7261a0ce35cc31342937cb57dcc287aea0c59ede **/ platform/linux-generic/include/odp_ipsec_internal.h | 1 + platform/linux-generic/odp_ipsec.c | 13 +++++++++++++ platform/linux-generic/odp_ipsec_sad.c | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/platform/linux-generic/include/odp_ipsec_internal.h b/platform/linux-generic/include/odp_ipsec_internal.h index 81ecec08e..cfedb7c08 100644 --- a/platform/linux-generic/include/odp_ipsec_internal.h +++ b/platform/linux-generic/include/odp_ipsec_internal.h @@ -128,6 +128,7 @@ struct ipsec_sa_s { unsigned dec_ttl : 1; unsigned copy_dscp : 1; unsigned copy_df : 1; + unsigned aes_ctr_iv : 1; /* Only for outbound */ unsigned use_counter_iv : 1; diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 832c62c94..24b14dc83 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -351,6 +351,13 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, goto err; } + if (ipsec_sa->aes_ctr_iv) { + iv[12] = 0; + iv[13] = 0; + iv[14] = 0; + iv[15] = 1; + } + hdr_len = _ODP_ESPHDR_LEN + ipsec_sa->esp_iv_len; trl_len = _ODP_ESPTRL_LEN + ipsec_sa->icv_len; @@ -743,6 +750,12 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, memcpy(iv + ipsec_sa->salt_length, &ctr, ipsec_sa->esp_iv_len); + if (ipsec_sa->aes_ctr_iv) { + iv[12] = 0; + iv[13] = 0; + iv[14] = 0; + iv[15] = 1; + } } else if (ipsec_sa->esp_iv_len) { uint32_t len; diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index ca42838cd..d5efb095c 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -333,6 +333,13 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) ipsec_sa->esp_block_len = 16; crypto_param.iv.length = 16; break; + case ODP_CIPHER_ALG_AES_CTR: + ipsec_sa->use_counter_iv = 1; + ipsec_sa->aes_ctr_iv = 1; + ipsec_sa->esp_iv_len = 8; + ipsec_sa->esp_block_len = 16; + crypto_param.iv.length = 16; + break; #if ODP_DEPRECATED_API case ODP_CIPHER_ALG_AES128_GCM: #endif