From patchwork Mon Nov 13 02:00:18 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: 118708 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1272392qgn; Sun, 12 Nov 2017 18:11:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ0jD4kR1hzLCJnAdkOozokHX0vqMM/V77GEtgCv0e7tPwADZ4ebPrXc+6ifZyKSNJ4fBSe X-Received: by 10.200.53.171 with SMTP id k40mr12399560qtb.264.1510539067293; Sun, 12 Nov 2017 18:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510539067; cv=none; d=google.com; s=arc-20160816; b=if4CVCUhr9eD8gY7S/tXGHVP4lo/DR57YgjQeq+aGPG1z+IUC63S2wpMC6rfaCNJrL xmHPhbmtMmUy1FzpqPK72WwDK7kwqeq/k7qqqbXnuh/ONkRLvwl8BQT6lalCT6D0aj95 PkLpwJfQJxZzZdGJIs2culjDI341vgBVdao0i3FpepaXfE4x7Jby8PmlUziV/MzvBE6p 17nahMp6TMw445ukNqs22QZtSERNKsvIE87OwDZWfHSVpUsb8zaJEypUc/EBZ83xasEU v/36+N3TyeGDk6+8uxUj6OCFJh38J/fQBTmmp10y4kOLtus4wo3JLHpg5VM6rCEIo1qd 9v4Q== 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=dorOV8r/pf73CkUXRms3UfwWXhS6VyeKSCzjmKIQMRM=; b=NVr+n4A1qaqpgv3ioR5L9Cdj7D6S/s+DivEi8Du3Kbt3mOJlrP/u8OYpTyI0OImKIJ AjQos68o0yFtH9tixxSQVS9pB9e4yxSkCKTiq+rcs2Z1PgRKJ6gY2xWrDt+D/vWVD6Bb jiMjg0rB20LLKDzUF9sPrWWAnB3D4nytH6MUMKcz3qi1O0dcPoJHe0uCoKR/u+F61+EY GzY0x7wanqPL+LtOH0cLXl6qXaauv7naxRnXvG/T7buMjXYxw/LklnUrGJVxvR2PvhHF cDdc7Tqdz2xCkCIYMuNZ/NvrWkPZI0h1qWnKoZY3VWWXOygIBO27dWYHYkx5xXysZgHQ iJog== 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 k66si276741qkf.457.2017.11.12.18.11.07; Sun, 12 Nov 2017 18: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 EA2FB60CDF; Mon, 13 Nov 2017 02:11:06 +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 1723961005; Mon, 13 Nov 2017 02:02:50 +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 9E6DA61002; Mon, 13 Nov 2017 02:02:44 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 1FF6160C35 for ; Mon, 13 Nov 2017 02:00:30 +0000 (UTC) Received: from mxback7j.mail.yandex.net (mxback7j.mail.yandex.net [IPv6:2a02:6b8:0:1619::110]) by forward100o.mail.yandex.net (Yandex) with ESMTP id CE8012A250E8 for ; Mon, 13 Nov 2017 05:00:27 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback7j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id csqS13N25N-0RJi98tF; Mon, 13 Nov 2017 05:00:27 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id uZeq9OjDfk-0Rv8o5OW; Mon, 13 Nov 2017 05:00:27 +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 05:00:18 +0300 Message-Id: <1510538419-566-14-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510538419-566-1-git-send-email-odpbot@yandex.ru> References: <1510538419-566-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v15 13/14] 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: 44a6636daa5f976c8aac76116e80e0c764352072 **/ 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 0a7f96256..b50b65be6 100644 --- a/platform/linux-generic/include/odp_ipsec_internal.h +++ b/platform/linux-generic/include/odp_ipsec_internal.h @@ -127,6 +127,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 ca02549ea..092592266 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -337,6 +337,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; @@ -729,6 +736,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 425175692..8eaa4f902 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -319,6 +319,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