test/crypto: add AES-CCM test vectors

Message ID 20220726101619.1992-1-anoobj@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series test/crypto: add AES-CCM test vectors |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Anoob Joseph July 26, 2022, 10:16 a.m. UTC
  From: Archana Muniganti <marchana@marvell.com>

Added ESP tunnel mode known vectors for AES-CCM along with
combined mode support.

Signed-off-by: Archana Muniganti <marchana@marvell.com>
---
 app/test/test_cryptodev.c                     |   8 ++
 app/test/test_cryptodev_security_ipsec.c      |   3 +
 app/test/test_cryptodev_security_ipsec.h      |   5 +
 ...st_cryptodev_security_ipsec_test_vectors.h | 101 ++++++++++++++++++
 4 files changed, 117 insertions(+)
  

Comments

Akhil Goyal Aug. 25, 2022, 8:18 a.m. UTC | #1
> Subject: [PATCH] test/crypto: add AES-CCM test vectors
> 
> From: Archana Muniganti <marchana@marvell.com>
> 
> Added ESP tunnel mode known vectors for AES-CCM along with
> combined mode support.
> 
> Signed-off-by: Archana Muniganti <marchana@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
  
Akhil Goyal Aug. 28, 2022, 9:30 a.m. UTC | #2
> 
> From: Archana Muniganti <marchana@marvell.com>
> 
> Added ESP tunnel mode known vectors for AES-CCM along with
> combined mode support.
> 
> Signed-off-by: Archana Muniganti <marchana@marvell.com>
Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 69a0301de0..ee566a4ee3 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -15292,6 +15292,10 @@  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-CCM 256)",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
 		TEST_CASE_NAMED_WITH_DATA(
 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
 			ut_setup_security, ut_teardown,
@@ -15353,6 +15357,10 @@  static struct unit_test_suite ipsec_proto_testsuite  = {
 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
 		TEST_CASE_NAMED_WITH_DATA(
 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
 			ut_setup_security, ut_teardown,
diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c
index 6086055af1..3f691f0f56 100644
--- a/app/test/test_cryptodev_security_ipsec.c
+++ b/app/test/test_cryptodev_security_ipsec.c
@@ -392,6 +392,9 @@  test_ipsec_td_prepare(const struct crypto_param *param1,
 			else
 				memcpy(td, &pkt_aes_256_gcm, sizeof(*td));
 
+			if (param1->alg.aead == RTE_CRYPTO_AEAD_AES_CCM)
+				td->salt.len = 3;
+
 			td->aead = true;
 			td->xform.aead.aead.algo = param1->alg.aead;
 			td->xform.aead.aead.key.length = param1->key_length;
diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h
index 744dd64a9e..02b08f9f95 100644
--- a/app/test/test_cryptodev_security_ipsec.h
+++ b/app/test/test_cryptodev_security_ipsec.h
@@ -132,6 +132,11 @@  static const struct crypto_param aead_list[] = {
 	{
 		.type = RTE_CRYPTO_SYM_XFORM_AEAD,
 		.alg.aead = RTE_CRYPTO_AEAD_AES_GCM,
+		.key_length = 32,
+	},
+	{
+		.type = RTE_CRYPTO_SYM_XFORM_AEAD,
+		.alg.aead = RTE_CRYPTO_AEAD_AES_CCM,
 		.key_length = 32
 	},
 };
diff --git a/app/test/test_cryptodev_security_ipsec_test_vectors.h b/app/test/test_cryptodev_security_ipsec_test_vectors.h
index 5c5b0445ee..5f775a241a 100644
--- a/app/test/test_cryptodev_security_ipsec_test_vectors.h
+++ b/app/test/test_cryptodev_security_ipsec_test_vectors.h
@@ -325,6 +325,107 @@  struct ipsec_test_data pkt_aes_256_gcm = {
 	},
 };
 
+struct ipsec_test_data pkt_aes_256_ccm = {
+	.key = {
+		.data = {
+			0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+			0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+			0x61, 0x62, 0x63, 0x64, 0x61, 0x62, 0x63, 0x64,
+			0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+		},
+	},
+	.input_text = {
+		.data = {
+			/* IP */
+			0x45, 0x00, 0x00, 0x2E, 0x00, 0x01, 0x00, 0x00,
+			0x40, 0x11, 0x5F, 0xBC, 0x0D, 0x00, 0x00, 0x02,
+			0x0E, 0x00, 0x00, 0x01,
+
+			/* UDP */
+			0x04, 0x01, 0x04, 0x01, 0x00, 0x1A, 0xA0, 0x79,
+			0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78,
+			0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78,
+			0x78, 0x78,
+		},
+		.len = 46,
+	},
+	.output_text = {
+		.data = {
+			/* IP - outer header */
+			0x45, 0x00, 0x00, 0x64, 0x00, 0x01, 0x00, 0x00,
+			0x40, 0x32, 0x76, 0x65, 0x02, 0x00, 0x00, 0x01,
+			0x02, 0x00, 0x00, 0x02,
+
+			/* ESP */
+			0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
+
+			/* IV */
+			0x00, 0x00, 0x00, 0x00, 0x02, 0x58, 0xBB, 0x81,
+
+			/* Data */
+			0xB4, 0x12, 0x67, 0x79, 0x79, 0x9A, 0xCB, 0xC5,
+			0x94, 0xF9, 0xA3, 0x95, 0xAC, 0x06, 0x8B, 0xEE,
+			0x20, 0x69, 0xE8, 0xD9, 0x4A, 0xC2, 0xAA, 0xA0,
+			0xD4, 0xEE, 0xF6, 0xAE, 0x08, 0xF8, 0x3F, 0xE6,
+			0x88, 0x1F, 0x5C, 0xD7, 0x8D, 0x9D, 0x30, 0x02,
+			0x36, 0xEA, 0x10, 0x5B, 0xB0, 0x30, 0x97, 0xBF,
+			0xFA, 0x89, 0x36, 0x53, 0x96, 0xD7, 0x43, 0x8C,
+			0x4D, 0x87, 0xFD, 0x8E, 0x45, 0x49, 0x34, 0x80,
+		},
+		.len = 100,
+	},
+	.salt = {
+		.data = {
+			0x6d, 0x6e, 0x6f
+		},
+		.len = 3,
+	},
+
+	.iv = {
+		.data = {
+			0x00, 0x00, 0x00, 0x00, 0x02, 0x58, 0xBB, 0x81,
+		},
+	},
+
+	.ipsec_xform = {
+		.spi = 0x00000100,
+		.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_CCM,
+				.key.length = 32,
+				.iv.length = 12,
+				.iv.offset = IV_OFFSET,
+				.digest_length = 16,
+				.aad_length = 12,
+			},
+		},
+	},
+};
+
 /* Known vectors for AES-CBC
  * https://datatracker.ietf.org/doc/html/rfc3602#section-4
  */