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

Added vectors and test suite for TLS 1.3
AES-128-GCM, AES-256-GCM and CHACHA20-POLY1305
vectors. The vectors are generated using gnuTLS
client server application.

Signed-off-by: Akhil Goyal <gak...@marvell.com>
---
 app/test/test_cryptodev.c                     |  35 +++
 app/test/test_cryptodev_security_tls_record.h |   3 +
 ...yptodev_security_tls_record_test_vectors.h | 205 ++++++++++++++++++
 3 files changed, 243 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 9b11f34767..70375cc6fa 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -17680,6 +17680,40 @@ static struct unit_test_suite 
dtls12_record_proto_testsuite  = {
        }
 };
 
+static struct unit_test_suite tls13_record_proto_testsuite  = {
+       .suite_name = "TLS 1.3 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, 
&tls13_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, 
&tls13_test_data_aes_256_gcm),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Write record known vector CHACHA20-POLY1305",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec, 
&tls13_test_data_chacha20_poly1305),
+
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Read record known vector AES-GCM-128",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec_read, 
&tls13_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, 
&tls13_test_data_aes_256_gcm),
+               TEST_CASE_NAMED_WITH_DATA(
+                       "Read record known vector CHACHA20-POLY1305",
+                       ut_setup_security, ut_teardown,
+                       test_tls_record_proto_known_vec_read, 
&tls13_test_data_chacha20_poly1305),
+
+               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),           
\
@@ -18699,6 +18733,7 @@ run_cryptodev_testsuite(const char *pmd_name)
                &docsis_proto_testsuite,
                &tls12_record_proto_testsuite,
                &dtls12_record_proto_testsuite,
+               &tls13_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 e706e38e46..05bd7a9862 100644
--- a/app/test/test_cryptodev_security_tls_record.h
+++ b/app/test/test_cryptodev_security_tls_record.h
@@ -124,6 +124,9 @@ extern struct tls_record_test_data 
dtls_test_data_aes_256_cbc_sha256_hmac;
 extern struct tls_record_test_data dtls_test_data_aes_256_cbc_sha384_hmac;
 extern struct tls_record_test_data dtls_test_data_3des_cbc_sha1_hmac;
 extern struct tls_record_test_data dtls_test_data_null_cipher_sha1_hmac;
+extern struct tls_record_test_data tls13_test_data_aes_128_gcm;
+extern struct tls_record_test_data tls13_test_data_aes_256_gcm;
+extern struct tls_record_test_data tls13_test_data_chacha20_poly1305;
 
 int test_tls_record_status_check(struct rte_crypto_op *op,
                                 const struct tls_record_test_data *td);
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 27b07cd54a..8af17b07e5 100644
--- a/app/test/test_cryptodev_security_tls_record_test_vectors.h
+++ b/app/test/test_cryptodev_security_tls_record_test_vectors.h
@@ -1781,4 +1781,209 @@ struct tls_record_test_data 
tls_test_data_3des_cbc_sha1_hmac = {
        .app_type = 0x17,
 };
 
