From patchwork Thu Dec 7 13:02:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anoob Joseph X-Patchwork-Id: 134921 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 500A843699; Thu, 7 Dec 2023 14:03:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9FA5C42F3B; Thu, 7 Dec 2023 14:02:51 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 413B342F25 for ; Thu, 7 Dec 2023 14:02:50 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B79PDlF031920; Thu, 7 Dec 2023 05:02:49 -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=KqNmo4JJcupRZWLxM3n7ILwhyBZgstmhrf6O7XSieUY=; b=eg8444biYfA/VE2FzUvv/TpDWOmXae4ntgRbDFYCn8zKSn8nziV+Uqvj0McvYG1y3kYm UVI5j5XVAgkkc0y54O1cVqBBVAxM6NRiHTWmuj+J2KvKz0Pn2uN6E/SgEw+eWkq/L7nE cgJf6lX4RNLzwzXKBbPQOSoPNtB3R/F3nZH6WzrmB3+rclZW7sfN/He/KEbMaqpSvU9m zQjzgu02ZBH9LA6/QoA68+C8acQ/rv+XBuIbqo8sEiCjd/IgAHrNzrzsRbTeNaP0v1+5 jqlbfuYbaVjuEE/BzXqw0UUOpO2nWENMhSy4tiHDSvvtIMhp6S/aKOZ68Z+IR1hfE72y Cw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3uubdd8n6a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 07 Dec 2023 05:02:49 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 7 Dec 2023 05:02:47 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 7 Dec 2023 05:02:47 -0800 Received: from BG-LT92004.corp.innovium.com (unknown [10.28.163.189]) by maili.marvell.com (Postfix) with ESMTP id C22613F7051; Thu, 7 Dec 2023 05:02:44 -0800 (PST) From: Anoob Joseph To: Akhil Goyal , Jerin Jacob CC: Harry van Haaren , Hemant Agrawal , Konstantin Ananyev , , Vidya Sagar Velumuri Subject: [PATCH 09/14] test/crypto: add TLS1.2/DTLS1.2 AES-128/256-GCM vectors Date: Thu, 7 Dec 2023 18:32:11 +0530 Message-ID: <20231207130216.140-10-anoobj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231207130216.140-1-anoobj@marvell.com> References: <20231207130216.140-1-anoobj@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ZUqoj7k19lDSBkt8rDRuSn-YIixMuT_G X-Proofpoint-GUID: ZUqoj7k19lDSBkt8rDRuSn-YIixMuT_G X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_10,2023-12-07_01,2023-05-22_02 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: Akhil Goyal 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 Signed-off-by: Vidya Sagar Velumuri --- 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