DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nithinsen Kaithakadan <nkaithakadan@marvell.com>
To: <dev@dpdk.org>, <stable@dpdk.org>
Cc: <adwivedi@marvell.com>, <anoobj@marvell.com>,
	<ktejasree@marvell.com>, <gakhil@marvell.com>,
	<fanzhang.oss@gmail.com>
Subject: [PATCH 1/3] test/crypto: add ctr test cases and vectors
Date: Wed, 18 Jun 2025 12:54:07 +0000	[thread overview]
Message-ID: <20250618125410.767919-2-nkaithakadan@marvell.com> (raw)
In-Reply-To: <20250618125410.767919-1-nkaithakadan@marvell.com>

Add test cases for AES-CTR along with the
corresponding vectors.

Signed-off-by: Nithinsen Kaithakadan <nkaithakadan@marvell.com>
---
 app/test/test_cryptodev.c                     |  33 +-
 ...st_cryptodev_security_ipsec_test_vectors.h | 316 ++++++++++++++++++
 2 files changed, 348 insertions(+), 1 deletion(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index bee1dfcdba..7535ef6974 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -10572,7 +10572,8 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
 	};
 
-	if (td[0].aead || td[0].aes_gmac) {
+	if (td[0].aead || td[0].aes_gmac ||
+		       (td[0].xform.chain.cipher.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR)) {
 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
 	}
@@ -17946,6 +17947,36 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_known_vec,
 			&pkt_aes_128_cbc_md5),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec,
+			&pkt_aes_128_ctr_hmac_sha256),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec,
+			&pkt_aes_128_ctr_hmac_sha384),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec,
+			&pkt_aes_128_ctr_hmac_sha512),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec_inb,
+			&pkt_aes_128_ctr_hmac_sha256),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec_inb,
+			&pkt_aes_128_ctr_hmac_sha384),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_known_vec_inb,
+			&pkt_aes_128_ctr_hmac_sha512),
 		TEST_CASE_NAMED_WITH_DATA(
 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
 			ut_setup_security, ut_teardown,
diff --git a/app/test/test_cryptodev_security_ipsec_test_vectors.h b/app/test/test_cryptodev_security_ipsec_test_vectors.h
index 6e60e32b9d..17353a2201 100644
--- a/app/test/test_cryptodev_security_ipsec_test_vectors.h
+++ b/app/test/test_cryptodev_security_ipsec_test_vectors.h
@@ -1718,6 +1718,322 @@ struct ipsec_test_data pkt_des_cbc_hmac_sha512 = {
 	},
 };
 
