From patchwork Mon Dec 6 11:07:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anoob Joseph X-Patchwork-Id: 104914 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B508A034F; Mon, 6 Dec 2021 12:08:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 79E0141160; Mon, 6 Dec 2021 12:08:48 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 8D6CA40A4B for ; Mon, 6 Dec 2021 12:08:47 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B62JwkR001881; Mon, 6 Dec 2021 03:08:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=gzGY0Z5OoSzscD7TMT5x1UczE8OTJJcnv0cKy7oeypc=; b=jtSfGeXBJknvMW+Le8KzBQswlCztDourKchYJMVoFY1K1E+T7+tNCYDh+iKJhg9qYNBt OAy7XTCGF/lh2v5QKWWZNW1I6GWyqe/fhXHaCrNxAWV9ZUK/f0rgsFUQVCAiCOwDgrTn B1Bm36YUfVAJjI7rvyp5pjttoSpBx/l2a2M00ViRhh8tBOYRE+lq6srwO7BgfXvBrpx4 SA4MBbBnaqdPQI28HXgtHzqUdvpMhvW0DJ0FWgzr9YLxenr8Wnl4DpXERA4Yjaknx1WN ERMXFN2bIYXtqopNz0KC/MVShM5yZ8OoIZAZ/YJcFmqy1anvYomcaVrfEAf3OlyzxjER EA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3cs9muhfve-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 06 Dec 2021 03:08:46 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 6 Dec 2021 03:08:44 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 6 Dec 2021 03:08:44 -0800 Received: from HY-LT1002.marvell.com (HY-LT1002.marvell.com [10.28.176.218]) by maili.marvell.com (Postfix) with ESMTP id 818EC3F704A; Mon, 6 Dec 2021 03:08:40 -0800 (PST) From: Anoob Joseph To: Akhil Goyal , Declan Doherty , Fan Zhang , "Pablo de Lara" CC: Tejasree Kondoj , Jerin Jacob , Archana Muniganti , Hemant Agrawal , Radu Nicolau , Ciara Power , Gagandeep Singh , Subject: [PATCH v2 06/13] test/crypto: add IPsec fragmented packet known vectors Date: Mon, 6 Dec 2021 16:37:53 +0530 Message-ID: <1638788880-650-7-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1638788880-650-1-git-send-email-anoobj@marvell.com> References: <1638777528-553-1-git-send-email-anoobj@marvell.com> <1638788880-650-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: b697H23tyCbRfGXLfSuQ5nHuqeWH-dh1 X-Proofpoint-ORIG-GUID: b697H23tyCbRfGXLfSuQ5nHuqeWH-dh1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-06_04,2021-12-06_01,2021-12-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Tejasree Kondoj Add fragmented plain packet known vector test case in IPsec outbound. Signed-off-by: Tejasree Kondoj --- app/test/test_cryptodev.c | 22 +++++ app/test/test_cryptodev_security_ipsec.c | 10 ++ app/test/test_cryptodev_security_ipsec.h | 1 + .../test_cryptodev_security_ipsec_test_vectors.h | 104 +++++++++++++++++++++ doc/guides/rel_notes/release_22_03.rst | 1 + 5 files changed, 138 insertions(+) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 0f74984..e2bbabf 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -9383,6 +9383,23 @@ test_ipsec_proto_known_vec_inb(const void *test_data) } static int +test_ipsec_proto_known_vec_fragmented(const void *test_data) +{ + struct ipsec_test_data td_outb; + struct ipsec_test_flags flags; + + memset(&flags, 0, sizeof(flags)); + flags.fragment = true; + + memcpy(&td_outb, test_data, sizeof(td_outb)); + + /* Disable IV gen to be able to test with known vectors */ + td_outb.ipsec_xform.options.iv_gen_disable = 1; + + return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags); +} + +static int test_ipsec_proto_all(const struct ipsec_test_flags *flags) { struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX]; @@ -14514,6 +14531,11 @@ static struct unit_test_suite ipsec_proto_testsuite = { test_ipsec_proto_known_vec, &pkt_aes_128_cbc_hmac_sha256_v6), TEST_CASE_NAMED_WITH_DATA( + "Outbound fragmented packet", + ut_setup_security, ut_teardown, + test_ipsec_proto_known_vec_fragmented, + &pkt_aes_128_gcm_frag), + TEST_CASE_NAMED_WITH_DATA( "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)", ut_setup_security, ut_teardown, test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm), diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c index 12031d3..ccce63f 100644 --- a/app/test/test_cryptodev_security_ipsec.c +++ b/app/test/test_cryptodev_security_ipsec.c @@ -659,6 +659,16 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td, return TEST_FAILED; } + if ((td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) && + flags->fragment) { + const struct rte_ipv4_hdr *iph4; + iph4 = (const struct rte_ipv4_hdr *)output_text; + if (iph4->fragment_offset) { + printf("Output packet is fragmented"); + return TEST_FAILED; + } + } + skip = test_ipsec_tunnel_hdr_len_get(td); len -= skip; diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h index d74eee7..884a795 100644 --- a/app/test/test_cryptodev_security_ipsec.h +++ b/app/test/test_cryptodev_security_ipsec.h @@ -63,6 +63,7 @@ struct ipsec_test_flags { bool l4_csum; bool ipv6; bool tunnel_ipv6; + bool fragment; }; struct crypto_param { diff --git a/app/test/test_cryptodev_security_ipsec_test_vectors.h b/app/test/test_cryptodev_security_ipsec_test_vectors.h index b8661f7..b6d48ad 100644 --- a/app/test/test_cryptodev_security_ipsec_test_vectors.h +++ b/app/test/test_cryptodev_security_ipsec_test_vectors.h @@ -958,4 +958,108 @@ struct ipsec_test_data pkt_aes_128_cbc_hmac_sha256_v6 = { }, }; +struct ipsec_test_data pkt_aes_128_gcm_frag = { + .key = { + .data = { + 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, + 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, + }, + }, + .input_text = { + .data = { + 0x45, 0x00, 0x00, 0x6e, 0x00, 0x01, 0x00, 0x17, + 0x40, 0x06, 0xed, 0x48, 0xc6, 0x12, 0x00, 0x00, + 0xc6, 0x12, 0x01, 0x05, 0x00, 0x14, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x55, 0x05, 0x00, 0x00, + 0x00, 0x01, 0x02, 0x03, 0xf2, 0xf6, 0xe9, 0x21, + 0xf9, 0xf2, 0xf6, 0xe9, 0x21, 0xf9, 0xf2, 0xf6, + 0xe9, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .len = 110, + }, + .output_text = { + .data = { + 0x45, 0x00, 0x00, 0xa4, 0x00, 0x01, 0x00, 0x00, + 0x40, 0x32, 0xf6, 0x0c, 0xc0, 0xa8, 0x01, 0x70, + 0xc0, 0xa8, 0x01, 0x5a, 0x00, 0x00, 0x00, 0x34, + 0x00, 0x00, 0x00, 0x01, 0x45, 0xad, 0xfe, 0x23, + 0x78, 0x56, 0x12, 0x00, 0x49, 0x26, 0xac, 0x4e, + 0x8d, 0xf3, 0x74, 0x26, 0x18, 0x3f, 0x65, 0x94, + 0x73, 0x2e, 0xe4, 0xcf, 0x84, 0x6d, 0x03, 0x8a, + 0x4c, 0xdd, 0x2d, 0xef, 0xcd, 0x9f, 0x84, 0x76, + 0x93, 0xe1, 0xee, 0x21, 0x92, 0x8b, 0xf7, 0x7a, + 0xb1, 0x6a, 0x7f, 0xd6, 0x10, 0x66, 0xdd, 0xa1, + 0x8b, 0x17, 0x56, 0x99, 0x9a, 0x40, 0xd0, 0x6b, + 0x2d, 0xe0, 0x55, 0x40, 0x2f, 0xb8, 0x38, 0xe3, + 0x08, 0x46, 0xe2, 0x69, 0xc9, 0xa1, 0x85, 0x9d, + 0x7b, 0xec, 0x33, 0x2a, 0x2d, 0x1d, 0x1f, 0x1a, + 0x9e, 0xf0, 0x1e, 0xc3, 0x33, 0x64, 0x35, 0x82, + 0xbb, 0xb5, 0x7a, 0x91, 0x2e, 0x8d, 0xd5, 0x5b, + 0x3a, 0xbe, 0x95, 0x94, 0xba, 0x40, 0x73, 0x4e, + 0xa4, 0x15, 0xe4, 0x4a, 0xf9, 0x14, 0x2c, 0x4f, + 0x63, 0x2e, 0x23, 0x6e, 0xeb, 0x06, 0xe7, 0x52, + 0xe1, 0xc7, 0x91, 0x7f, 0x19, 0xc0, 0x4a, 0xd2, + 0xd5, 0x3e, 0x84, 0xa8, + }, + .len = 164, + }, + .salt = { + .data = { + 0xde, 0xad, 0xbe, 0xef, + }, + .len = 4, + }, + + .iv = { + .data = { + 0x45, 0xad, 0xfe, 0x23, 0x78, 0x56, 0x12, 0x00, + }, + }, + + .ipsec_xform = { + .spi = 52, + .options.esn = 0, + .options.udp_encap = 0, + .options.copy_dscp = 0, + .options.copy_flabel = 0, + .options.copy_df = 0, + .options.dec_ttl = 0, + .options.ecn = 0, + .options.stats = 0, + .options.tunnel_hdr_verify = 0, + .options.ip_csum_enable = 0, + .options.l4_csum_enable = 0, + .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS, + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, + .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, + .tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4, + .replay_win_sz = 0, + }, + + .aead = true, + + .xform = { + .aead = { + .next = NULL, + .type = RTE_CRYPTO_SYM_XFORM_AEAD, + .aead = { + .op = RTE_CRYPTO_AEAD_OP_ENCRYPT, + .algo = RTE_CRYPTO_AEAD_AES_GCM, + .key.length = 16, + .iv.length = 12, + .iv.offset = IV_OFFSET, + .digest_length = 16, + .aad_length = 12, + }, + }, + }, +}; + #endif /* TEST_CRYPTODEV_SECURITY_IPSEC_TEST_VECTORS_H_ */ diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index 65e348f..0562547 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -67,6 +67,7 @@ New Features * IPv4 in IPv4 * IPv4 in IPv6 * IPv6 in IPv4 + * Added tunnel mode fragment packet tests. Removed Items