From patchwork Tue Nov 14 20:00:02 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: 118881 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3458506qgn; Tue, 14 Nov 2017 12:00:26 -0800 (PST) X-Google-Smtp-Source: AGs4zMYqdk1ICIqURUlUICDZTeQyYKved7lKHdYfKNVit1gd2ZOW+vrt016HmUvH2yf9l4fod66b X-Received: by 10.200.3.158 with SMTP id t30mr4578868qtg.149.1510689626320; Tue, 14 Nov 2017 12:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689626; cv=none; d=google.com; s=arc-20160816; b=aBR7+UI0lGPVyfbsCOt1cz633qBN8QRxMOg6+9u+e7nPG9V4Mz7std5L+vQtU676EM CFMWZFpoBk+Yuhgi3WRZor0AJpsW+LAemNJ+qoGkNQaM9Pmz3zwh8XVG2eUM66aZYufC QPjs9Y/GlxsX+T5x0UuYP8OHrN3LDxb5ZUf0q5Ci+3dwQ+qY7bDLqzA7jzzlzva+nNHL 4imnkugISkfnm2x4q3HqeVsenWwirMtcWa0/68ywofNbrXSVzJvSSmqJEd4xAzzRvzrA Mv2e3BFIc0kq5HdAABfBlI4g/a5XYQmbzssxip8AWJ0IhK9IQUmCzh14gp4rrK5crV01 n3Tw== 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=gJhZ79yfEBYluke846SK3MR8xD9YSKbDcz6MpLj0hvg=; b=Ub1AjVLsRt94UCSGRKvsC9yMzYHqLHZj1sp9l1KQAhJEPWTBqqVXxJOnGgjfzLUz0W DBpVTb5V6jTJyuu6qz+dwdeuuz4PfhsLZYEhJG79+P2SxtfJy5aWrbBPirhs2vGUEFMM AS02x/5P9u1X9jLs31GgSZ7SraC4qgc2sVgysfECasUGfcPz8gRQaHY7hrgvQVoBOk2O 8st6vcowh2gzgnaVKeknwHavv/XtCU2wGesGsjGVrmWPEUPfHQrOiW+X9+Izv4NHIoAh im8kfD4A3J1aWgbZ740wUxLiFon++V6UoHxb8oOqeKvdPoLwR2LOin7/OM+nPs3GLtuC wr6A== 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 a17si6318026qtk.103.2017.11.14.12.00.26; Tue, 14 Nov 2017 12:00:26 -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 00E9B60606; Tue, 14 Nov 2017 20:00:25 +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 6B36160667; Tue, 14 Nov 2017 20:00:18 +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 A0E2D60641; Tue, 14 Nov 2017 20:00:15 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 50D6D60606 for ; Tue, 14 Nov 2017 20:00:14 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward102j.mail.yandex.net (Yandex) with ESMTP id C4B3556047A1 for ; Tue, 14 Nov 2017 23:00:12 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Pf1KpuZ7t3-0C2uRuq1; Tue, 14 Nov 2017 23:00:12 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0CpGtbPu; Tue, 14 Nov 2017 23:00:12 +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: Tue, 14 Nov 2017 23:00:02 +0300 Message-Id: <1510689611-17861-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 1/10] api: crypto: add AES-GMAC declarations 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 AES-GMAC declarations to support RFC4543. 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ include/odp/api/spec/crypto.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index ed1fd6784..6a4304d8b 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -134,6 +134,20 @@ typedef enum { */ ODP_AUTH_ALG_AES_GCM, + /** AES in Galois/Counter MAC Mode + * + * NIST and RFC specifications of GCM/GMAC refer to all data to be + * authenticated as AAD. In constrast to that, ODP API specifies the + * bulk of authenticated data to be located in packet payload for all + * authentication algorithms, including GMAC. Thus for GMAC application + * should also pass all data to be authenticated as packet data. AAD is + * not used for GMAC. GMAC IV should be passed via session IV or + * per-packet IV override. + * + * @note Must be paired with cipher ODP_CIPHER_ALG_NULL + */ + ODP_AUTH_ALG_AES_GMAC, + /** @deprecated Use ODP_AUTH_ALG_MD5_HMAC instead */ ODP_DEPRECATE(ODP_AUTH_ALG_MD5_96), @@ -208,6 +222,9 @@ typedef union odp_crypto_auth_algos_t { /** ODP_AUTH_ALG_AES_GCM */ uint32_t aes_gcm : 1; + /** ODP_AUTH_ALG_AES_GMAC*/ + uint32_t aes_gmac : 1; + /** @deprecated Use md5_hmac instead */ uint32_t ODP_DEPRECATE(md5_96) : 1; From patchwork Tue Nov 14 20:00:03 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: 118883 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3460723qgn; Tue, 14 Nov 2017 12:02:02 -0800 (PST) X-Google-Smtp-Source: AGs4zMZbrGZPQ3c83EThX+FTwsJTUbT5wso9IuPncHiLYsx4VvrtPnm66p2PXxKsYPGjpiEsTiwQ X-Received: by 10.55.18.231 with SMTP id 100mr21569660qks.115.1510689722671; Tue, 14 Nov 2017 12:02:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689722; cv=none; d=google.com; s=arc-20160816; b=CCfqeqyGExJ99vDrYRTLW7wM4jIVF0aLi1gQDqlKL/qh6KuDFZseybWxUMt4zUYwgb k/PPgg7ljllOtaaV1MpCeKa82gfIFe60D2W74MNjw6nKNKjsfZ2BaX75iGS9XREC87gu jlRU/5ZgJsV7Y4UMlcSpXzGtfuDek7GyK29PW+Xw8TK7TzA5oTmojcHeR7cNUanekiWc 6OFZWarULBCz/jc++7wb6h6jRZApC4qLRn8pmjQeU8uYUXsep/JrJOG5iKRlYw2dppO+ jCURChnrGe3gA/axWjQFQcyfp0lFehu6GuXvEd+drmojfqPA5wH6zl+EzNSh+SG/2gDi kzQA== 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=qpSWgeo2Lh6h4oKef73wbL1g5lOjR5c/kz5t6K4RhzA=; b=kSGmIQFiWyN6qvkBwnUqoasYyqZa41x9bNBdWLpmYljlDkNeOHVomwuJICqWZwrtjL n/rPyA+aJ7/lRj7m9qIzb9P4wy/9jnJiFE4QRszPX0jHk2TORgPjPwKq2oYmcW65yraX 7JpR7V5wVD8R0XUSrSVdLkN3jY0C11pu+wiVX4KOvEkcKGgzB4aM+Uk3xo1etG0N8xmZ 6X/X8t6UrE4a1orAqiasbmdk9G2T8Y4dLDxyoBU1pANAjKooBIUd5OvNUBEEw/up6tTS IxGdxeSJR+s+MtLx7CW+mLh30/Hozkf8kp+VKOPnsh054RjT0zLVtEt6f4Cu8Y7Dv3nD Cn1g== 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 s3si550270qkd.22.2017.11.14.12.02.02; Tue, 14 Nov 2017 12:02: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 468246086D; Tue, 14 Nov 2017 20:02: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 E544B6068B; Tue, 14 Nov 2017 20:00:29 +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 2740D6068D; Tue, 14 Nov 2017 20:00:19 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id E018F60636 for ; Tue, 14 Nov 2017 20:00:14 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 584D84082A8D for ; Tue, 14 Nov 2017 23:00:13 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 6Khx7gxiln-0DKW6X8p; Tue, 14 Nov 2017 23:00:13 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0CpqZ92h; Tue, 14 Nov 2017 23:00:12 +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: Tue, 14 Nov 2017 23:00:03 +0300 Message-Id: <1510689611-17861-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 2/10] validation: crypto: add AES-GMAC testcase 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 AES-GMAC test vector based on draft-mcgrew-gcm-test-01. 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ test/validation/api/crypto/crypto.h | 2 ++ test/validation/api/crypto/odp_crypto_test_inp.c | 46 ++++++++++++++++++++++++ test/validation/api/crypto/test_vectors.h | 33 +++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/test/validation/api/crypto/crypto.h b/test/validation/api/crypto/crypto.h index ba1058f35..078a1909f 100644 --- a/test/validation/api/crypto/crypto.h +++ b/test/validation/api/crypto/crypto.h @@ -36,6 +36,8 @@ void crypto_test_gen_alg_hmac_sha256(void); void crypto_test_check_alg_hmac_sha256(void); void crypto_test_gen_alg_hmac_sha512(void); void crypto_test_check_alg_hmac_sha512(void); +void crypto_test_gen_alg_aes_gmac(void); +void crypto_test_check_alg_aes_gmac(void); /* test arrays: */ extern odp_testinfo_t crypto_suite[]; diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index 1f7523de2..fdc0db8e3 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -50,6 +50,8 @@ static const char *auth_alg_name(odp_auth_alg_t auth) return "ODP_AUTH_ALG_SHA512_HMAC"; case ODP_AUTH_ALG_AES_GCM: return "ODP_AUTH_ALG_AES_GCM"; + case ODP_AUTH_ALG_AES_GMAC: + return "ODP_AUTH_ALG_AES_GMAC"; default: return "Unknown"; } @@ -344,6 +346,9 @@ static void alg_test(odp_crypto_op_t op, if (auth_alg == ODP_AUTH_ALG_AES_GCM && !(capa.auths.bit.aes_gcm)) rc = -1; + if (auth_alg == ODP_AUTH_ALG_AES_GMAC && + !(capa.auths.bit.aes_gmac)) + rc = -1; if (auth_alg == ODP_AUTH_ALG_MD5_HMAC && !(capa.auths.bit.md5_hmac)) rc = -1; @@ -588,6 +593,10 @@ static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth) if (!capability.auths.bit.aes_gcm) return ODP_TEST_INACTIVE; break; + case ODP_AUTH_ALG_AES_GMAC: + if (!capability.auths.bit.aes_gmac) + return ODP_TEST_INACTIVE; + break; default: fprintf(stderr, "Unsupported authentication algorithm\n"); return ODP_TEST_INACTIVE; @@ -1114,6 +1123,39 @@ void crypto_test_check_alg_hmac_sha512(void) false); } +static int check_alg_aes_gmac(void) +{ + return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_AES_GMAC); +} + +void crypto_test_gen_alg_aes_gmac(void) +{ + unsigned int test_vec_num = (sizeof(aes_gmac_reference) / + sizeof(aes_gmac_reference[0])); + unsigned int i; + + for (i = 0; i < test_vec_num; i++) + alg_test(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_AES_GMAC, + &aes_gmac_reference[i], + false); +} + +void crypto_test_check_alg_aes_gmac(void) +{ + unsigned int test_vec_num = (sizeof(aes_gmac_reference) / + sizeof(aes_gmac_reference[0])); + unsigned int i; + + for (i = 0; i < test_vec_num; i++) + alg_test(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_AES_GMAC, + &aes_gmac_reference[i], + false); +} + int crypto_suite_sync_init(void) { suite_context.pool = odp_pool_lookup("packet_pool"); @@ -1219,6 +1261,10 @@ odp_testinfo_t crypto_suite[] = { check_alg_hmac_sha512), ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_hmac_sha512, check_alg_hmac_sha512), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac, + check_alg_aes_gmac), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac, + check_alg_aes_gmac), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/crypto/test_vectors.h b/test/validation/api/crypto/test_vectors.h index 63103227a..f2ce9eb2f 100644 --- a/test/validation/api/crypto/test_vectors.h +++ b/test/validation/api/crypto/test_vectors.h @@ -442,6 +442,39 @@ static crypto_test_reference_t aes_gcm_reference[] = { } }; +static crypto_test_reference_t aes_gmac_reference[] = { + { + .auth_key_length = AES128_GCM_KEY_LEN, + .auth_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, + 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, + .iv_length = AES_GCM_IV_LEN, + .iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, + .length = 68, + .plaintext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, + 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x01, 0x02, 0x02, 0x01 }, + .ciphertext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, + 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x01, 0x02, 0x02, 0x01 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0xf2, 0xa9, 0xa8, 0x36, 0xe1, 0x55, 0x10, 0x6a, + 0xa8, 0xdc, 0xd6, 0x18, 0xe4, 0x09, 0x9a, 0xaa } + }, +}; + static crypto_test_reference_t hmac_md5_reference[] = { { .auth_key_length = HMAC_MD5_KEY_LEN, From patchwork Tue Nov 14 20:00:04 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: 118882 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3459560qgn; Tue, 14 Nov 2017 12:01:12 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ3Y3HBDNOxj2iXlcX9YZ0VkMu438/+qG27wCR/fLtMz6gYinSrax2lPUvb7vSGACaNXKGy X-Received: by 10.237.53.200 with SMTP id d8mr1799930qte.32.1510689672775; Tue, 14 Nov 2017 12:01:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689672; cv=none; d=google.com; s=arc-20160816; b=kSAowcGdw+i92/0ZW4Xt1+AtOWYl7DQnAFr8z554gkhdC5mdGpDA3iVpQX/8WZDB7h Bet0yJu2/7AYjn510wYvKXOLV414wcjN7+SGtDEbPq+1lt0wT6GU3Tpos195ZNqvdNRV QzG1dulH2JcHzfuUjAXTxjv2LOzpKdkTP14HbrYnHLccYiu3PHvRXmp9FFA6HoUGtUA5 JKE4JR3tSajtF5ZMDjxDOlDZZWwdom50R8OQD2WB6HfF1FbIjzE753L3IMsw1TLvM4iu Fh7Wh9EJEcSV/+2TgRuliVYoUhGmTxmR+m8erUO/v5HGZpAZikpqw3HJuvax6aeN+fho 30dg== 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=D/D4YwlNSNpbT58+DrE8m8ZC07OudGWu/t55Wudmc1c=; b=I7CiedKPcpvYJLfFJ8CF3jGzfti2Ko+nQdZxrWpNZRNmk991E+PzzOHKtfYAm1jlG5 2d87rtNqWKW/XUR6FyXOecaW2YDm96+PdZXZLEHwoCSLbHT5yu+bxwMAzOXlEA6/QeIU Rke9wc5miDeHAIzGz8B0bDEB22kKwcKQLGHsx6QGtXkLtFnaLr+MxZ0f3GICUrmVcOqY L1463IkAV/Gd6CR5AuHjLINEu5WrcqR3xSzMktLvwj+lgkfSdBZKzT72+TUrMRycAMD1 t97b4tD09raCzyGy/exz9Yhiv6dBU8SIQPeCIEtwcediey3LZJUlzgo6z93j8ukAGKn4 mfAQ== 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 c188si1718060qkd.228.2017.11.14.12.01.12; Tue, 14 Nov 2017 12:01:12 -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 6029060812; Tue, 14 Nov 2017 20:01:12 +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 A39E160606; Tue, 14 Nov 2017 20:00:26 +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 EEDEB60639; Tue, 14 Nov 2017 20:00:18 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 137CB60639 for ; Tue, 14 Nov 2017 20:00:15 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward106o.mail.yandex.net (Yandex) with ESMTP id BADB2783DBA for ; Tue, 14 Nov 2017 23:00:13 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id AtbpJE8aui-0DgSZh5i; Tue, 14 Nov 2017 23:00:13 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0DpGFHYQ; Tue, 14 Nov 2017 23:00:13 +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: Tue, 14 Nov 2017 23:00:04 +0300 Message-Id: <1510689611-17861-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 3/10] linux-gen: crypto: add AES-GMAC implementation 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 on top of OpenSSL AES-GCM with all text going into AAD part. 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ .../linux-generic/include/odp_crypto_internal.h | 5 +- platform/linux-generic/odp_crypto.c | 151 ++++++++++++++++++++- 2 files changed, 154 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index 12d1720b7..21174daa4 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -51,7 +51,10 @@ struct odp_crypto_generic_session { uint8_t key[EVP_MAX_KEY_LENGTH]; uint32_t key_length; uint32_t bytes; - const EVP_MD *evp_md; + union { + const EVP_MD *evp_md; + const EVP_CIPHER *evp_cipher; + }; crypto_func_t func; } auth; }; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index f34863bf2..1cc2d7018 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -37,7 +37,9 @@ * Keep sorted: first by key length, then by IV length */ static const odp_crypto_cipher_capability_t cipher_capa_null[] = { -{.key_len = 0, .iv_len = 0} }; +{.key_len = 0, .iv_len = 0}, +/* Special case for GMAC */ +{.key_len = 0, .iv_len = 12} }; static const odp_crypto_cipher_capability_t cipher_capa_trides_cbc[] = { {.key_len = 24, .iv_len = 8} }; @@ -84,6 +86,9 @@ static const odp_crypto_auth_capability_t auth_capa_sha512_hmac[] = { static const odp_crypto_auth_capability_t auth_capa_aes_gcm[] = { {.digest_len = 16, .key_len = 0, .aad_len = {.min = 8, .max = 12, .inc = 4} } }; +static const odp_crypto_auth_capability_t auth_capa_aes_gmac[] = { +{.digest_len = 16, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} } }; + typedef struct odp_crypto_global_s odp_crypto_global_t; struct odp_crypto_global_s { @@ -236,6 +241,33 @@ odp_crypto_alg_err_t auth_check(odp_packet_t pkt, } static +int internal_aad(EVP_CIPHER_CTX *ctx, + odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param) +{ + uint32_t offset = param->auth_range.offset; + uint32_t len = param->auth_range.length; + int dummy_len; + int ret; + + ODP_ASSERT(offset + len <= odp_packet_len(pkt)); + + while (len > 0) { + uint32_t seglen = 0; /* GCC */ + void *mapaddr = odp_packet_offset(pkt, offset, &seglen, NULL); + uint32_t maclen = len > seglen ? seglen : len; + + EVP_EncryptUpdate(ctx, NULL, &dummy_len, mapaddr, maclen); + offset += maclen; + len -= maclen; + } + + ret = EVP_EncryptFinal_ex(ctx, NULL, &dummy_len); + + return ret; +} + +static int internal_encrypt(EVP_CIPHER_CTX *ctx, odp_packet_t pkt, const odp_crypto_packet_op_param_t *param) @@ -556,6 +588,108 @@ static int process_aes_gcm_param(odp_crypto_generic_session_t *session, return 0; } +static +odp_crypto_alg_err_t aes_gmac_gen(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, + odp_crypto_generic_session_t *session) +{ + EVP_CIPHER_CTX *ctx; + void *iv_ptr; + uint8_t block[EVP_MAX_MD_SIZE]; + int ret; + + if (param->override_iv_ptr) + iv_ptr = param->override_iv_ptr; + else if (session->p.iv.data) + iv_ptr = session->cipher.iv_data; + else + return ODP_CRYPTO_ALG_ERR_IV_INVALID; + + /* Encrypt it */ + ctx = EVP_CIPHER_CTX_new(); + EVP_EncryptInit_ex(ctx, session->auth.evp_cipher, NULL, + session->auth.key, NULL); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + session->p.iv.length, NULL); + EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); + EVP_CIPHER_CTX_set_padding(ctx, 0); + + ret = internal_aad(ctx, pkt, param); + + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, + session->p.auth_digest_len, block); + odp_packet_copy_from_mem(pkt, param->hash_result_offset, + session->p.auth_digest_len, block); + + EVP_CIPHER_CTX_free(ctx); + + return ret <= 0 ? ODP_CRYPTO_ALG_ERR_DATA_SIZE : + ODP_CRYPTO_ALG_ERR_NONE; +} + +static +odp_crypto_alg_err_t aes_gmac_check(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, + odp_crypto_generic_session_t *session) +{ + EVP_CIPHER_CTX *ctx; + void *iv_ptr; + uint8_t block[EVP_MAX_MD_SIZE]; + int ret; + + if (param->override_iv_ptr) + iv_ptr = param->override_iv_ptr; + else if (session->p.iv.data) + iv_ptr = session->cipher.iv_data; + else + return ODP_CRYPTO_ALG_ERR_IV_INVALID; + + /* Decrypt it */ + ctx = EVP_CIPHER_CTX_new(); + EVP_DecryptInit_ex(ctx, session->auth.evp_cipher, NULL, + session->auth.key, NULL); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + session->p.iv.length, NULL); + EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); + EVP_CIPHER_CTX_set_padding(ctx, 0); + + odp_packet_copy_to_mem(pkt, param->hash_result_offset, + session->p.auth_digest_len, block); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, + session->p.auth_digest_len, block); + _odp_packet_set_data(pkt, param->hash_result_offset, + 0, session->p.auth_digest_len); + + ret = internal_aad(ctx, pkt, param); + + EVP_CIPHER_CTX_free(ctx); + + return ret <= 0 ? ODP_CRYPTO_ALG_ERR_ICV_CHECK : + ODP_CRYPTO_ALG_ERR_NONE; +} + +static int process_aes_gmac_param(odp_crypto_generic_session_t *session, + const EVP_CIPHER *cipher) +{ + /* Verify Key len is valid */ + if ((uint32_t)EVP_CIPHER_key_length(cipher) != + session->p.auth_key.length) + return -1; + + memcpy(session->auth.key, session->p.auth_key.data, + session->p.auth_key.length); + + session->auth.evp_cipher = cipher; + + /* Set function */ + if (ODP_CRYPTO_OP_ENCODE == session->p.op) + session->auth.func = aes_gmac_gen; + else + session->auth.func = aes_gmac_check; + + return 0; +} + static int process_auth_param(odp_crypto_generic_session_t *session, uint32_t key_length, const EVP_MD *evp_md) @@ -601,6 +735,7 @@ int odp_crypto_capability(odp_crypto_capability_t *capa) capa->auths.bit.sha256_hmac = 1; capa->auths.bit.sha512_hmac = 1; capa->auths.bit.aes_gcm = 1; + capa->auths.bit.aes_gmac = 1; #if ODP_DEPRECATED_API capa->ciphers.bit.aes128_cbc = 1; @@ -688,6 +823,10 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth, src = auth_capa_aes_gcm; num = sizeof(auth_capa_aes_gcm) / size; break; + case ODP_AUTH_ALG_AES_GMAC: + src = auth_capa_aes_gmac; + num = sizeof(auth_capa_aes_gmac) / size; + break; default: return -1; } @@ -859,6 +998,16 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, rc = -1; } break; + case ODP_AUTH_ALG_AES_GMAC: + if (param->auth_key.length == 16) + rc = process_aes_gmac_param(session, EVP_aes_128_gcm()); + else if (param->auth_key.length == 24) + rc = process_aes_gmac_param(session, EVP_aes_192_gcm()); + else if (param->auth_key.length == 32) + rc = process_aes_gmac_param(session, EVP_aes_256_gcm()); + else + rc = -1; + break; default: rc = -1; } From patchwork Tue Nov 14 20: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: 118885 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3463876qgn; Tue, 14 Nov 2017 12:04:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMY2aDi3tH9/RwUXwkXbq4ExRC+ooElLY5YdMHFWafBnAAgrbvN+Yyht+Fj+nJPE7Mq2/f8n X-Received: by 10.233.222.135 with SMTP id s129mr922998qkf.261.1510689856624; Tue, 14 Nov 2017 12:04:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689856; cv=none; d=google.com; s=arc-20160816; b=JFGXKWtZphEF1qqOkG25j5bziBwlQK0BFOr9JAt77m1aScxE99SRzGUBX24704+S3P j/IGXbEPRVgLImxC9H+pIAFlwzp2eWQfqCS5KzlS00rl5xwt/Ah4FampQPdmEzZZVGPu XS2Bhh6+R1d+2BUm//qSTGbeyWvGE4Vx4plshjP2nZZBRxCsyq0lzb+5Wh+km73Scwx3 RuexjxWg0cgTFe/PihWQLnuKImMv3S42Akfo45535zKu2SBJsxcUUWwx5f5u9H+5G2bo qERxzGNaRD8DGN8lPKed5MCCFveWeh/NU1Txv43oaoKhvgxef+4z5XigBGVxcrd87T5p S3tA== 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=TaWBzoViElhvj1z52zEzR6yvseED0ZSIfgI6tXZTxD8=; b=xJuKaPZVFckMbhB8WOiDDCjtjG/ZfvrLVw/xtDsj2Mh615cji8fVnboEOCUQFBCSFs 0tIBWJomWjYyJi86ACQ1p6SNiFOQ8HgXGC1xsUKtyfrMbXIpzXWTUAyZ858B6KnwQqWf HCkabcz4oAMScGfNgCpaKAswZWMq0g+HdMKQPVQYgpfrcmidKfRlatkyvzhgfOHDqse+ K9c0likMPpqKNKretZ5y0zRtff7VLxB9pg9V4RRq54UilIFYz6ausmiIVUSjKc8fOt/Z ls8+KlG1B5k/H/2gTfqfrBeby37GfhsWixUkxAV4f/bPh95lny+2bGGoA1QxnZ9Z1pDm R9xg== 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 u37si733486qtj.406.2017.11.14.12.04.16; Tue, 14 Nov 2017 12:04:16 -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 3CBD86068A; Tue, 14 Nov 2017 20:04:16 +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 DE110606A4; Tue, 14 Nov 2017 20:00: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 E6A8E6063A; Tue, 14 Nov 2017 20:00:23 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id EC2B360606 for ; Tue, 14 Nov 2017 20:00:15 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 1513721841E8 for ; Tue, 14 Nov 2017 23:00:14 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id bOXGYNxmdQ-0EpGgvgS; Tue, 14 Nov 2017 23:00:14 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0Dp4KH4s; Tue, 14 Nov 2017 23:00:13 +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: Tue, 14 Nov 2017 23:00:05 +0300 Message-Id: <1510689611-17861-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 4/10] 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ platform/linux-generic/odp_ipsec_sad.c | 73 +++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index 8eaa4f902..f1fde5e69 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -267,38 +267,6 @@ 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.auth_alg) { - case ODP_AUTH_ALG_NULL: - ipsec_sa->icv_len = 0; - break; -#if ODP_DEPRECATED_API - case ODP_AUTH_ALG_MD5_96: -#endif - case ODP_AUTH_ALG_MD5_HMAC: - ipsec_sa->icv_len = 12; - break; - case ODP_AUTH_ALG_SHA1_HMAC: - ipsec_sa->icv_len = 12; - break; -#if ODP_DEPRECATED_API - case ODP_AUTH_ALG_SHA256_128: -#endif - case ODP_AUTH_ALG_SHA256_HMAC: - ipsec_sa->icv_len = 16; - break; - case ODP_AUTH_ALG_SHA512_HMAC: - ipsec_sa->icv_len = 32; - break; -#if ODP_DEPRECATED_API - case ODP_AUTH_ALG_AES128_GCM: -#endif - 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; @@ -339,6 +307,47 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) goto error; } + switch (crypto_param.auth_alg) { + case ODP_AUTH_ALG_NULL: + ipsec_sa->icv_len = 0; + break; +#if ODP_DEPRECATED_API + case ODP_AUTH_ALG_MD5_96: +#endif + case ODP_AUTH_ALG_MD5_HMAC: + ipsec_sa->icv_len = 12; + break; + case ODP_AUTH_ALG_SHA1_HMAC: + ipsec_sa->icv_len = 12; + break; +#if ODP_DEPRECATED_API + case ODP_AUTH_ALG_SHA256_128: +#endif + case ODP_AUTH_ALG_SHA256_HMAC: + ipsec_sa->icv_len = 16; + break; + case ODP_AUTH_ALG_SHA512_HMAC: + ipsec_sa->icv_len = 32; + break; +#if ODP_DEPRECATED_API + case ODP_AUTH_ALG_AES128_GCM: +#endif + case ODP_AUTH_ALG_AES_GCM: + ipsec_sa->icv_len = 16; + break; + 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: + goto error; + } + if (1 == ipsec_sa->use_counter_iv && ODP_IPSEC_DIR_OUTBOUND == param->dir) odp_atomic_init_u64(&ipsec_sa->out.counter, 1); From patchwork Tue Nov 14 20:00:06 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: 118884 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3462834qgn; Tue, 14 Nov 2017 12:03:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMbRDI/izQGBVrRyMmmtIhMnVRkrH7t7tsmN4EO5keqJOxRZJsddVQ0+hMZ2XlOH07qnVlri X-Received: by 10.55.133.71 with SMTP id h68mr4886773qkd.17.1510689809083; Tue, 14 Nov 2017 12:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689809; cv=none; d=google.com; s=arc-20160816; b=tEVpGknYPdc6Pui0BuZ5ERNfCCoQAEQlXJ75eRd/3EiHzslo11dG52357hjPVyajUz 4Cn0rsnObnbAoAkZeZrgj+Ijm3y19UHosAA/i5hX1hpe/9FKKYEfVvMkBMGg/OWiPw/l 8be6u4p5fQUEaju4Ky2r4FCYE1Ya0I87e8GPcclX34YD9FHTCppWUO/4rnEHI5mQdFxs j86trzLjuzclO1CqqEbdAF08W5seXRsviBUhHVPAXuN/yLHj6vKLiwQrfpR039NZDMH+ Du9y3sZ/HPPNszlLLuN8XUJP76Mzg3XlvDkFiNsaDgyaUFbxNe5ckNNts7WNGEpNgFTZ X4Tg== 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=XJiqesX+r6Jxw6PfY1FhaqQYHD//imKgn1hMc6BJxAw=; b=kc+go6aI3EjfE5peP1tD4VzrC39db9J5N0ZoH47sagh5i8PMTzQC4bihdOQKrs3iEs dcYpzbtJAP1h0hVpo/GJuH4kAM6/u9lmvLr6TXBOHOmt7bjBG3mxoHIZ60Uaa+THMtgr bkpy24OpXijaHHmQ9pCwdbBt+wNVGLicMSASuS1tut2/FxXtz36GvOInI0qaR3HusjbE xpqkWERzHsVOkFV/U0ifmCH7kzRslGN63+7+sc8bp9mBdTCDV42fCptuV3QHCD7mafM0 v4jo0kS42lWc784dcK1OrS3O98U+u8x5UyilDIz8/eumQw0szlJhckK1seMvrLCisr6T 4E8w== 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 d12si7403281qtc.302.2017.11.14.12.03.28; Tue, 14 Nov 2017 12:03:29 -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 C51D46068A; Tue, 14 Nov 2017 20:03:28 +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 8CDF5606A1; Tue, 14 Nov 2017 20:00:36 +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 3392A6068B; Tue, 14 Nov 2017 20:00:23 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 418E26063A for ; Tue, 14 Nov 2017 20:00:16 +0000 (UTC) Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward100p.mail.yandex.net (Yandex) with ESMTP id A8A055103F73 for ; Tue, 14 Nov 2017 23:00:14 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id axgQ9LK9ZX-0EbmHaZa; Tue, 14 Nov 2017 23:00:14 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0EpeBYTo; Tue, 14 Nov 2017 23:00:14 +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: Tue, 14 Nov 2017 23:00:06 +0300 Message-Id: <1510689611-17861-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 5/10] validation: ipsec: check authentication key length is supported 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 check through auth capabilities, verifying that key length is supported. 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ test/validation/api/ipsec/ipsec.c | 34 +++++++++++++++++++++++++--------- test/validation/api/ipsec/ipsec.h | 11 ++++++----- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index 277d393ab..e6a22a1a4 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -122,13 +122,14 @@ static void pktio_stop(odp_pktio_t pktio) int ipsec_check(odp_bool_t ah, odp_cipher_alg_t cipher, uint32_t cipher_bits, - odp_auth_alg_t auth) + odp_auth_alg_t auth, + uint32_t auth_bits) { odp_ipsec_capability_t capa; odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; int i, num; - odp_bool_t found = false; + odp_bool_t found; if (odp_ipsec_capability(&capa) < 0) return ODP_TEST_INACTIVE; @@ -219,6 +220,7 @@ int ipsec_check(odp_bool_t ah, } /* Search for the test case */ + found = false; for (i = 0; i < num; i++) { if (cipher_capa[i].key_len == cipher_bits / 8) { found = 1; @@ -237,48 +239,62 @@ int ipsec_check(odp_bool_t ah, return ODP_TEST_INACTIVE; } + /* Search for the test case */ + found = false; + for (i = 0; i < num; i++) { + if (auth_capa[i].key_len == auth_bits / 8) { + found = 1; + break; + } + } + + if (!found) { + fprintf(stderr, "Unsupported auth key length\n"); + return ODP_TEST_INACTIVE; + } + return ODP_TEST_ACTIVE; } int ipsec_check_ah_sha256(void) { - return ipsec_check_ah(ODP_AUTH_ALG_SHA256_HMAC); + return ipsec_check_ah(ODP_AUTH_ALG_SHA256_HMAC, 256); } int ipsec_check_esp_null_sha256(void) { return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0, - ODP_AUTH_ALG_SHA256_HMAC); + ODP_AUTH_ALG_SHA256_HMAC, 256); } int ipsec_check_esp_aes_cbc_128_null(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_CBC, 128, - ODP_AUTH_ALG_NULL); + ODP_AUTH_ALG_NULL, 0); } int ipsec_check_esp_aes_cbc_128_sha256(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_CBC, 128, - ODP_AUTH_ALG_SHA256_HMAC); + ODP_AUTH_ALG_SHA256_HMAC, 256); } int ipsec_check_esp_aes_ctr_128_null(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_CTR, 128, - ODP_AUTH_ALG_NULL); + ODP_AUTH_ALG_NULL, 0); } int ipsec_check_esp_aes_gcm_128(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_GCM, 128, - ODP_AUTH_ALG_AES_GCM); + ODP_AUTH_ALG_AES_GCM, 0); } int ipsec_check_esp_aes_gcm_256(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_GCM, 256, - ODP_AUTH_ALG_AES_GCM); + ODP_AUTH_ALG_AES_GCM, 0); } void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param, diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h index d45063672..3d4e5bcd6 100644 --- a/test/validation/api/ipsec/ipsec.h +++ b/test/validation/api/ipsec/ipsec.h @@ -74,11 +74,12 @@ void ipsec_check_out_in_one(const ipsec_test_part *part, int ipsec_check(odp_bool_t ah, odp_cipher_alg_t cipher, uint32_t cipher_bits, - odp_auth_alg_t auth); -#define ipsec_check_ah(auth) \ - ipsec_check(true, ODP_CIPHER_ALG_NULL, 0, auth) -#define ipsec_check_esp(cipher, cipher_bits, auth) \ - ipsec_check(false, cipher, cipher_bits, auth) + odp_auth_alg_t auth, + uint32_t auth_bits); +#define ipsec_check_ah(auth, auth_bits) \ + ipsec_check(true, ODP_CIPHER_ALG_NULL, 0, auth, auth_bits) +#define ipsec_check_esp(cipher, cipher_bits, auth, auth_bits) \ + ipsec_check(false, cipher, cipher_bits, auth, auth_bits) int ipsec_check_ah_sha256(void); int ipsec_check_esp_null_sha256(void); int ipsec_check_esp_aes_cbc_128_null(void); From patchwork Tue Nov 14 20:00:07 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: 118886 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3464862qgn; Tue, 14 Nov 2017 12:05:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMYF+3mg4Hw5QMsrfnibSmZOrmbSKvhNIwedJVMmNOdP8YoRqXwUp2j+fd8rUCw7CunxiB23 X-Received: by 10.237.62.169 with SMTP id n38mr22955540qtf.42.1510689904533; Tue, 14 Nov 2017 12:05:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689904; cv=none; d=google.com; s=arc-20160816; b=KIZT+DUtIOuHbSLW2F6PpOX+ciFf4zD6BDoYgeI2V+xHIQSdeKF8pxeVyo9C4+Fa9N ov0AdoGs9HlfPOBMzDEvWWirHUdKHKg4xv7rY4/5WM4LUGdUVCxv2ul3+XfQyRDNA6n/ se+OCUmkG9TErNxsy82hkoCqd6i+HPaSgxRRr76VeaPFgYeqOh9WSXb9er4mJ7eqH1ps kUq1sdtD67dlNfm8fLRrFhCyVeNShKmBLzX734Z8nBEuNnsh/3bTVeYQ5O2Gb6uGQnEB xfnsYC/Zpy6P7QB5rM9DGOfVEwKgqjKDrW8KSfzxxWqdh6Vw5SpRB8+7IWKLn1V1PLgi PcCA== 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=Wrzw36WSH4HDWLVHpTQRxIP2zFMuoJOdi2zWUvQyzT0=; b=ll/Z5f4+9DJRCoio/n7ueaZA8IRbU+ejNafxlqxVtcfQZh0nEJgU78gy0V9wGJ4+JG HY23Fv30nqf52atkXhqR/Q/1iPPyU0yp+/UnlTQPc2zQ8tJRH9MxBoQXBPsIVynVP5vO NYvnMRoy/ge4cow7b/Px9e5Oh7Ys9wd9Rv5zjcB1ixWvkgXI486oTA0jH199fXuqmGE5 w7uruOkDxVoh9xiEmyFB9nuGn7khaeD7Qsb8Q05yaF9GJ6VUzwirE3ozu3nfk15cP8rv 8fQA/h/Z06YJ1bsulYWqETFRhWWxAf2HGzNxmqFuCsSG5CnOENTPCBg2LInW3lFNmjcQ N2pw== 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 d54si791826qtk.239.2017.11.14.12.05.04; Tue, 14 Nov 2017 12:05:04 -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 37C0760667; Tue, 14 Nov 2017 20:05:04 +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 2EF4C60730; Tue, 14 Nov 2017 20:00:49 +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 2559760606; Tue, 14 Nov 2017 20:00:24 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id E3F9160641 for ; Tue, 14 Nov 2017 20:00:16 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 289E45A045EC for ; Tue, 14 Nov 2017 23:00:15 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id yKYXtoE6Gj-0F8G7L5H; Tue, 14 Nov 2017 23:00:15 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0EpGXqEP; Tue, 14 Nov 2017 23:00:14 +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: Tue, 14 Nov 2017 23:00:07 +0300 Message-Id: <1510689611-17861-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 6/10] validation: ipsec: support AES-GMAC-ESP validation 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 AES-GMAC-ESP testcase based on draft-mcgrew-gcm-test-01. 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ test/validation/api/ipsec/ipsec.c | 10 +++ test/validation/api/ipsec/ipsec.h | 1 + test/validation/api/ipsec/ipsec_test_in.c | 65 ++++++++++++++++++ test/validation/api/ipsec/ipsec_test_out.c | 32 +++++++++ test/validation/api/ipsec/test_vectors.h | 106 +++++++++++++++++++++++++++++ 5 files changed, 214 insertions(+) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index e6a22a1a4..5a267200c 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -208,6 +208,10 @@ int ipsec_check(odp_bool_t ah, if (!capa.auths.bit.aes_gcm) return ODP_TEST_INACTIVE; break; + case ODP_AUTH_ALG_AES_GMAC: + if (!capa.auths.bit.aes_gmac) + return ODP_TEST_INACTIVE; + break; default: fprintf(stderr, "Unsupported authentication algorithm\n"); return ODP_TEST_INACTIVE; @@ -297,6 +301,12 @@ int ipsec_check_esp_aes_gcm_256(void) ODP_AUTH_ALG_AES_GCM, 0); } +int ipsec_check_esp_null_aes_gmac_128(void) +{ + return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0, + ODP_AUTH_ALG_AES_GMAC, 128); +} + void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param, odp_bool_t in, odp_bool_t ah, diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h index 3d4e5bcd6..16608fe00 100644 --- a/test/validation/api/ipsec/ipsec.h +++ b/test/validation/api/ipsec/ipsec.h @@ -87,5 +87,6 @@ int ipsec_check_esp_aes_cbc_128_sha256(void); int ipsec_check_esp_aes_ctr_128_null(void); int ipsec_check_esp_aes_gcm_128(void); int ipsec_check_esp_aes_gcm_256(void); +int ipsec_check_esp_null_aes_gmac_128(void); #endif diff --git a/test/validation/api/ipsec/ipsec_test_in.c b/test/validation/api/ipsec/ipsec_test_in.c index 8c883262a..0f7148d72 100644 --- a/test/validation/api/ipsec/ipsec_test_in.c +++ b/test/validation/api/ipsec/ipsec_test_in.c @@ -978,6 +978,67 @@ static void test_in_mcgrew_gcm_12_esp(void) ipsec_sa_destroy(sa); } +static void test_in_mcgrew_gcm_15_esp(void) +{ + odp_ipsec_tunnel_param_t tunnel = {}; + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + + ipsec_sa_param_fill(¶m, + true, false, 0x00004321, &tunnel, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_AES_GMAC, &key_mcgrew_gcm_15, + &key_mcgrew_gcm_salt_15); + + sa = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); + + ipsec_test_part test = { + .pkt_in = &pkt_mcgrew_gcm_test_15_esp, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .pkt_out = &pkt_mcgrew_gcm_test_15}, + }, + }; + + ipsec_check_in_one(&test, sa); + + ipsec_sa_destroy(sa); +} + +static void test_in_esp_null_aes_gmac_128(void) +{ + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + + ipsec_sa_param_fill(¶m, + true, false, 123, NULL, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_AES_GMAC, &key_a5_128, + &key_mcgrew_gcm_salt_2); + + sa = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); + + ipsec_test_part test = { + .pkt_in = &pkt_icmp_0_esp_null_aes_gmac_128_1, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .pkt_out = &pkt_icmp_0 }, + }, + }; + + ipsec_check_in_one(&test, sa); + + ipsec_sa_destroy(sa); +} + static void ipsec_test_capability(void) { odp_ipsec_capability_t capa; @@ -1005,6 +1066,8 @@ odp_testinfo_t ipsec_in_suite[] = { ipsec_check_esp_aes_gcm_128), ODP_TEST_INFO_CONDITIONAL(test_in_mcgrew_gcm_12_esp, ipsec_check_esp_aes_gcm_128), + ODP_TEST_INFO_CONDITIONAL(test_in_mcgrew_gcm_15_esp, + ipsec_check_esp_null_aes_gmac_128), ODP_TEST_INFO_CONDITIONAL(test_in_ah_sha256, ipsec_check_ah_sha256), ODP_TEST_INFO_CONDITIONAL(test_in_ah_sha256_tun, @@ -1047,5 +1110,7 @@ odp_testinfo_t ipsec_in_suite[] = { ipsec_check_ah_sha256), ODP_TEST_INFO_CONDITIONAL(test_in_esp_null_sha256_bad1, ipsec_check_esp_null_sha256), + ODP_TEST_INFO_CONDITIONAL(test_in_esp_null_aes_gmac_128, + ipsec_check_esp_null_aes_gmac_128), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c index b543271bf..a498b663b 100644 --- a/test/validation/api/ipsec/ipsec_test_out.c +++ b/test/validation/api/ipsec/ipsec_test_out.c @@ -361,6 +361,36 @@ static void test_out_esp_aes_gcm128(void) ipsec_sa_destroy(sa); } +static void test_out_esp_null_aes_gmac_128(void) +{ + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + + ipsec_sa_param_fill(¶m, + false, false, 123, NULL, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_AES_GMAC, &key_a5_128, + &key_mcgrew_gcm_salt_2); + + sa = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); + + ipsec_test_part test = { + .pkt_in = &pkt_icmp_0, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .pkt_out = &pkt_icmp_0_esp_null_aes_gmac_128_1 }, + }, + }; + + ipsec_check_out_one(&test, sa); + + ipsec_sa_destroy(sa); +} + static void ipsec_test_capability(void) { odp_ipsec_capability_t capa; @@ -388,5 +418,7 @@ odp_testinfo_t ipsec_out_suite[] = { ipsec_check_esp_aes_ctr_128_null), ODP_TEST_INFO_CONDITIONAL(test_out_esp_aes_gcm128, ipsec_check_esp_aes_gcm_128), + ODP_TEST_INFO_CONDITIONAL(test_out_esp_null_aes_gmac_128, + ipsec_check_esp_null_aes_gmac_128), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/ipsec/test_vectors.h b/test/validation/api/ipsec/test_vectors.h index fbf7d366c..09823e632 100644 --- a/test/validation/api/ipsec/test_vectors.h +++ b/test/validation/api/ipsec/test_vectors.h @@ -45,6 +45,9 @@ KEY(key_mcgrew_gcm_salt_4, 0x00, 0x00, 0x00, 0x00); KEY(key_mcgrew_gcm_12, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47); KEY(key_mcgrew_gcm_salt_12, 0xd9, 0x66, 0x42, 0x67); +KEY(key_mcgrew_gcm_15, 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, + 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34); +KEY(key_mcgrew_gcm_salt_15, 0x22, 0x43, 0x3c, 0x64); static const ODP_UNUSED ipsec_test_packet pkt_icmp_0 = { .len = 142, @@ -622,6 +625,52 @@ static const ODP_UNUSED ipsec_test_packet pkt_icmp_0_esp_aes_ctr_null_1 = { }, }; +static const ODP_UNUSED ipsec_test_packet pkt_icmp_0_esp_null_aes_gmac_128_1 = { + .len = 178, + .l2_offset = 0, + .l3_offset = 14, + .l4_offset = 34, + .data = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IP */ + 0x45, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x32, 0xab, 0xd2, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* ESP */ + 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x01, + + /* IV */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, + + /* ESP TRL */ + 0x01, 0x02, 0x02, 0x01, + + /* ICV */ + 0x16, 0x0e, 0xa6, 0x8f, 0xb3, 0xa6, 0x8c, 0x74, + 0x19, 0x59, 0x72, 0x80, 0x91, 0x98, 0x77, 0x5e, + }, +}; + static const ODP_UNUSED ipsec_test_packet pkt_rfc3602_5 = { .len = 98, .l2_offset = 0, @@ -1088,4 +1137,61 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_12_esp = { }, }; +static const ipsec_test_packet pkt_mcgrew_gcm_test_15 = { + .len = 62, + .l2_offset = 0, + .l3_offset = 14, + .l4_offset = 34, + .data = { + /* ETH - not a part of RFC, added for simplicity */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IP */ + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, + + /* ICMP */ + 0x08, 0x00, 0xc6, 0xcd, 0x02, 0x00, 0x07, 0x00, + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, + 0x71, 0x72, 0x73, 0x74, + }, +}; + +static const ipsec_test_packet pkt_mcgrew_gcm_test_15_esp = { + .len = 118, + .l2_offset = 0, + .l3_offset = 14, + .l4_offset = 34, + .data = { + /* ETH - not a part of RFC, added for simplicity */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IP - not a part of RFC, added for simplicity */ + 0x45, 0x00, 0x00, 0x68, 0x69, 0x8f, 0x00, 0x00, + 0x80, 0x32, 0x4d, 0xb2, 0xc0, 0xa8, 0x01, 0x02, + 0xc0, 0xa8, 0x01, 0x01, + + /* ESP */ + 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, + + /* IV */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* IP */ + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, + 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x01, 0x02, 0x02, 0x01, 0xf2, 0xa9, 0xa8, 0x36, + 0xe1, 0x55, 0x10, 0x6a, 0xa8, 0xdc, 0xd6, 0x18, + 0xe4, 0x09, 0x9a, 0xaa, + }, +}; + #endif From patchwork Tue Nov 14 20:00:08 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: 118887 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3464949qgn; Tue, 14 Nov 2017 12:05:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMaYh8cGXti0rCx2N+UPIqxxjvHJ6q76Ow3mk3ajmO3SXfunNQyQ+eB0XsRIdh4v7hVTUuBg X-Received: by 10.237.34.45 with SMTP id n42mr22288003qtc.80.1510689908599; Tue, 14 Nov 2017 12:05:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689908; cv=none; d=google.com; s=arc-20160816; b=XnEPL4EiDivsT9VflEmUcVIlevOo/SkHVhVbIBioQOULFCmmd2dDyCoWgsSmaXWN06 ifgo1HYKZi+YC8RzL/QUHuz+LLQ8APUaaFg7G0cRmhycywMUfX23yqKQ/0wQoQY1gStw s1iylVkgPTIU7l+v2LTiHbxQ6Lt95zj7OAYlloYpAT3Q4VSGYdnBaYhk7qsc00oiOK7i 3GIBAbQSHUQ8faNREXN2kIfuoU3/FU8hruVmtwbaBdyKjHMAW8p8aVHk7cY84hpWgFb+ mdHqGTbVgTBn9SNH0Fc6w7OoimSIisjQsRk/RrJ0X7kcEnZW11WUQ10o2B9I43/mOTzr clew== 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=xZVd0VpAdCKlrXlynCKRXFyEvAcAaMpjjxon7JSHkvc=; b=Hp0/nQQuVeOKvnfypBv0TqG30jQqMT/vMH6rUrfuT+UeeI28AO0DSW84plGNc8ziL7 RCwuUsuKgwA8e7pl+fJSaics81aXLcWa8GlH/tUWC6XofVKwDDKQnKM5JhGAdAPwbOdg XvV7twqLeUx+rAFIC2B/IJphbKmnaIEL4YeA5TtSQr1cMN1NeRRxUrsGIYShYwcvsdU/ AqeEo/45vueQv678uXMiMBFArS3jt4H30CtQlhKvhJFYsgYrJushTGFFxY7Y93VXmMmV 7V6vdk+CrJwNgukoJuEJ6nwT1XPmXryYSx08O9hlpN4wyaTkxgqBteDhzYy6EhWPZoaF BTGA== 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 o123si892452qkc.114.2017.11.14.12.05.08; Tue, 14 Nov 2017 12:05:08 -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 4A2A060676; Tue, 14 Nov 2017 20:05:08 +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 A26A66074C; Tue, 14 Nov 2017 20:01:03 +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 DC8B760690; Tue, 14 Nov 2017 20:00:27 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 41DE260646 for ; Tue, 14 Nov 2017 20:00:17 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 8AE252D82EEF for ; Tue, 14 Nov 2017 23:00:15 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id c8ROSWedwo-0FKWjmlq; Tue, 14 Nov 2017 23:00:15 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0Fp4fHXC; Tue, 14 Nov 2017 23:00:15 +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: Tue, 14 Nov 2017 23:00:08 +0300 Message-Id: <1510689611-17861-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 7/10] linux-gen: ipsec: implement AES-GMAC-AH 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 authentication support for AH. 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ platform/linux-generic/odp_ipsec.c | 46 +++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 9533ca422..d54ec3286 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -400,6 +400,16 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, } } + memcpy(iv, ipsec_sa->salt, ipsec_sa->salt_length); + if (odp_packet_copy_to_mem(pkt, + ipsec_offset + _ODP_AHHDR_LEN, + ipsec_sa->esp_iv_len, + iv + ipsec_sa->salt_length) < 0) { + status->error.alg = 1; + goto err; + } + param.override_iv_ptr = iv; + hdr_len = (ah.ah_len + 2) * 4; trl_len = 0; @@ -425,7 +435,8 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, param.auth_range.offset = ip_offset; param.auth_range.length = odp_be_to_cpu_16(ip->tot_len); - param.hash_result_offset = ipsec_offset + _ODP_AHHDR_LEN; + param.hash_result_offset = ipsec_offset + _ODP_AHHDR_LEN + + ipsec_sa->esp_iv_len; stats_length = param.auth_range.length; } else { @@ -826,7 +837,8 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, } else if (ipsec_sa->proto == ODP_IPSEC_AH) { _odp_ahhdr_t ah; - hdr_len = _ODP_AHHDR_LEN + ipsec_sa->icv_len; + hdr_len = _ODP_AHHDR_LEN + ipsec_sa->esp_iv_len + + ipsec_sa->icv_len; trl_len = 0; /* Save IPv4 stuff */ @@ -853,7 +865,7 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, memset(&ah, 0, sizeof(ah)); ah.spi = odp_cpu_to_be_32(ipsec_sa->spi); - ah.ah_len = 1 + (ipsec_sa->icv_len / 4); + ah.ah_len = 1 + (ipsec_sa->esp_iv_len + ipsec_sa->icv_len) / 4; ah.seq_no = odp_cpu_to_be_32(ipsec_seq_no(ipsec_sa)); ah.next_header = ip->proto; ip->proto = _ODP_IPPROTO_AH; @@ -864,11 +876,34 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, param.aad.ptr = (uint8_t *)&aad; param.aad.length = sizeof(aad); + /* For GMAC */ + if (ipsec_sa->use_counter_iv) { + uint64_t ctr; + + ODP_ASSERT(sizeof(ctr) == ipsec_sa->esp_iv_len); + + ctr = odp_atomic_fetch_add_u64(&ipsec_sa->out.counter, + 1); + /* Check for overrun */ + if (ctr == 0) + goto err; + + memcpy(iv, ipsec_sa->salt, ipsec_sa->salt_length); + memcpy(iv + ipsec_sa->salt_length, &ctr, + ipsec_sa->esp_iv_len); + param.override_iv_ptr = iv; + } + odp_packet_copy_from_mem(pkt, ipsec_offset, _ODP_AHHDR_LEN, &ah); + odp_packet_copy_from_mem(pkt, + ipsec_offset + _ODP_AHHDR_LEN, + ipsec_sa->esp_iv_len, + iv + ipsec_sa->salt_length); _odp_packet_set_data(pkt, - ipsec_offset + _ODP_AHHDR_LEN, + ipsec_offset + _ODP_AHHDR_LEN + + ipsec_sa->esp_iv_len, 0, ipsec_sa->icv_len); ip->chksum = 0; @@ -878,7 +913,8 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, param.auth_range.offset = ip_offset; param.auth_range.length = odp_be_to_cpu_16(ip->tot_len); - param.hash_result_offset = ipsec_offset + _ODP_AHHDR_LEN; + param.hash_result_offset = ipsec_offset + _ODP_AHHDR_LEN + + ipsec_sa->esp_iv_len; stats_length = param.auth_range.length; } else { From patchwork Tue Nov 14 20:00:09 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: 118888 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3466758qgn; Tue, 14 Nov 2017 12:06:36 -0800 (PST) X-Google-Smtp-Source: AGs4zMaEGYuRTZA5ShimlTSIl6gR9XG30tnZR/Wkp2ZZ/Kn5RENCt0Z0LzkKbRCYR1F/qqNnjurT X-Received: by 10.200.46.241 with SMTP id i46mr16892620qta.248.1510689996601; Tue, 14 Nov 2017 12:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689996; cv=none; d=google.com; s=arc-20160816; b=bEjyhg56IqS6Xxp5zj2C7rrocwYQ2r1nv5vGpWKayoQhOQbiqtb1LE5GDwnHwm6IfC 46WpCFQYWUziqw22hSfy7jAP1ryVoEWXsHQzc44R6FLSoBXtT0dumlPZtNagI+IQlIlQ yzsrTznmq5nf5GPRSZ1QCVPz+pj/ZZ3nvmXfkpmqDhmJAeocwDW0KO87uMfzSnsPat5Z kBxlddMdQBHbCS/zamhZDkkNPUUe3tRccx+UDmQ7dw0WMuBUpz75zaXmt1/DKp4ZhabV pEDXvrOdbFQzl66xAOr5VlTxNLI8KbbXouoEqn8eScZOPS0HVb4gx6SE1oTHyFV7BAba bj6Q== 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=UO3JOhz/IQ70/W2YQycHDffGV4tMAMT1fZKVTLeJ5aU=; b=xrzEjRItW3bZZBxqStpJUHGBG2620jWXJ+vzH8rEYLxyDWoY9cv+W0vTH48OiCZoWU bOpH2WO0Mc42ZeagAdj7lvmVMIl0EFa4F0i7HWp6TQO7iisTS2AtyDeAl47TK6usZXiS RxLLSWnfOQMrVI13ma7k+o0Exkuf632jofABG45Wzp+eJinQaFdR8aUCxX5TaRP5bQEm hcudd0krh55U9ZiKfWFks5NnhGz7l08/fkHyxo/YoHcTSeuxHu999S4023oyLNIIPzps G5USfUH2C7JTrxEh6RyAahkWPveGbeLp1nrAQBL9pwF/c9rbHAgho1bWX4rmp/+2nXna uH1A== 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 w36si10512034qta.214.2017.11.14.12.06.36; Tue, 14 Nov 2017 12:06:36 -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 446716072F; Tue, 14 Nov 2017 20:06:36 +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 E19576071A; Tue, 14 Nov 2017 20:01:06 +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 12FB36069A; Tue, 14 Nov 2017 20:00:30 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id 8C42660654 for ; Tue, 14 Nov 2017 20:00:17 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 40CC36A84123 for ; Tue, 14 Nov 2017 23:00:16 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id dRyYWSlJqM-0GZarsci; Tue, 14 Nov 2017 23:00:16 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0FpW6qDb; Tue, 14 Nov 2017 23:00:15 +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: Tue, 14 Nov 2017 23:00:09 +0300 Message-Id: <1510689611-17861-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 8/10] validation: api: add AES-GMAC-AH testcases 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 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ test/validation/api/ipsec/ipsec.c | 6 +++++ test/validation/api/ipsec/ipsec.h | 1 + test/validation/api/ipsec/ipsec_test_in.c | 32 ++++++++++++++++++++++++ test/validation/api/ipsec/ipsec_test_out.c | 32 ++++++++++++++++++++++++ test/validation/api/ipsec/test_vectors.h | 40 ++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index 5a267200c..7b39c2c5a 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -301,6 +301,12 @@ int ipsec_check_esp_aes_gcm_256(void) ODP_AUTH_ALG_AES_GCM, 0); } +int ipsec_check_ah_aes_gmac_128(void) +{ + return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0, + ODP_AUTH_ALG_AES_GMAC, 128); +} + int ipsec_check_esp_null_aes_gmac_128(void) { return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0, diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h index 16608fe00..9a24dd38c 100644 --- a/test/validation/api/ipsec/ipsec.h +++ b/test/validation/api/ipsec/ipsec.h @@ -87,6 +87,7 @@ int ipsec_check_esp_aes_cbc_128_sha256(void); int ipsec_check_esp_aes_ctr_128_null(void); int ipsec_check_esp_aes_gcm_128(void); int ipsec_check_esp_aes_gcm_256(void); +int ipsec_check_ah_aes_gmac_128(void); int ipsec_check_esp_null_aes_gmac_128(void); #endif diff --git a/test/validation/api/ipsec/ipsec_test_in.c b/test/validation/api/ipsec/ipsec_test_in.c index 0f7148d72..294e4a5d6 100644 --- a/test/validation/api/ipsec/ipsec_test_in.c +++ b/test/validation/api/ipsec/ipsec_test_in.c @@ -1009,6 +1009,36 @@ static void test_in_mcgrew_gcm_15_esp(void) ipsec_sa_destroy(sa); } +static void test_in_ah_aes_gmac_128(void) +{ + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + + ipsec_sa_param_fill(¶m, + true, true, 123, NULL, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_AES_GMAC, &key_a5_128, + &key_mcgrew_gcm_salt_2); + + sa = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); + + ipsec_test_part test = { + .pkt_in = &pkt_icmp_0_ah_aes_gmac_128_1, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .pkt_out = &pkt_icmp_0 }, + }, + }; + + ipsec_check_in_one(&test, sa); + + ipsec_sa_destroy(sa); +} + static void test_in_esp_null_aes_gmac_128(void) { odp_ipsec_sa_param_t param; @@ -1110,6 +1140,8 @@ odp_testinfo_t ipsec_in_suite[] = { ipsec_check_ah_sha256), ODP_TEST_INFO_CONDITIONAL(test_in_esp_null_sha256_bad1, ipsec_check_esp_null_sha256), + ODP_TEST_INFO_CONDITIONAL(test_in_ah_aes_gmac_128, + ipsec_check_ah_aes_gmac_128), ODP_TEST_INFO_CONDITIONAL(test_in_esp_null_aes_gmac_128, ipsec_check_esp_null_aes_gmac_128), ODP_TEST_INFO_NULL, diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c index a498b663b..7d4ea4a73 100644 --- a/test/validation/api/ipsec/ipsec_test_out.c +++ b/test/validation/api/ipsec/ipsec_test_out.c @@ -361,6 +361,36 @@ static void test_out_esp_aes_gcm128(void) ipsec_sa_destroy(sa); } +static void test_out_ah_aes_gmac_128(void) +{ + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + + ipsec_sa_param_fill(¶m, + false, true, 123, NULL, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_AES_GMAC, &key_a5_128, + &key_mcgrew_gcm_salt_2); + + sa = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); + + ipsec_test_part test = { + .pkt_in = &pkt_icmp_0, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .pkt_out = &pkt_icmp_0_ah_aes_gmac_128_1 }, + }, + }; + + ipsec_check_out_one(&test, sa); + + ipsec_sa_destroy(sa); +} + static void test_out_esp_null_aes_gmac_128(void) { odp_ipsec_sa_param_t param; @@ -418,6 +448,8 @@ odp_testinfo_t ipsec_out_suite[] = { ipsec_check_esp_aes_ctr_128_null), ODP_TEST_INFO_CONDITIONAL(test_out_esp_aes_gcm128, ipsec_check_esp_aes_gcm_128), + ODP_TEST_INFO_CONDITIONAL(test_out_ah_aes_gmac_128, + ipsec_check_ah_aes_gmac_128), ODP_TEST_INFO_CONDITIONAL(test_out_esp_null_aes_gmac_128, ipsec_check_esp_null_aes_gmac_128), ODP_TEST_INFO_NULL, diff --git a/test/validation/api/ipsec/test_vectors.h b/test/validation/api/ipsec/test_vectors.h index 09823e632..7fb7d5a84 100644 --- a/test/validation/api/ipsec/test_vectors.h +++ b/test/validation/api/ipsec/test_vectors.h @@ -625,6 +625,46 @@ static const ODP_UNUSED ipsec_test_packet pkt_icmp_0_esp_aes_ctr_null_1 = { }, }; +static const ODP_UNUSED ipsec_test_packet pkt_icmp_0_ah_aes_gmac_128_1 = { + .len = 178, + .l2_offset = 0, + .l3_offset = 14, + .l4_offset = 34, + .data = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IP */ + 0x45, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x33, 0xab, 0xd1, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* AH */ + 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, + 0x00, 0x00, 0x00, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xd6, 0x0e, 0xcc, 0x22, 0x31, 0x79, 0x59, 0x72, + 0x68, 0xc9, 0x58, 0xfb, 0x8b, 0xb0, 0xbb, 0xd5, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, + }, +}; + static const ODP_UNUSED ipsec_test_packet pkt_icmp_0_esp_null_aes_gmac_128_1 = { .len = 178, .l2_offset = 0, From patchwork Tue Nov 14 20:00:10 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: 118889 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3467475qgn; Tue, 14 Nov 2017 12:07:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMbSAH/5KCLG/tDcZ3PKUXgE0K6vDWDN67Xf2vpuLLG+a86nvrXAKUfYnTtLkkdxaj/TFFds X-Received: by 10.107.134.227 with SMTP id q96mr11411469ioi.197.1510690033874; Tue, 14 Nov 2017 12:07:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510690033; cv=none; d=google.com; s=arc-20160816; b=0uJ3a8eV/F99HYy38oiCj34Oj6Ik/rqPmBxRytlQ6PEgLd+zd9zGDqsSZVvF/C/M28 +CCGZG4UrAnPcXbHWgDgkdiY4TC9AbBhSFcP0I8TCuTeNn8UgNPFbiUffGH1cuTxrA0A fuDek4AOiZ2x1u9DtbAHQoyxTk0ij3lf4YKyDPoG300CypW67jpDykCiWbQswrYOdQLi xIkUcQfdvXyPGsL4kHgOPYJ5XjlUuCx04OZYhIKnmTQ0tgbSMiYf5qGYtqu8dDE1pJL9 vmTddwQpECzGRvxZZSbf6ojBfhUgt3J/HRfI+TCcz02WR45iVyqe98UWP3SafP7RZEwL Tb6A== 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=48KxYprJFIyNCMmtUpHAFQudYJFv5TCRrj7qmsKmRK8=; b=U3JyG8HqC+HziQ3mNycPjNMegFZQbaBBBOfDfSBegmCoM3M131XPaAnyO9Yuj1rymL Dj2OHvmgcFGoM84KZL4VPf6IdcqhYAsRE0KUIRMQZhNcBAzzeGTwxU3ENOKm9mhGx0PC CRvJRi2t05zzkHAoTVcSI7U3H2m6PU01W3ITG4iLoXR6WG5oJBhYU9yT+k979KuOQg5/ YEljj1dkRGa8YnTxQb91omhcdc+iLcbbpaIrDr0lotiZbpxg4cBa9YGGagkN+sObnk8h eafGbE3C6AV729+AHbiYQvYjfnbAAiGQUeS+c+PwqiigKivckYfsviKKQ29OTV94kSJu AaOQ== 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 a139si8531922ita.115.2017.11.14.12.07.13; Tue, 14 Nov 2017 12:07:13 -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 308766072F; Tue, 14 Nov 2017 20:07:13 +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 2DD576074A; Tue, 14 Nov 2017 20:01:10 +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 6F9C8606A7; Tue, 14 Nov 2017 20:00:36 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 1BCFB60655 for ; Tue, 14 Nov 2017 20:00:18 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward103o.mail.yandex.net (Yandex) with ESMTP id C5CC6588320E for ; Tue, 14 Nov 2017 23:00:16 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id qpv0h9zqxJ-0GHeInvs; Tue, 14 Nov 2017 23:00:16 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0Gp4NMsl; Tue, 14 Nov 2017 23:00:16 +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: Tue, 14 Nov 2017 23:00:10 +0300 Message-Id: <1510689611-17861-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 9/10] linux-gen: crypto: drop duplicate authentication field 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 session->auth.bytes duplicates session->p.auth_digest_len, so let's drop first field. 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ platform/linux-generic/include/odp_crypto_internal.h | 1 - platform/linux-generic/odp_crypto.c | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index 21174daa4..32178d9de 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -50,7 +50,6 @@ struct odp_crypto_generic_session { struct { uint8_t key[EVP_MAX_KEY_LENGTH]; uint32_t key_length; - uint32_t bytes; union { const EVP_MD *evp_md; const EVP_CIPHER *evp_cipher; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 1cc2d7018..6d0ad709a 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -207,7 +207,7 @@ odp_crypto_alg_err_t auth_gen(odp_packet_t pkt, /* Copy to the output location */ odp_packet_copy_from_mem(pkt, param->hash_result_offset, - session->auth.bytes, + session->p.auth_digest_len, hash); return ODP_CRYPTO_ALG_ERR_NONE; @@ -218,7 +218,7 @@ odp_crypto_alg_err_t auth_check(odp_packet_t pkt, const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session) { - uint32_t bytes = session->auth.bytes; + uint32_t bytes = session->p.auth_digest_len; uint8_t hash_in[EVP_MAX_MD_SIZE]; uint8_t hash_out[EVP_MAX_MD_SIZE]; @@ -703,8 +703,7 @@ static int process_auth_param(odp_crypto_generic_session_t *session, session->auth.evp_md = evp_md; /* Number of valid bytes */ - session->auth.bytes = session->p.auth_digest_len; - if (session->auth.bytes < (unsigned)EVP_MD_size(evp_md) / 2) + if (session->p.auth_digest_len < (unsigned)EVP_MD_size(evp_md) / 2) return -1; /* Convert keys */ From patchwork Tue Nov 14 20:00:11 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: 118890 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3468485qgn; Tue, 14 Nov 2017 12:08:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMYYSXgiIedPYAJHy2aj+Thb9l8NbjudPe2JCRegTrhaqHh4ou7mV/q4Jn+gIzSL+vT+xu/1 X-Received: by 10.237.54.40 with SMTP id e37mr22808025qtb.41.1510690088274; Tue, 14 Nov 2017 12:08:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510690088; cv=none; d=google.com; s=arc-20160816; b=AaQYNmSSY+0CMNmDgulZM9xTZdzGGogJ3oHFpmjhrqS3UAzsA2/Fu/6ShIYYEiPYnD DkigALmlW38d3+S0/W1DztFvfTvU3xw4UvzDajbVzk37mwSsgutzA89UfhKsMkyQUA8P XA/BjjW2K27uNwZ6AI2HUyGbZlhQmjFiwxp23pYPhNHY3ATJovykqIuID1XMnv32R/g9 QiCIcuxBiiW+8tHI6wvaJrb6n9YFdubzYbe7+TI8+m00H7Kyujjv3wyAqpuQswGmqV8J WC4bqi/cKrjfN99J++7fc5WDD+rSChjYGLEyLU81rwXFvlJQgToRpGQGpv9xARahEyg7 ihxQ== 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=Ec2rV+a08DU4EYAHWYE1H/hNcElLbL91RcavzsLuk80=; b=cqExGj8jS66mPaj1LwWuBqih8HDvhH6n1Q79Dyb7LxI1gAxVxZKuRUpp9BKkQrxQd0 of+GU14OyyR5SSTW0uuBQBjNzwtGRVcME81Bz/NnaVKRCQKaWOMCE9KJM3nCZlqSxkmB Ii0zM5Ry2X3Vu0Wy4ZPXh+hTFIOZ5QD80XWFfogvbxKQNAtST/QwDLNmKeKZ9y5Vlz0f BEePZopN7MMzj+aKclcutB5LN+34xXoCBFY/WSIDzr/n3vt3oNjH5/mZPl4rsCPTmTPP R3WFFOFtiYZGfOPYCsXs9j0JKljAHzIQgSSRF0c2slLGNnXXa/D9HAOFPhD/FLCYkGEi W6EA== 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 75si1632819qkb.443.2017.11.14.12.08.08; Tue, 14 Nov 2017 12:08:08 -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 E197D606B3; Tue, 14 Nov 2017 20:08: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,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 7298860841; Tue, 14 Nov 2017 20:01:21 +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 78642607C5; Tue, 14 Nov 2017 20:00:58 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 7A9FC60639 for ; Tue, 14 Nov 2017 20:00:19 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 308B47822CD for ; Tue, 14 Nov 2017 23:00:17 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Ncse7CJkQA-0H2iVrFN; Tue, 14 Nov 2017 23:00:17 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0Gp0URaj; Tue, 14 Nov 2017 23:00:16 +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: Tue, 14 Nov 2017 23:00:11 +0300 Message-Id: <1510689611-17861-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 10/10] linux-gen: drop unnecessary odp_crypto_internal include 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 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ platform/linux-generic/include/odp_packet_internal.h | 1 - platform/linux-generic/odp_ipsec.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index e62854b1e..1ebe46901 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -25,7 +25,6 @@ extern "C" { #include #include #include -#include #include #include #include diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index d54ec3286..0ebc65341 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -264,7 +264,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, unsigned stats_length; uint16_t ipsec_offset; /**< Offset of IPsec header from buffer start */ - uint8_t iv[MAX_IV_LEN]; /**< ESP IV storage */ + uint8_t iv[IPSEC_MAX_IV_LEN]; /**< ESP IV storage */ ipsec_aad_t aad; /**< AAD, note ESN is not fully supported */ unsigned hdr_len; /**< Length of IPsec headers */ unsigned trl_len; /**< Length of IPsec trailers */ @@ -628,7 +628,7 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, int rc; uint16_t ipsec_offset; /**< Offset of IPsec header from buffer start */ - uint8_t iv[MAX_IV_LEN]; /**< ESP IV storage */ + uint8_t iv[IPSEC_MAX_IV_LEN]; /**< ESP IV storage */ ipsec_aad_t aad; /**< AAD, note ESN is not fully supported */ unsigned hdr_len; /**< Length of IPsec headers */ unsigned trl_len; /**< Length of IPsec trailers */