From: Akhil Goyal <gak...@marvell.com>

Added test vectors for TLS1.2 and DTLS 1.2 for AES-128-GCM
and AES-256-GCM.

These vectors are generated using GnuTLS server and client applications.

Signed-off-by: Akhil Goyal <gak...@marvell.com>
Signed-off-by: Vidya Sagar Velumuri <vvelum...@marvell.com>
---
 app/test/test_cryptodev.c                     |  43 ++-
 app/test/test_cryptodev_security_tls_record.h |   4 +
 ...yptodev_security_tls_record_test_vectors.h | 286 ++++++++++++++++++
 3 files changed, 332 insertions(+), 1 deletion(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index a82f971135..0360f30bd1 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -16818,13 +16818,29 @@ static struct unit_test_suite 
tls12_record_proto_testsuite  = {
                        ut_setup_security, ut_teardown,
                        test_tls_record_proto_known_vec, 
&tls_test_data_aes_128_gcm_v1),
                TEST_CASE_NAMED_WITH_DATA(
-                       "Write record known vector AES-128-CBC-SHA1",
+                       "Write record known vector AES-GCM-128 (vector 2)",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec, 
&tls_test_data_aes_128_gcm_v2),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Write record known vector AES-GCM-256",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec, 
&tls_test_data_aes_256_gcm),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Write record known vector AES-CBC-128-SHA1",
                        ut_setup_security, ut_teardown,
                        test_tls_record_proto_known_vec, 
&tls_test_data_aes_128_cbc_sha1_hmac),
                TEST_CASE_NAMED_WITH_DATA(
                        "Read record known vector AES-GCM-128 (vector 1)",
                        ut_setup_security, ut_teardown,
                        test_tls_record_proto_known_vec_read, 
&tls_test_data_aes_128_gcm_v1),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Read record known vector AES-GCM-128 (vector 2)",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec_read, 
&tls_test_data_aes_128_gcm_v2),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Read record known vector AES-GCM-256",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec_read, 
&tls_test_data_aes_256_gcm),
                TEST_CASE_NAMED_WITH_DATA(
                        "Read record known vector AES-128-CBC-SHA1",
                        ut_setup_security, ut_teardown,
@@ -16833,6 +16849,30 @@ static struct unit_test_suite 
tls12_record_proto_testsuite  = {
        }
 };
 
+static struct unit_test_suite dtls12_record_proto_testsuite  = {
+       .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
+       .setup = tls_record_proto_testsuite_setup,
+       .unit_test_cases = {
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Write record known vector AES-GCM-128",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec, 
&dtls_test_data_aes_128_gcm),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Write record known vector AES-GCM-256",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec, 
&dtls_test_data_aes_256_gcm),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Read record known vector AES-GCM-128",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec_read, 
&dtls_test_data_aes_128_gcm),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Read record known vector AES-GCM-256",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec_read, 
&dtls_test_data_aes_256_gcm),
+               TEST_CASES_END() /**< NULL terminate unit test array */
+       }
+};
+
 #define ADD_UPLINK_TESTCASE(data)                                              
\
        TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,    
\
        ut_teardown, test_docsis_proto_uplink, (const void *) &data),           
\
@@ -17841,6 +17881,7 @@ run_cryptodev_testsuite(const char *pmd_name)
                &pdcp_proto_testsuite,
                &docsis_proto_testsuite,
                &tls12_record_proto_testsuite,
+               &dtls12_record_proto_testsuite,
 #endif
                &end_testsuite
        };
diff --git a/app/test/test_cryptodev_security_tls_record.h 
b/app/test/test_cryptodev_security_tls_record.h
index 3e42db2c03..18d689253b 100644
--- a/app/test/test_cryptodev_security_tls_record.h
+++ b/app/test/test_cryptodev_security_tls_record.h
@@ -56,6 +56,10 @@ struct tls_record_test_flags {
 };
 
 extern struct tls_record_test_data tls_test_data_aes_128_gcm_v1;
