]> git.droids-corp.org - dpdk.git/commitdiff
test/crypto: add IPsec AES-CBC-HMAC-SHA256 known vectors
authorTejasree Kondoj <ktejasree@marvell.com>
Mon, 6 Dec 2021 11:07:49 +0000 (16:37 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Fri, 21 Jan 2022 09:42:45 +0000 (10:42 +0100)
Test app for lookaside IPsec is added with
AES-CBC-HMAC-SHA256 test cases.

Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
app/test/test_cryptodev.c
app/test/test_cryptodev_security_ipsec.h
app/test/test_cryptodev_security_ipsec_test_vectors.h

index ac153a339dec70e222a121e75ea55ca3259ddf52..2cbe3718407cd83cb98b278fa8b6014f8afc8d1f 100644 (file)
@@ -9197,7 +9197,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
                       sizeof(ut_params->auth_xform));
                ut_params->cipher_xform.cipher.key.data = td[0].key.data;
                ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
-               ut_params->auth_xform.auth.key.data = td[0].key.data;
+               ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
 
                /* Verify crypto capabilities */
 
@@ -14422,6 +14422,11 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
                        "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
                        ut_setup_security, ut_teardown,
                        test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
+                       ut_setup_security, ut_teardown,
+                       test_ipsec_proto_known_vec,
+                       &pkt_aes_128_cbc_hmac_sha256),
                TEST_CASE_NAMED_WITH_DATA(
                        "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
                        ut_setup_security, ut_teardown,
@@ -14438,6 +14443,11 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
                        "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
                        ut_setup_security, ut_teardown,
                        test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
+                       ut_setup_security, ut_teardown,
+                       test_ipsec_proto_known_vec_inb,
+                       &pkt_aes_128_cbc_hmac_sha256),
                TEST_CASE_NAMED_ST(
                        "Combined test alg list",
                        ut_setup_security, ut_teardown,
index 91c6cd47ffe87fda85ff9222edf22624bdbc4da0..70a264aa8c53fba21307d96203223bb6e131eba8 100644 (file)
@@ -14,6 +14,9 @@ struct ipsec_test_data {
        struct {
                uint8_t data[32];
        } key;
+       struct {
+               uint8_t data[32];
+       } auth_key;
 
        struct {
                uint8_t data[1024];
index bf831e93b26a8b63151142710c53bab468e4a573..16c88fee8f44bf80ce7a042d1105d8f6b22c5a32 100644 (file)
@@ -434,4 +434,113 @@ struct ipsec_test_data pkt_aes_128_cbc_null = {
        },
 };
 
+struct ipsec_test_data pkt_aes_128_cbc_hmac_sha256 = {
+       .key = {
+               .data = {
+                       0x00, 0x04, 0x05, 0x01, 0x23, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0f, 0x00, 0x00,
+               },
+       },
+       .auth_key = {
+               .data = {
+                       0xde, 0x34, 0x56, 0x00, 0x00, 0x00, 0x78, 0x00,
+                       0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+                       0x10, 0x30, 0x40, 0x00, 0x01, 0x02, 0x03, 0x04,
+                       0x0a, 0x0b, 0x0c, 0x0d, 0x05, 0x06, 0x07, 0x08,
+               },
+       },
+       .input_text = {
+               .data = {
+                       /* IP */
+                       0x45, 0x00, 0x00, 0x32, 0x00, 0x01, 0x00, 0x00,
+                       0x1f, 0x11, 0x17, 0x8b, 0xc0, 0xa8, 0x01, 0x6f,
+                       0xc0, 0xa8, 0x01, 0x70,
+
+                       /* UDP */
+                       0x00, 0x09, 0x00, 0x09, 0x00, 0x1e, 0x00, 0x00,
+                       0xbe, 0x9b, 0xe9, 0x55, 0x00, 0x00, 0x00, 0x21,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               },
+               .len = 50,
+       },
+       .output_text = {
+               .data = {
+                       /* IP - outer header */
+                       0x45, 0x00, 0x00, 0x7c, 0x00, 0x01, 0x00, 0x00,
+                       0x40, 0x32, 0x52, 0x4d, 0x14, 0x00, 0x00, 0x01,
+                       0x14, 0x00, 0x00, 0x02,
+
+                       /* ESP */
+                       0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01,
+
+                       /* IV */
+                       0x34, 0x12, 0x67, 0x45, 0xff, 0xff, 0x00, 0x00,
+                       0x20, 0xbf, 0xe8, 0x39, 0x00, 0x00, 0x00, 0x00,
+
+                       /* Data */
+                       0x67, 0xb5, 0x46, 0x6e, 0x78, 0x17, 0xd3, 0x5a,
+                       0xac, 0x62, 0x62, 0x62, 0xb0, 0x57, 0x9b, 0x09,
+                       0x19, 0x4f, 0x06, 0x59, 0xc8, 0xb0, 0x30, 0x65,
+                       0x1f, 0x45, 0x57, 0x41, 0x72, 0x17, 0x28, 0xe9,
+                       0xad, 0x50, 0xbe, 0x44, 0x1d, 0x2d, 0x9a, 0xd0,
+                       0x48, 0x75, 0x0d, 0x1c, 0x8d, 0x24, 0xa8, 0x6f,
+                       0x6b, 0x24, 0xb6, 0x5d, 0x43, 0x1e, 0x55, 0xf0,
+                       0xf7, 0x14, 0x1f, 0xf2, 0x61, 0xd4, 0xe0, 0x30,
+                       0x16, 0xbe, 0x1b, 0x5c, 0xcc, 0xb7, 0x66, 0x1c,
+                       0x47, 0xad, 0x07, 0x6c, 0xd5, 0xcb, 0xce, 0x6c,
+               },
+               .len = 124,
+       },
+       .iv = {
+               .data = {
+                       0x34, 0x12, 0x67, 0x45, 0xff, 0xff, 0x00, 0x00,
+                       0x20, 0xbf, 0xe8, 0x39, 0x00, 0x00, 0x00, 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,
+               .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 = false,
+
+       .xform = {
+               .chain.cipher = {
+                       .next = NULL,
+                       .type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       .cipher = {
+                               .op = RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+                               .algo = RTE_CRYPTO_CIPHER_AES_CBC,
+                               .key.length = 16,
+                               .iv.length = 16,
+                       },
+               },
+               .chain.auth = {
+                       .next = NULL,
+                       .type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                       .auth = {
+                               .op = RTE_CRYPTO_AUTH_OP_GENERATE,
+                               .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
+                               .key.length = 32,
+                               .digest_length = 16,
+                       },
+               },
+       },
+};
+
 #endif /* TEST_CRYPTODEV_SECURITY_IPSEC_TEST_VECTORS_H_ */