+/* TLS 1.3 AES-128-GCM */
+struct tls_record_test_data tls13_test_data_aes_128_gcm = {
+       .key = {
+               .data = {
+                       0x03, 0x12, 0xf5, 0x86, 0xe4, 0xd0, 0x27, 0xc7,
+                       0x47, 0x82, 0x44, 0xca, 0xd3, 0xce, 0x06, 0x6c,
+               },
+       },
+       .input_text = {
+               .data = {
+                       0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                       0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x20,
+                       0x41, 0x45, 0x53, 0x2d, 0x31, 0x32, 0x38, 0x2d,
+                       0x47, 0x43, 0x4d, 0x20, 0x65, 0x78, 0x61, 0x6d,
+                       0x70, 0x6c, 0x65, 0x20, 0x76, 0x65, 0x63, 0x74,
+                       0x6f, 0x72, 0xa,
+               },
+               .len = 43,
+       },
+       .output_text = {
+               .data = {
+                       0x17, 0x03, 0x03, 0x00, 0x3c,
+                       0x52, 0xb5, 0x24, 0xce, 0x5c, 0x29, 0x0f, 0x0a,
+                       0x3a, 0xc0, 0x60, 0xaf, 0xba, 0xe3, 0x0d, 0x28,
+                       0x6c, 0xbb, 0x3e, 0x5f, 0xde, 0x4a, 0xcd, 0xf1,
+                       0x30, 0x12, 0xa9, 0x42, 0x95, 0x55, 0xf5, 0x2c,
+                       0xb7, 0xb6, 0x60, 0x82, 0xa2, 0x1d, 0x34, 0x33,
+                       0x0a, 0xd7, 0x48, 0x40, 0xef, 0xab, 0x70, 0xa7,
+                       0xb2, 0x58, 0x41, 0xdb, 0xf6, 0x37, 0xe4, 0x6d,
+                       0xa3, 0x1e, 0xbf, 0x6f,
+               },
+               .len = 65,
+       },
+       .imp_nonce = {
+               .data = {
+                       0x8d, 0x1f, 0xa0, 0x14, 0xc7, 0x66, 0x9f, 0x93,
+                       0x74, 0x3f, 0x46, 0x52,
+               },
+               .len = 12,
+       },
+
+       .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 = 0,
+                               .iv.offset = 0,
+                               .digest_length = 16,
+                               .aad_length = 5,
+                       },
+               },
+       },
+
+       .tls_record_xform = {
+               .ver = RTE_SECURITY_VERSION_TLS_1_3,
+               .type = RTE_SECURITY_TLS_SESS_TYPE_WRITE,
+               .tls_1_3.seq_no = 0x0,
+       },
+
+       .aead = true,
+       .app_type = 0x17,
+};
+
+/* TLS 1.3 AES-256-GCM */
+struct tls_record_test_data tls13_test_data_aes_256_gcm = {
+       .key = {
+               .data = {
+                       0xc9, 0xc2, 0xa2, 0x4c, 0x4e, 0x36, 0x19, 0x6e,
+                       0xd8, 0xf5, 0xb9, 0x14, 0x30, 0xfc, 0xe0, 0xef,
+                       0x29, 0xb0, 0x00, 0xd1, 0x2d, 0xfc, 0x5a, 0x76,
+                       0x50, 0xf4, 0xf3, 0xb1, 0x82, 0x21, 0x57, 0x82,
+               },
+       },
+       .input_text = {
+               .data = {
+                       0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                       0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x20,
+                       0x41, 0x45, 0x53, 0x2d, 0x32, 0x35, 0x36, 0x2d,
+                       0x47, 0x43, 0x4d, 0x20, 0x65, 0x78, 0x61, 0x6d,
+                       0x70, 0x6c, 0x65, 0x20, 0x76, 0x65, 0x63, 0x74,
+                       0x6f, 0x72, 0xa,
+               },
+               .len = 43,
+       },
+       .output_text = {
+               .data = {
+                       0x17, 0x03, 0x03, 0x00, 0x3c,
+                       0xc9, 0xb0, 0x44, 0x23, 0xd5, 0xe2, 0xbd, 0x1d,
+                       0xf1, 0x96, 0x53, 0x2c, 0x8c, 0xe2, 0xa3, 0x00,
+                       0x7b, 0x2a, 0xb1, 0xa1, 0xd6, 0x79, 0x58, 0xb5,
+                       0x35, 0x1f, 0xbb, 0x98, 0x03, 0xe1, 0x82, 0xa2,
+                       0x1e, 0x26, 0x81, 0xbe, 0x77, 0x65, 0xaf, 0x7d,
+                       0x9f, 0x52, 0xec, 0x3a, 0x18, 0x2d, 0x36, 0xab,
+                       0xdc, 0xa9, 0xfb, 0xd3, 0xa8, 0xd5, 0xbc, 0x98,
+                       0xa4, 0xab, 0x70, 0xe9,
+               },
+               .len = 65,
+       },
+       .imp_nonce = {
+               .data = {
+                       0xd4, 0x78, 0xf2, 0x90, 0x61, 0x5d, 0x8c, 0x63,
+                       0x4b, 0xf4, 0x72, 0xf3,
+               },
+               .len = 12,
+       },
+
+       .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 = 0,
+                               .iv.offset = 0,
+                               .digest_length = 16,
+                               .aad_length = 5,
+                       },
+               },
+       },
+
+       .tls_record_xform = {
+               .ver = RTE_SECURITY_VERSION_TLS_1_3,
+               .type = RTE_SECURITY_TLS_SESS_TYPE_WRITE,
+               .tls_1_3.seq_no = 0x0,
+       },
+
+       .aead = true,
+       .app_type = 0x17,
+};
+
+struct tls_record_test_data tls13_test_data_chacha20_poly1305 = {
+       .key = {
+               .data = {
+                       0xec, 0x7d, 0x7a, 0x3f, 0x91, 0xdd, 0xb9, 0x70,
+                       0x95, 0x3b, 0x99, 0xb0, 0xe7, 0x66, 0xda, 0xdc,
+                       0x85, 0xbb, 0xfc, 0xc8, 0x50, 0xe9, 0x61, 0x88,
+                       0xc8, 0x1e, 0xf0, 0x61, 0xb0, 0xcd, 0x6c, 0x3d,
+               },
+       },
+       .input_text = {
+               .data = {
+                       0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                       0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x20,
+                       0x43, 0x48, 0x41, 0x43, 0x48, 0x41, 0x32, 0x30,
+                       0x2d, 0x50, 0x4f, 0x4c, 0x59, 0x31, 0x33, 0x30,
+                       0x35, 0x20, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c,
+                       0x65, 0x20, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0xa,
+               },
+               .len = 49,
+       },
+       .output_text = {
+               .data = {
+                       0x17, 0x03, 0x03, 0x00, 0x42,
+                       0x9a, 0xc1, 0xd9, 0x0e, 0xf9, 0x4c, 0x51, 0x8c,
+                       0xb4, 0xa7, 0x54, 0x57, 0x56, 0xba, 0xbb, 0xf7,
+                       0xd7, 0x1d, 0x49, 0x5a, 0x42, 0xd2, 0xab, 0x75,
+                       0x3f, 0xb1, 0x5f, 0xb5, 0x2b, 0x2b, 0xa3, 0xc5,
+                       0x61, 0x32, 0x7e, 0x62, 0x1e, 0xf5, 0x56, 0xff,
+                       0x84, 0x8e, 0x9a, 0x99, 0x06, 0xba, 0x3b, 0xc0,
+                       0x15, 0x4c, 0xf5, 0xb1, 0x5e, 0xcc, 0xff, 0x42,
+                       0x79, 0x4b, 0xa9, 0x23, 0x16, 0x08, 0xc3, 0x9a,
+                       0x52, 0x2a,
+               },
+               .len = 71,
+       },
+       .imp_nonce = {
+               .data = {
+                       0x3c, 0x28, 0xa0, 0xb8, 0xf8, 0x74, 0x35, 0xfe,
+                       0xd2, 0xa0, 0x31, 0x28,
+               },
+               .len = 12,
+       },
+
+       .xform = {
+               .aead = {
+                       .next = NULL,
+                       .type = RTE_CRYPTO_SYM_XFORM_AEAD,
+                       .aead = {
+                               .op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
+                               .algo = RTE_CRYPTO_AEAD_CHACHA20_POLY1305,
+                               .key.length = 32,
+                               .iv.length = 0,
+                               .iv.offset = 0,
+                               .digest_length = 16,
+                               .aad_length = 5,
+                       },
+               },
+       },
+
+       .tls_record_xform = {
+               .ver = RTE_SECURITY_VERSION_TLS_1_3,
+               .type = RTE_SECURITY_TLS_SESS_TYPE_WRITE,
+               .tls_1_3.seq_no = 0x0,
+       },
+
+       .aead = true,
+       .app_type = 0x17,
+};
+
 #endif
-- 
2.25.1

Reply via email to