From patchwork Wed Nov 8 18:00:12 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: 118306 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5604539qgn; Wed, 8 Nov 2017 10:08:20 -0800 (PST) X-Google-Smtp-Source: ABhQp+T1sFaX7IzJwwV75xDQc1HWSOZ7jZ9WDjMrsaSOEoMpeat6BJn8V1EA0SyKixjATvKpEKzI X-Received: by 10.200.47.77 with SMTP id k13mr2253607qta.298.1510164499944; Wed, 08 Nov 2017 10:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510164499; cv=none; d=google.com; s=arc-20160816; b=WLBXQiEeiHQvv5O9ZgJKZm5nmOMx/D0kaICel7drWYUvIxJOsv0iYwbwIT0nBbdy1t BzqYFCj4TaACLa2B7G5tD5dt7H5HUsxlbnOm26vwxvAPnW/twWi8D4tmOPJ9jl9dB0/m uK4kD2rGxiG/ypbf47UQ3Gn3A4DuLJWtXhFBDRcan7Yq1wUXUCtwkCPYhXPUYx0aG8qd +T+AGdGodRFB/nw/Z0J80ojhSNtuWlNQNTvzcdVAUlnGOacOGSLc5jwSHHSQot5cn3pF h27kIeXwd61W+eoK21n+p/KdhKld0dKqDPzOAJhj8zu7wCJOB3+jtJAUNl/PQBLT/4VO lKGQ== 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=wGVxiktV2RBss17o5DHxyTv4zLG/WPn23DLVxdm1f9Q=; b=dA/VkXI3e2ZyPrKHxiG9mvMu25wURTbmMbr7FbabLGgUoz8KnAWdAZWslH5lFxDMKe DMZHl0Q10NmtgCPSLOa+WLEoYG/pX/84yalkQFNFJNYCXFy6WomOP+5O8+Ts9/sb+tt4 P/hRDBCS8l4QCV2v3lQSsath6lpjsWR+MiZPAX9TV1t5FnaY/mvy2tQt7PCjmH58Lrfv 95ydTBltDrdVbwClW4p+Sa/K1arB7fmTjN6XPo5Ikn15yNSMzZ7MVnh3dzQCnX0W5w7P F3hZ7jdZU3Tr291HY4ueI5N0vVlv3Nx9Vuy9Hm6ll8qNXzr6bm8IFtEKTvvbdwUHvU3j jkcA== 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 g88si4544853qkh.161.2017.11.08.10.08.19; Wed, 08 Nov 2017 10:08:19 -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 A6AD860C88; Wed, 8 Nov 2017 18:08:19 +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 998F26069B; Wed, 8 Nov 2017 18:01:24 +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 17E4260B2A; Wed, 8 Nov 2017 18:00:29 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id 96A0A608BB for ; Wed, 8 Nov 2017 18:00:18 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward105j.mail.yandex.net (Yandex) with ESMTP id F0344182E1D for ; Wed, 8 Nov 2017 21:00:16 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id APxKN2ixyH-0GsGeuGL; Wed, 08 Nov 2017 21:00:16 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id unJA9Y8tSc-0G30TTsk; Wed, 08 Nov 2017 21: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: Wed, 8 Nov 2017 21:00:12 +0300 Message-Id: <1510164012-14286-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510164012-14286-1-git-send-email-odpbot@yandex.ru> References: <1510164012-14286-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v1 8/8] 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: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 569b57eebedebdf2d3148ca06f481cb94bea52e4 **/ test/validation/api/ipsec/ipsec.c | 10 +++++ test/validation/api/ipsec/ipsec.h | 1 + test/validation/api/ipsec/ipsec_test_in.c | 33 ++++++++++++++++ test/validation/api/ipsec/ipsec_test_out.c | 44 ++++++++++++++++++++++ test/validation/api/ipsec/test_vectors.h | 60 ++++++++++++++++++++++++++++++ 5 files changed, 148 insertions(+) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index fb5f7863e..8d63c36a1 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -201,6 +201,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; @@ -284,6 +288,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 9dd0feabf..4532fe7ce 100644 --- a/test/validation/api/ipsec/ipsec.h +++ b/test/validation/api/ipsec/ipsec.h @@ -86,5 +86,6 @@ int ipsec_check_esp_aes_cbc_128_null(void); int ipsec_check_esp_aes_cbc_128_sha256(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 25fc00e11..8e692f678 100644 --- a/test/validation/api/ipsec/ipsec_test_in.c +++ b/test/validation/api/ipsec/ipsec_test_in.c @@ -752,6 +752,37 @@ 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 ipsec_test_capability(void) { odp_ipsec_capability_t capa; @@ -779,6 +810,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, diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c index 39a3c30ff..7be07d095 100644 --- a/test/validation/api/ipsec/ipsec_test_out.c +++ b/test/validation/api/ipsec/ipsec_test_out.c @@ -319,6 +319,48 @@ static void test_out_esp_aes_gcm128(void) ipsec_sa_destroy(sa); } +static void test_out_esp_aes_null_gmac128(void) +{ + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + odp_ipsec_sa_t sa2; + + 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_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); + + sa2 = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa2); + + 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 }, + }, + }; + + ipsec_check_out_in_one(&test, sa, sa2); + + ipsec_sa_destroy(sa2); + ipsec_sa_destroy(sa); +} + static void ipsec_test_capability(void) { odp_ipsec_capability_t capa; @@ -344,5 +386,7 @@ odp_testinfo_t ipsec_out_suite[] = { ipsec_check_esp_aes_cbc_128_sha256), ODP_TEST_INFO_CONDITIONAL(test_out_esp_aes_gcm128, ipsec_check_esp_aes_gcm_128), + ODP_TEST_INFO_CONDITIONAL(test_out_esp_aes_null_gmac128, + 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 2fb06b2b7..20e737c99 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, @@ -962,4 +965,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