+extern struct tls_record_test_data tls_test_data_aes_128_gcm_v2;
+extern struct tls_record_test_data tls_test_data_aes_256_gcm;
+extern struct tls_record_test_data dtls_test_data_aes_128_gcm;
+extern struct tls_record_test_data dtls_test_data_aes_256_gcm;
 extern struct tls_record_test_data tls_test_data_aes_128_cbc_sha1_hmac;
 
 int test_tls_record_status_check(struct rte_crypto_op *op);
diff --git a/app/test/test_cryptodev_security_tls_record_test_vectors.h 
b/app/test/test_cryptodev_security_tls_record_test_vectors.h
index 85ad2df500..fb060275fb 100644
--- a/app/test/test_cryptodev_security_tls_record_test_vectors.h
+++ b/app/test/test_cryptodev_security_tls_record_test_vectors.h
@@ -78,6 +78,148 @@ struct tls_record_test_data tls_test_data_aes_128_gcm_v1 = {
        .app_type = 0x17,
 };
 
+/* TLS 1.2 AES-128-GCM */
+struct tls_record_test_data tls_test_data_aes_128_gcm_v2 = {
+       .key = {
+               .data = {
+                       0x64, 0xda, 0xc6, 0x34, 0xd4, 0x88, 0x59, 0x57,
+                       0x2d, 0x7c, 0xcc, 0x6d, 0xb2, 0x88, 0x40, 0x4c,
+               },
+       },
+       .input_text = {
+               .data = {
+                       0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                       0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x32, 0x20,
+                       0x41, 0x45, 0x53, 0x2d, 0x31, 0x32, 0x38, 0x2d,
+                       0x47, 0x43, 0x4d, 0x20, 0x65, 0x78, 0x61, 0x6d,
+                       0x70, 0x6c, 0x65, 0xa,
+               },
+               .len = 36,
+       },
+       .output_text = {
+               .data = {
+                       0x17, 0x03, 0x03, 0x00, 0x3c,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+                       0xb2, 0x8f, 0x1e, 0x8d, 0xe3, 0x67, 0xfd, 0xfa,
+                       0x68, 0x5a, 0xf4, 0x0f, 0x68, 0xdc, 0x5b, 0x6f,
+                       0x88, 0xd0, 0x1b, 0x3c, 0x84, 0xad, 0x01, 0xcf,
+                       0xd2, 0xab, 0x8b, 0x59, 0xbd, 0x66, 0x93, 0xd2,
+                       0x6f, 0xbd, 0xb2, 0xf0, 0xc7, 0xa3, 0x26, 0x78,
+                       0x35, 0xda, 0xe1, 0x4b, 0xb3, 0x3b, 0x21, 0x08,
+                       0xd2, 0x9b, 0x5c, 0x16,
+               },
+               .len = 65,
+       },
+       .imp_nonce = {
+               .data = {
+                       0xdf, 0x13, 0xc5, 0x7c,
+               },
+               .len = 4,
+       },
+       .iv = {
+               .data = {
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
+               },
+       },
+
+       .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 = 13,
+                       },
+               },
+       },
+
+       .tls_record_xform = {
+               .ver = RTE_SECURITY_VERSION_TLS_1_2,
+               .type = RTE_SECURITY_TLS_SESS_TYPE_WRITE,
+               .tls_1_2.seq_no = 0x1,
+       },
+
+       .aead = true,
+       .app_type = 0x17,
+};
+
+/* TLS 1.2 AES-256-GCM */
+struct tls_record_test_data tls_test_data_aes_256_gcm = {
+       .key = {
+               .data = {
+                       0x14, 0x8d, 0x98, 0x26, 0xc3, 0x9f, 0xae, 0x1a,
+                       0x52, 0x38, 0x7c, 0xfe, 0xcd, 0x2e, 0x7f, 0x28,
+                       0x1f, 0x11, 0x07, 0x02, 0x83, 0xa0, 0x24, 0x78,
+                       0x09, 0x83, 0x65, 0xb9, 0x99, 0x1b, 0x2c, 0x3a,
+               },
+       },
+       .input_text = {
+               .data = {
+                       0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                       0x41, 0x45, 0x53, 0x2d, 0x32, 0x35, 0x36, 0x2d,
+                       0x47, 0x43, 0x4d, 0x20, 0x54, 0x4c, 0x53, 0x20,
+                       0x31, 0x2e, 0x32, 0x20, 0x65, 0x78, 0x61, 0x6d,
+                       0x70, 0x6c, 0x65, 0xa,
+               },
+               .len = 36,
+       },
+       .output_text = {
+               .data = {
+                       0x17, 0x03, 0x03, 0x00, 0x3c,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+                       0x37, 0xed, 0x76, 0x33, 0xb3, 0xcd, 0x66, 0x76,
+                       0x68, 0x2d, 0xc2, 0xb2, 0x83, 0x91, 0x15, 0xdf,
+                       0xc3, 0x13, 0x14, 0x83, 0x99, 0x4c, 0x0c, 0xcc,
+                       0xc0, 0x41, 0x6f, 0x54, 0x8d, 0xd5, 0x6f, 0xe7,
+                       0xe9, 0x7d, 0x9c, 0xed, 0xe8, 0xd6, 0x92, 0xac,
+                       0xa5, 0xc2, 0x93, 0xdf, 0xdc, 0xf7, 0x80, 0x3c,
+                       0xc6, 0xc3, 0x6e, 0x7f,
+               },
+               .len = 65,
+       },
+       .imp_nonce = {
+               .data = {
+                       0xff, 0x9d, 0x56, 0x96,
+               },
+               .len = 4,
+       },
+       .iv = {
+               .data = {
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
+               },
+       },
+
+       .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 = 32,
+                               .iv.length = 12,
+                               .iv.offset = IV_OFFSET,
+                               .digest_length = 16,
+                               .aad_length = 13,
+                       },
+               },
+       },
+
+       .tls_record_xform = {
+               .ver = RTE_SECURITY_VERSION_TLS_1_2,
+               .type = RTE_SECURITY_TLS_SESS_TYPE_WRITE,
+               .tls_1_2.seq_no = 0x1,
+       },
+
+       .aead = true,
+       .app_type = 0x17,
+};
+
 struct tls_record_test_data tls_test_data_aes_128_cbc_sha1_hmac = {
        .key = {
                .data = {
@@ -169,4 +311,148 @@ struct tls_record_test_data 
tls_test_data_aes_128_cbc_sha1_hmac = {
        .app_type = 0x17,
 };
 
+/* DTLS 1.2 AES-128-GCM */
+struct tls_record_test_data dtls_test_data_aes_128_gcm = {
+       .key = {
+               .data = {
+                       0xde, 0x1f, 0xf3, 0x6f, 0x76, 0x9a, 0x99, 0x71,
+                       0x19, 0x5f, 0x03, 0x36, 0x64, 0x7d, 0xb2, 0x1e,
+               },
+       },
+       .output_text = {
+               .data = {
+                       0x17, 0xfe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x01, 0x00, 0x3d, 0x00, 0x01, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x01, 0xe8, 0x02, 0xd6,
+                       0xa6, 0x78, 0x71, 0x50, 0x8f, 0x26, 0x43, 0x5d,
+                       0xf7, 0x50, 0x5a, 0x45, 0x8b, 0xc9, 0x7f, 0xa7,
+                       0x12, 0x51, 0x3a, 0x72, 0x0c, 0xfa, 0x21, 0xff,
+                       0x8c, 0xc9, 0x3f, 0x25, 0x08, 0xb5, 0xe8, 0x7d,
+                       0x5f, 0xbc, 0xa8, 0xb9, 0xd3, 0xe3, 0x15, 0xb0,
+                       0x9b, 0xbd, 0x82, 0x9b, 0x77, 0x14, 0x17, 0x2a,
+                       0x28, 0xbb,
+               },
+               .len = 74,
+       },
+       .input_text = {
+               .data = {
+                       0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                       0x44, 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x32,
+                       0x20, 0x41, 0x45, 0x53, 0x2d, 0x31, 0x32, 0x38,
+                       0x2d, 0x47, 0x43, 0x4d, 0x20, 0x65, 0x78, 0x61,
+                       0x6d, 0x70, 0x6c, 0x65, 0xa,
+               },
+               .len = 37,
+       },
+       .imp_nonce = {
+               .data = {
+                       0x66, 0xb2, 0x04, 0x1d,
+               },
+               .len = 4,
+       },
+       .iv = {
+               .data = {
+                       0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+               },
+       },
+
+       .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 = 13,
+                       },
+               },
+       },
+
+       .tls_record_xform = {
+               .ver = RTE_SECURITY_VERSION_DTLS_1_2,
+               .type = RTE_SECURITY_TLS_SESS_TYPE_WRITE,
+               .dtls_1_2.epoch = 1,
+               .dtls_1_2.seq_no = 1,
+       },
+
+       .aead = true,
+       .app_type = 0x17,
+};
+
+/* DTLS 1.2 AES-256-GCM */
+struct tls_record_test_data dtls_test_data_aes_256_gcm = {
+       .key = {
+               .data = {
+                       0x9e, 0x0d, 0xe9, 0x57, 0x4d, 0x24, 0xa7, 0x15,
+                       0x0d, 0x49, 0xf0, 0x87, 0xa6, 0xf1, 0x3e, 0x33,
+                       0x8c, 0xb8, 0x86, 0xb6, 0xbb, 0x72, 0x93, 0xa2,
+                       0x5e, 0xcb, 0x31, 0xe3, 0x60, 0xc6, 0x7e, 0x11,
+               },
+       },
+       .output_text = {
+               .data = {
+                       0x17, 0xfe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x01, 0x00, 0x39, 0x00, 0x01, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x01, 0xf9, 0xed, 0xe7,
+                       0xe2, 0x53, 0x97, 0x9a, 0x3c, 0xc7, 0x66, 0x21,
+                       0x62, 0xfb, 0x29, 0x27, 0x8d, 0xc6, 0x11, 0xa3,
+                       0x69, 0x89, 0xdc, 0x34, 0x50, 0x6d, 0x2f, 0xf7,
+                       0x58, 0xd5, 0xc7, 0x71, 0xf4, 0x6d, 0x07, 0xae,
+                       0x35, 0x39, 0x7b, 0xa8, 0xc3, 0x38, 0x71, 0xb8,
+                       0xee, 0xb0, 0x18, 0xc6, 0xb5, 0x49,
+               },
+               .len = 70,
+       },
+       .input_text = {
+               .data = {
+                       0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                       0x44, 0x54, 0x4c, 0x53, 0x20, 0x65, 0x78, 0x61,
+                       0x6d, 0x70, 0x6c, 0x65, 0x20, 0x74, 0x65, 0x73,
+                       0x74, 0x20, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0xa,
+               },
+               .len = 33,
+       },
+       .imp_nonce = {
+               .data = {
+                       0x24, 0x58, 0x29, 0x71,
+               },
+               .len = 4,
+       },
+       .iv = {
+               .data = {
+                       0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+               },
+       },
+
+       .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 = 32,
+                               .iv.length = 12,
+                               .iv.offset = IV_OFFSET,
+                               .digest_length = 16,
+                               .aad_length = 13,
+                       },
+               },
+       },
+
+       .tls_record_xform = {
+               .ver = RTE_SECURITY_VERSION_DTLS_1_2,
+               .type = RTE_SECURITY_TLS_SESS_TYPE_WRITE,
+               .dtls_1_2.epoch = 1,
+               .dtls_1_2.seq_no = 1,
+       },
+
+       .aead = true,
+       .app_type = 0x17,
+};
+
 #endif
-- 
2.25.1

Reply via email to