+struct ipsec_test_data pkt_aes_128_ctr_hmac_sha256 = {
+	.key = {
+		.data = {
+			0x43, 0x39, 0x31, 0x4B, 0x55, 0x52, 0x39, 0x47,
+			0x59, 0x4D, 0x6D, 0x35, 0x47, 0x66, 0x6B, 0x45,
+		},
+	},
+	.auth_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 = {
+			0x45, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
+			0x3E, 0x11, 0x6D, 0xAA, 0x0D, 0x00, 0x00, 0x02,
+			0x02, 0x00, 0x00, 0x02, 0x10, 0xE1, 0x04, 0xD2,
+			0x00, 0x48, 0xA7, 0x62, 0x00, 0x01, 0x02, 0x03,
+			0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
+			0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
+			0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B,
+			0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
+		},
+		.len = 64,
+	},
+	.output_text = {
+		.data = {
+			0x45, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
+			0xFE, 0x32, 0x39, 0x00, 0xC0, 0xA8, 0x01, 0x01,
+			0xC0, 0xA8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x64,
+			0x00, 0x00, 0x00, 0x01, 0x6C, 0x02, 0x5C, 0x41,
+			0xD5, 0x18, 0xE5, 0xF9, 0x87, 0xF0, 0x07, 0x54,
+			0xA2, 0x66, 0x28, 0x6E, 0x2C, 0xB4, 0xF9, 0x9A,
+			0x2D, 0xC7, 0x42, 0x36, 0x11, 0xE7, 0x63, 0x38,
+			0xD9, 0xD2, 0x6E, 0x45, 0x9C, 0x7C, 0xB5, 0x4B,
+			0xC7, 0x78, 0x81, 0x49, 0x73, 0xC7, 0x13, 0x44,
+			0xA7, 0x77, 0xB4, 0x56, 0xC6, 0xC7, 0xBD, 0x77,
+			0x7B, 0xFD, 0x3C, 0x67, 0x38, 0xCA, 0xB5, 0x2B,
+			0x67, 0xDB, 0xDF, 0xCB, 0x24, 0x5D, 0xA2, 0xAE,
+			0xD2, 0x15, 0x99, 0x39, 0x20, 0x70, 0xCF, 0x7B,
+			0xEE, 0x17, 0x05, 0xCF, 0x4A, 0xC5, 0xD0, 0x44,
+			0xC9, 0x81, 0xDC, 0xCB, 0xDD, 0xBC, 0x7C, 0x2F,
+		},
+		.len = 120,
+	},
+
+	.iv = {
+		.data = {
+			0x6C, 0x02, 0x5C, 0x41, 0xD5, 0x18, 0xE5, 0xF9,
+		},
+	},
+	.salt = {
+		.data = {
+			0xde, 0xad, 0xbe, 0xef,
+		},
+		.len = 4,
+	},
+
+	.ipsec_xform = {
+		.spi = 100,
+		.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_CTR,
+				.key.length = 16,
+				.iv.length = 12,
+			},
+		},
+		.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,
+			},
+		},
+	},
+};
+
+struct ipsec_test_data pkt_aes_128_ctr_hmac_sha384 = {
+	.key = {
+		.data = {
+			0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+			0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
+		},
+	},
+	.auth_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,
+			0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+			0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
+		},
+	},
+	.input_text = {
+		.data = {
+			0x45, 0x00, 0x00, 0x2E, 0x00, 0x01, 0x00, 0x00,
+			0x3F, 0x11, 0x1C, 0x8A, 0xAC, 0x10, 0x03, 0x0A,
+			0xAC, 0x10, 0x04, 0x0A, 0xC0, 0x00, 0xC0, 0x00,
+			0x00, 0x1A, 0x1A, 0x84, 0x00, 0x00, 0x00, 0x00,
+			0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+			0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+		},
+		.len = 46,
+	},
+	.output_text = {
+		.data = {
+			0x45, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00,
+			0xFF, 0x32, 0x38, 0x0C, 0xC0, 0xA8, 0x01, 0x01,
+			0xC0, 0xA8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x64,
+			0x00, 0x00, 0x00, 0x01, 0xD2, 0xC4, 0xD3, 0xFE,
+			0x1D, 0x7D, 0xEA, 0xBB, 0x92, 0x26, 0xDC, 0x11,
+			0x3D, 0x7B, 0x17, 0x0E, 0x9C, 0x8B, 0x09, 0xA9,
+			0x73, 0xDC, 0xBF, 0xC5, 0x0E, 0x02, 0x31, 0xAA,
+			0xAF, 0x9C, 0x21, 0x81, 0x15, 0x83, 0x22, 0x87,
+			0xB3, 0x93, 0x94, 0x35, 0xAB, 0xB9, 0x43, 0x77,
+			0x4D, 0x18, 0x95, 0xA9, 0x55, 0x0B, 0xD6, 0x8E,
+			0xBA, 0x86, 0x0C, 0x93, 0x67, 0x65, 0x85, 0x7D,
+			0x5E, 0x74, 0x2F, 0xE5, 0x8C, 0x72, 0x60, 0xE3,
+			0x91, 0xB2, 0x83, 0x74, 0x84, 0xAD, 0x19, 0x26,
+			0x26, 0x5D, 0x30, 0x89,
+		},
+		.len = 108,
+	},
+
+	.iv = {
+		.data = {
+			0xD2, 0xC4, 0xD3, 0xFE, 0x1D, 0x7D, 0xEA, 0xBB,
+		},
+	},
+	.salt = {
+		.data = {
+			0xde, 0xad, 0xbe, 0xef,
+		},
+		.len = 4,
+	},
+
+	.ipsec_xform = {
+		.spi = 100,
+		.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_CTR,
+				.key.length = 16,
+				.iv.length = 12,
+			},
+		},
+		.chain.auth = {
+			.next = NULL,
+			.type = RTE_CRYPTO_SYM_XFORM_AUTH,
+			.auth = {
+				.op = RTE_CRYPTO_AUTH_OP_GENERATE,
+				.algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
+				.key.length = 48,
+				.digest_length = 24,
+			},
+		},
+	},
+};
+
+struct ipsec_test_data pkt_aes_128_ctr_hmac_sha512 = {
+	.key = {
+		.data = {
+			0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+			0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
+		},
+	},
+	.auth_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,
+			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 = {
+			0x45, 0x00, 0x00, 0x2E, 0x00, 0x01, 0x00, 0x00,
+			0x3F, 0x11, 0x1C, 0x8A, 0xAC, 0x10, 0x03, 0x0A,
+			0xAC, 0x10, 0x04, 0x0A, 0xC0, 0x00, 0xC0, 0x00,
+			0x00, 0x1A, 0x1A, 0x84, 0x00, 0x00, 0x00, 0x00,
+			0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+			0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+		},
+		.len = 46,
+	},
+	.output_text = {
+		.data = {
+			0x45, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,
+			0xFF, 0x32, 0x38, 0x04, 0xC0, 0xA8, 0x01, 0x01,
+			0xC0, 0xA8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x64,
+			0x00, 0x00, 0x00, 0x01, 0x65, 0xEB, 0x54, 0xB1,
+			0x76, 0x20, 0xF1, 0x31, 0xC2, 0x78, 0xF5, 0xB2,
+			0x63, 0x8D, 0x6F, 0xA4, 0x28, 0xB4, 0xF6, 0xAA,
+			0x21, 0x94, 0xD9, 0x6D, 0x44, 0x71, 0x94, 0xBD,
+			0xBA, 0xE7, 0xEC, 0xEF, 0xB5, 0x8B, 0xA9, 0xCC,
+			0xA7, 0x9D, 0xB7, 0x70, 0x4F, 0x39, 0xD0, 0x3E,
+			0x77, 0x5C, 0xEE, 0x8F, 0xC1, 0x46, 0x38, 0x27,
+			0x10, 0x11, 0x09, 0x2C, 0x32, 0xA3, 0xBE, 0xB2,
+			0x3F, 0xB9, 0x01, 0x9B, 0x1C, 0x74, 0x6F, 0xF8,
+			0xBE, 0x9C, 0xE7, 0xBA, 0x02, 0x0C, 0xC5, 0xD3,
+			0x05, 0x4A, 0xF3, 0x9B, 0x34, 0x8A, 0xF2, 0xE4,
+			0x1B, 0x72, 0x47, 0xBB,
+		},
+		.len = 116,
+	},
+
+	.iv = {
+		.data = {
+			0x65, 0xEB, 0x54, 0xB1, 0x76, 0x20, 0xF1, 0x31
+		},
+	},
+	.salt = {
+		.data = {
+			0xde, 0xad, 0xbe, 0xef,
+		},
+		.len = 4,
+	},
+
+	.ipsec_xform = {
+		.spi = 100,
+		.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_CTR,
+				.key.length = 16,
+				.iv.length = 12,
+			},
+		},
+		.chain.auth = {
+			.next = NULL,
+			.type = RTE_CRYPTO_SYM_XFORM_AUTH,
+			.auth = {
+				.op = RTE_CRYPTO_AUTH_OP_GENERATE,
+				.algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
+				.key.length = 64,
+				.digest_length = 32,
+			},
+		},
+	},
+};
+
 struct ipsec_test_data pkt_aes_128_cbc_hmac_sha256_v6 = {
 	.key = {
 		.data = {
-- 
2.48.1


  reply	other threads:[~2025-06-18 12:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 12:54 [PATCH 0/3] fixes and addition of aes ctr test vectors Nithinsen Kaithakadan
2025-06-18 12:54 ` Nithinsen Kaithakadan [this message]
2025-06-18 12:54 ` [PATCH 2/3] test/crypto: set iv len to 32B for auth and cipher Nithinsen Kaithakadan
2025-06-18 12:54 ` [PATCH 3/3] test/crypto: set ptr to null post crypto op free Nithinsen Kaithakadan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250618125410.767919-2-nkaithakadan@marvell.com \
    --to=nkaithakadan@marvell.com \
    --cc=adwivedi@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=gakhil@marvell.com \
    --cc=ktejasree@marvell.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).