From patchwork Sun Nov 12 12:00:22 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: 118661 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp690522qgn; Sun, 12 Nov 2017 04:20:02 -0800 (PST) X-Google-Smtp-Source: AGs4zMaPEM+aT/y54ZJO6klOcoKjFILPhJ/R6F9jKmr0Rxg8wx4dhGdC3mjN1SP3/tVUvK/RI0cl X-Received: by 10.200.63.209 with SMTP id v17mr1735831qtk.242.1510489202717; Sun, 12 Nov 2017 04:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510489202; cv=none; d=google.com; s=arc-20160816; b=YskR5qK3ih5mjMryg+PSoosn/nWuDl7m3QbSksXKOn321CXG04jnCs784lSWCS40Ww +6oYXvPHFi6Lij1tNAJ1qFuKAXNsQpPLjA8TGLg1C/rMCWv5ANM7yYatb8bUkclvA1lj 9sD/3baHQfbyOF5ZNJu0cmVErro1tmfs5om25fJqj1SVi4nkRXDdA7Ytlb8p+HJI5rgo 2OS4c0sKgyVLxOVk0z5pOrMBFCUUok2H6h8qGfR4KFLGKJBifAUY0kLSQzCdgLAGTHNo eisMO/1+bUrDyGSqNGwNBefaWb87YVP5hFgt4+BlfpppEW+uz2Rc1nsIauTmCOmk6Hxi K6Sw== 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=jmTxEPLzJmhSVGzGse2wWi5XEbF4Toq9V2JEZFssSec=; b=OKJXZv/ErX0VcvbA4EdlhiAU2+lLUjF3yf9G+BiRSGVyMYy4zVIiBoD7XFKW6kkDE/ d5+Y78xDpDkoNBINo4cqwBJaovR+b/nfMLpg8vCuPiCo6W3P+L/XIgioGqtWuq6ZYPY0 dWBn/i8AY6dw9MeDMWn9do0Ix40F/+SMYyJMSVinSMioWBN5Z7uKLm1fnDDvVFa0lb7h pneSQYKsaSn7JhCnx/kLR4/Gx01fw5gAoRLTIk1b+Bt2sob+zJwX9FnvzzTVFgJfKqhn 2z5s8F/Fa/QOCUWdb2aMcnybvDL6run0Dh4UpMCB0KypKSTaTSyVM5luynPTHgGGg0gp Oisg== 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 q29si1740909qkq.36.2017.11.12.04.20.02; Sun, 12 Nov 2017 04:20:02 -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 6AC2560BDC; Sun, 12 Nov 2017 12:20:02 +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 4B00A60C6A; Sun, 12 Nov 2017 12:02:51 +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 9A30660C0F; Sun, 12 Nov 2017 12:02:17 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 5711D60AC6 for ; Sun, 12 Nov 2017 12:00:33 +0000 (UTC) Received: from mxback4g.mail.yandex.net (mxback4g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:165]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 4FFC243083B6 for ; Sun, 12 Nov 2017 15:00:32 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback4g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9awP6QJcpL-0WNetOZ1; Sun, 12 Nov 2017 15:00:32 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 3w91frotLT-0VvagY1i; Sun, 12 Nov 2017 15:00:32 +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:22 +0300 Message-Id: <1510488023-21204-18-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510488023-21204-1-git-send-email-odpbot@yandex.ru> References: <1510488023-21204-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v12 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: e8722a0cdda227e01e7d308573aec08112d3c5b0 **/ 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 4e867c797..72647045c 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