Skip to contentSkip to conversation

Add lookaside IPsec tests

PATCH Superseded Anoob Joseph 4 participants 49 messages Jul 29, 2021 – Sep 28, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover Add lookaside IPsec tests

Add lookaside IPsec functional tests. Known vector tests and combined mode framework is added.

Known vector tests for outbound operations would use predefined IV and sequence number as 1. So plain packet would get encrypted to generate the IPsec packet. Tests would compare against known vector.

Known vector tests for inbound operation would generate test vectors by reversing outbound known vectors. The input_text would become encrypted packet and output_text would be the plain packet. Tests would then validate the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers supported by the hardware. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

Two test cases use combined mode,
1. Display algo coverage and basic in + out tests
2. Negative test for ICV corruption

Known vectors are based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum computed correctly. And they have following properties,
1. ESP
2. Tunnel mode
3. IPv4
4. IPv4 tunnel

This series is targetted for DPDK 21.11.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode
2. IPv6
3. UDP encapsulation
4. Transport
5. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k

Anoob Joseph (2):
test/crypto: add lookaside IPsec tests
test/crypto: add combined mode tests

Tejasree Kondoj (1):
test/crypto: add lookaside IPsec ICV corrupt test case

 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 330 +++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 311 +++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           | 115 +++++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 ++++++++++++++++++++
 6 files changed, 1084 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Following tests are added,

1. Inbound known vector [AES-GCM 128, 192 & 256]
2. Outbound known vector [AES-GCM 128, 192 & 256]

---
 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 250 ++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 202 +++++++++++++
 app/test/test_cryptodev_security_ipsec.h           |  66 +++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++++++
 6 files changed, 846 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
app/test/meson.build +1 -0
index 88aae44..4cfa022 100644
@@ -31,6 +31,7 @@ test_sources = files(
         'test_cryptodev.c',
         'test_cryptodev_asym.c',
         'test_cryptodev_blockcipher.c',
+        'test_cryptodev_security_ipsec.c',
         'test_cryptodev_security_pdcp.c',
         'test_cycles.c',
         'test_debug.c',
app/test/test.h +6 -0
index c3b2a87..7115edf 100644
@@ -124,6 +124,12 @@ struct unit_test_case {
 #define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \
 		{ setup, teardown, NULL, testcase, #testcase, 1, data }
 
+#define TEST_CASE_NAMED_ST(name, setup, teardown, testcase) \
+		{ setup, teardown, NULL, testcase, name, 1, NULL }
+
+#define TEST_CASE_NAMED_WITH_DATA(name, setup, teardown, testcase, data) \
+		{ setup, teardown, NULL, testcase, name, 1, data }
+
 #define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL }
 
 #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
app/test/test_cryptodev.c +250 -0

292 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.c new file +202 -0

202 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h new file +66 -0

66 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec_test_vectors.h new file +321 -0

321 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/3 test/crypto: add combined mode tests

In reply to Anoob Joseph

Add framework to test IPsec features with all supported combinations of ciphers.

---
 app/test/test_cryptodev.c                |  74 +++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.c | 107 +++++++++++++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.h |  50 ++++++++++++++-
 3 files changed, 221 insertions(+), 10 deletions(-)
app/test/test_cryptodev.c +69 -5
index 6e5bd69..ad9f372 100644
@@ -8863,7 +8863,8 @@ static int
 test_ipsec_proto_process(const struct ipsec_test_data td[],
 			 struct ipsec_test_data res_d[],
 			 int nb_td,
-			 bool silent)
+			 bool silent,
+			 const struct ipsec_test_flags *flags)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -8986,12 +8987,12 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 		/* Process crypto operation */
 		process_crypto_request(dev_id, ut_params->op);
 
-		ret = test_ipsec_status_check(ut_params->op, dir);
+		ret = test_ipsec_status_check(ut_params->op, flags, dir);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
-					      &res_d[i], silent);
+					      &res_d[i], silent, flags);
 
 		rte_crypto_op_free(ut_params->op);
 		ut_params->op = NULL;
@@ -9017,17 +9018,76 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 static int
 test_ipsec_proto_known_vec(const void *test_data)
 {
-	return test_ipsec_proto_process(test_data, NULL, 1, false);
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	return test_ipsec_proto_process(test_data, NULL, 1, false, &flags);
 }
 
 static int
 test_ipsec_proto_known_vec_inb(const void *td_outb)
 {
+	struct ipsec_test_flags flags;
 	struct ipsec_test_data td_inb;
 
+	memset(&flags, 0, sizeof(flags));
+
 	test_ipsec_td_in_from_out(td_outb, &td_inb);
 
-	return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
+}
+
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags)
+{
+	struct ipsec_test_data td_outb[1];
+	struct ipsec_test_data td_inb[1];
+	unsigned int i, pass_cnt = 0;
+	int ret;
+
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      RTE_DIM(td_outb));
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, 1, true, flags);
+		if (ret != TEST_SUCCESS)
+			continue;
+
+		test_ipsec_td_update(td_inb, td_outb, RTE_DIM(td_inb), flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, 1, true, flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+
+static int
+test_ipsec_proto_display_list(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.display_alg = true;
+
+	return test_ipsec_proto_all(&flags);
 }
 
 static int
@@ -13948,6 +14008,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_ST(
+			"Combined test alg list",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_display_list),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +103 -4

149 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +49 -1

66 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/3 test/crypto: add lookaside IPsec ICV corrupt test case

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Adding lookaside IPsec ICV corrupt test case.

---
 app/test/test_cryptodev.c                | 16 ++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 30 ++++++++++++++++++++----------
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 37 insertions(+), 10 deletions(-)
app/test/test_cryptodev.c +16 -0
index ad9f372..e59849a 100644
@@ -9091,6 +9091,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.icv_corrupt = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -14012,6 +14024,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			"Combined test alg list",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
+		TEST_CASE_NAMED_ST(
+			"Negative test: ICV corruption",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_err_icv_corrupt),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +20 -10
index 5351556..331a8bf 100644
@@ -175,9 +175,12 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 		memcpy(td_inb[i].output_text.data, td_outb[i].input_text.data,
 		       td_outb[i].input_text.len);
 		td_inb[i].output_text.len = td_outb->input_text.len;
-	}
 
-	RTE_SET_USED(flags);
+		if (flags && flags->icv_corrupt) {
+			int icv_pos = td_inb[i].input_text.len - 4;
+			td_inb[i].input_text.data[icv_pos] += 1;
+		}
+	}
 }
 
 void
@@ -199,6 +202,11 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
 	uint32_t skip = 0, len = rte_pktmbuf_pkt_len(m);
 
+	/* For negative tests, no need to do verification */
+	if (flags->icv_corrupt &&
+	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
+		return TEST_SUCCESS;
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
@@ -231,8 +239,6 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 		return TEST_FAILED;
 	}
 
-	RTE_SET_USED(flags);
-
 	return TEST_SUCCESS;
 }
 
@@ -289,13 +295,17 @@ test_ipsec_status_check(struct rte_crypto_op *op,
 {
 	int ret = TEST_SUCCESS;
 
-	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
-		printf("Security op processing failed\n");
-		ret = TEST_FAILED;
+	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->icv_corrupt) {
+		if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+			printf("ICV corruption test case failed\n");
+			ret = TEST_FAILED;
+		}
+	} else {
+		if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+			printf("Security op processing failed\n");
+			ret = TEST_FAILED;
+		}
 	}
 
-	RTE_SET_USED(flags);
-	RTE_SET_USED(dir);
-
 	return ret;
 }
app/test/test_cryptodev_security_ipsec.h +1 -0
index 97f3f86..717aab4 100644
@@ -47,6 +47,7 @@ struct ipsec_test_data {
 
 struct ipsec_test_flags {
 	bool display_alg;
+	bool icv_corrupt;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
#4 lore raw

v2 cover Add lookaside IPsec tests

In reply to Anoob Joseph

Add lookaside IPsec functional tests. Known vector tests and combined mode framework is added.

Known vectors are outbound vectors based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum computed correctly. And they have following properties,
1. ESP
2. Tunnel mode
3. IPv4
4. IPv4 tunnel

Known vector tests for inbound operation would generate test vectors by reversing outbound known vectors. The input_text would become encrypted packet and output_text would be the plain packet. Tests would then validate the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers supported by the PMD. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

Three test cases use combined mode,
1. Display algo coverage and basic in + out tests
2. Negative test for ICV corruption
3. IV generation

IV generation test case compares IV generated for a batch of packets and returns failure if IV is repeated.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode
2. IPv6
3. UDP encapsulation
4. Transport
5. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k

Changes in v2
- Dropped outbound known vector tests as lookaside protocol would require IV generated by PMD. The tests would be introduced with spec change to allow user to specify IV.
- Added IV generation tests
- Minor fixes in combined mode tests to handle multiple packets

Anoob Joseph (2):
test/crypto: add lookaside IPsec tests
test/crypto: add combined mode tests

Tejasree Kondoj (2):
test/crypto: add lookaside IPsec ICV corrupt test case test/crypto: add IV gen tests

 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 331 ++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 373 +++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           | 118 +++++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 ++++++++++++++++++
 6 files changed, 1150 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 1/4 test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are added.

Cipher list: AES-GCM 128, 192 & 256

---
 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 231 +++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           |  66 +++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++++++
 6 files changed, 837 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
app/test/meson.build +1 -0
index a761168..f144d8b 100644
@@ -38,6 +38,7 @@ test_sources = files(
         'test_cryptodev.c',
         'test_cryptodev_asym.c',
         'test_cryptodev_blockcipher.c',
+        'test_cryptodev_security_ipsec.c',
         'test_cryptodev_security_pdcp.c',
         'test_cycles.c',
         'test_debug.c',
app/test/test.h +6 -0
index c3b2a87..7115edf 100644
@@ -124,6 +124,12 @@ struct unit_test_case {
 #define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \
 		{ setup, teardown, NULL, testcase, #testcase, 1, data }
 
+#define TEST_CASE_NAMED_ST(name, setup, teardown, testcase) \
+		{ setup, teardown, NULL, testcase, name, 1, NULL }
+
+#define TEST_CASE_NAMED_WITH_DATA(name, setup, teardown, testcase, data) \
+		{ setup, teardown, NULL, testcase, name, 1, data }
+
 #define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL }
 
 #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
app/test/test_cryptodev.c +231 -0

273 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.c new file +212 -0

212 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h new file +66 -0

66 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec_test_vectors.h new file +321 -0

321 lines not on this page · raw message

Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 2/4 test/crypto: add combined mode tests

In reply to Anoob Joseph

Add framework to test IPsec features with all supported combinations of ciphers.

---
 app/test/test_cryptodev.c                |  73 +++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.c | 107 +++++++++++++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.h |  52 ++++++++++++++-
 3 files changed, 223 insertions(+), 9 deletions(-)
app/test/test_cryptodev.c +69 -4
index 73923f1..d89307d 100644
@@ -8860,7 +8860,8 @@ static int
 test_ipsec_proto_process(const struct ipsec_test_data td[],
 			 struct ipsec_test_data res_d[],
 			 int nb_td,
-			 bool silent)
+			 bool silent,
+			 const struct ipsec_test_flags *flags)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -8977,7 +8978,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 		/* Process crypto operation */
 		process_crypto_request(dev_id, ut_params->op);
 
-		ret = test_ipsec_status_check(ut_params->op, dir);
+		ret = test_ipsec_status_check(ut_params->op, flags, dir);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -8985,7 +8986,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 			res_d_tmp = &res_d[i];
 
 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
-					      res_d_tmp, silent);
+					      res_d_tmp, silent, flags);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -9013,11 +9014,71 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 static int
 test_ipsec_proto_known_vec_inb(const void *td_outb)
 {
+	struct ipsec_test_flags flags;
 	struct ipsec_test_data td_inb;
 
+	memset(&flags, 0, sizeof(flags));
+
 	test_ipsec_td_in_from_out(td_outb, &td_inb);
 
-	return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
+}
+
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags)
+{
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      nb_pkts);
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+
+static int
+test_ipsec_proto_display_list(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.display_alg = true;
+
+	return test_ipsec_proto_all(&flags);
 }
 
 static int
@@ -13926,6 +13987,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_ST(
+			"Combined test alg list",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_display_list),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +103 -4

153 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +51 -1

74 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 3/4 test/crypto: add lookaside IPsec ICV corrupt test case

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Adding lookaside IPsec ICV corrupt test case.

---
 app/test/test_cryptodev.c                | 16 ++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 30 ++++++++++++++++++++----------
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 37 insertions(+), 10 deletions(-)
app/test/test_cryptodev.c +16 -0
index d89307d..488daed 100644
@@ -9082,6 +9082,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.icv_corrupt = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -13991,6 +14003,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			"Combined test alg list",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
+		TEST_CASE_NAMED_ST(
+			"Negative test: ICV corruption",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_err_icv_corrupt),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +20 -10
index d08e093..aebbe66 100644
@@ -175,9 +175,12 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 		memcpy(td_inb[i].output_text.data, td_outb[i].input_text.data,
 		       td_outb[i].input_text.len);
 		td_inb[i].output_text.len = td_outb->input_text.len;
-	}
 
-	RTE_SET_USED(flags);
+		if (flags->icv_corrupt) {
+			int icv_pos = td_inb[i].input_text.len - 4;
+			td_inb[i].input_text.data[icv_pos] += 1;
+		}
+	}
 }
 
 void
@@ -217,6 +220,11 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
 	uint32_t skip, len = rte_pktmbuf_pkt_len(m);
 
+	/* For negative tests, no need to do verification */
+	if (flags->icv_corrupt &&
+	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
+		return TEST_SUCCESS;
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
@@ -241,8 +249,6 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 		return TEST_FAILED;
 	}
 
-	RTE_SET_USED(flags);
-
 	return TEST_SUCCESS;
 }
 
@@ -299,13 +305,17 @@ test_ipsec_status_check(struct rte_crypto_op *op,
 {
 	int ret = TEST_SUCCESS;
 
-	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
-		printf("Security op processing failed\n");
-		ret = TEST_FAILED;
+	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->icv_corrupt) {
+		if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+			printf("ICV corruption test case failed\n");
+			ret = TEST_FAILED;
+		}
+	} else {
+		if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+			printf("Security op processing failed\n");
+			ret = TEST_FAILED;
+		}
 	}
 
-	RTE_SET_USED(flags);
-	RTE_SET_USED(dir);
-
 	return ret;
 }
app/test/test_cryptodev_security_ipsec.h +1 -0
index cbb3ee4..134fc3a 100644
@@ -49,6 +49,7 @@ struct ipsec_test_data {
 
 struct ipsec_test_flags {
 	bool display_alg;
+	bool icv_corrupt;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
#8 lore raw

PATCH v2 4/4 test/crypto: add IV gen tests

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add test cases to verify IV generated by PMD.

---
 app/test/test_cryptodev.c                | 19 ++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 52 ++++++++++++++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 72 insertions(+)
app/test/test_cryptodev.c +19 -0
index 488daed..71e6c1a 100644
@@ -9032,6 +9032,9 @@ test_ipsec_proto_all(const struct ipsec_test_flags *flags)
 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
 	int ret;
 
+	if (flags->iv_gen)
+		nb_pkts = IPSEC_TEST_PACKETS_MAX;
+
 	for (i = 0; i < RTE_DIM(aead_list); i++) {
 		test_ipsec_td_prepare(&aead_list[i],
 				      NULL,
@@ -9082,6 +9085,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_iv_gen(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.iv_gen = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags;
@@ -14004,6 +14019,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
 		TEST_CASE_NAMED_ST(
+			"IV generation",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_iv_gen),
+		TEST_CASE_NAMED_ST(
 			"Negative test: ICV corruption",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_err_icv_corrupt),
app/test/test_cryptodev_security_ipsec.c +52 -0

76 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +1 -0
index 134fc3a..d2ec63f 100644
@@ -50,6 +50,7 @@ struct ipsec_test_data {
 struct ipsec_test_flags {
 	bool display_alg;
 	bool icv_corrupt;
+	bool iv_gen;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
#9 lore raw

v3 cover Add lookaside IPsec tests

In reply to Anoob Joseph

Add lookaside IPsec functional tests. Known vector tests and combined mode framework is added.

Known vectors are outbound vectors based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum computed correctly. And they have following properties,
1. ESP
2. Tunnel mode
3. IPv4
4. IPv4 tunnel

Known vector tests for inbound operation would generate test vectors by reversing outbound known vectors. The input_text would become encrypted packet and output_text would be the plain packet. Tests would then validate the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers supported by the PMD. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

Four test cases use combined mode,
1. Display algo coverage and basic in + out tests
2. Negative test for ICV corruption
3. IV generation
4. UDP encapsulation

IV generation test case compares IV generated for a batch of packets and returns failure if IV is repeated.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode
2. IPv6
3. Transport
4. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k

Changes in v3
- Added UDP encapsulation tests

Changes in v2
- Dropped outbound known vector tests as lookaside protocol would require IV generated by PMD. The tests would be introduced with spec change to allow user to specify IV.
- Added IV generation tests
- Minor fixes in combined mode tests to handle multiple packets

Anoob Joseph (2):
test/crypto: add lookaside IPsec tests
test/crypto: add combined mode tests

Tejasree Kondoj (3):
test/crypto: add lookaside IPsec ICV corrupt test case test/crypto: add IV gen tests
test/crypto: add UDP encapsulation test cases

 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 350 ++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 401 +++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           | 119 ++++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++
 6 files changed, 1198 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
Signature · 1 line
2.7.4
#10 lore raw

PATCH v3 1/5 test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are added.

Cipher list: AES-GCM 128, 192 & 256

---
 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 231 +++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           |  66 +++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++++++
 6 files changed, 837 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
app/test/meson.build +1 -0
index a761168..f144d8b 100644
@@ -38,6 +38,7 @@ test_sources = files(
         'test_cryptodev.c',
         'test_cryptodev_asym.c',
         'test_cryptodev_blockcipher.c',
+        'test_cryptodev_security_ipsec.c',
         'test_cryptodev_security_pdcp.c',
         'test_cycles.c',
         'test_debug.c',
app/test/test.h +6 -0
index c3b2a87..7115edf 100644
@@ -124,6 +124,12 @@ struct unit_test_case {
 #define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \
 		{ setup, teardown, NULL, testcase, #testcase, 1, data }
 
+#define TEST_CASE_NAMED_ST(name, setup, teardown, testcase) \
+		{ setup, teardown, NULL, testcase, name, 1, NULL }
+
+#define TEST_CASE_NAMED_WITH_DATA(name, setup, teardown, testcase, data) \
+		{ setup, teardown, NULL, testcase, name, 1, data }
+
 #define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL }
 
 #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
app/test/test_cryptodev.c +231 -0

273 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.c new file +212 -0

212 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h new file +66 -0

66 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec_test_vectors.h new file +321 -0

321 lines not on this page · raw message

Signature · 1 line
2.7.4
#11 lore raw

Re: [dpdk-dev] [PATCH v3 1/5] test/crypto: add lookaside IPsec tests

Hi Anoob,

Left some comments/questions inline.

Thanks,
Ciara

Quoted 20 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 05:47
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v3 1/5] test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are added.

Cipher list: AES-GCM 128, 192 & 256

---

<snip>

Quoted 13 lines

#ifdef RTE_LIB_SECURITY
static int

app/test/test_cryptodev.c +10 -0
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 784

Quoted 8 lines
app/test/test_cryptodev.c +8 -0
+				"testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */
+	dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);
+

Just a question on this - each testcase uses ut_setup_security which in turn calls dev_configure_and_start, Is the configuration resulting from this call just being redone when the first testcase runs?

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 793

Quoted 11 lines
(quoted diff) +2 -0
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +5 -0
+
+	if (security_proto_supported(
+			RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto

"

app/test/test_cryptodev.c +2 -0
+				"test not met\n");
+		return TEST_SKIPPED;

If the test is skipped here, the device is not stopped, which I believe would cause problems for the next testsuite setup configuring the device.

Quoted 7 lines
app/test/test_cryptodev.c +7 -0
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);
+
+	return 0;
+}
#12 lore raw

Re: [dpdk-dev] [PATCH v3 1/5] test/crypto: add lookaside IPsec tests

Hi Ciara,

Thanks for the review. Please see inline.

Thanks,
Anoob

Quoted 69 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Friday, September 3, 2021 3:09 PM
To: Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v3 1/5] test/crypto: add lookaside IPsec tests

External Email

----------------------------------------------------------------------
Hi Anoob,

Left some comments/questions inline.

Thanks,
Ciara

Quoted 14 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 05:47
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v3 1/5] test/crypto: add lookaside IPsec tests

Quoted 1 line

Added test case for lookaside IPsec. Inbound known vector tests are

added.

Quoted 6 lines

Cipher list: AES-GCM 128, 192 & 256

---

<snip>

Quoted 13 lines

#ifdef RTE_LIB_SECURITY
static int

app/test/test_cryptodev.c +10 -0
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 784

Quoted 6 lines
app/test/test_cryptodev.c +6 -0
+				"testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */
+

dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPT
O |

Quoted 7 lines
Quoted 1 line

+

	RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);
Quoted 1 line

+

Just a question on this - each testcase uses ut_setup_security which in turn calls dev_configure_and_start, Is the configuration resulting from this call just being redone when the first testcase runs?

[Anoob] The tests prior to this test suite can have SECURITY disabled (which is the case currently). And in that case, rte_security_capabalities_get() would be returning a NULL (since the device won't be having SECURITY feature enabled). I was addressing this aspect by reconfiguring with SECURITY enabled.

Quoted 11 lines

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 795

Quoted 7 lines
(quoted diff) +2 -0
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +3 -0
+
+	if (security_proto_supported(
+

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,

Review

Quoted 2 lines
(quoted diff) +2 -0
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec

Proto

Quoted 6 lines

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 793

Quoted 3 lines

"

app/test/test_cryptodev.c +2 -0
+				"test not met\n");
+		return TEST_SKIPPED;

If the test is skipped here, the device is not stopped, which I believe would cause problems for the next testsuite setup configuring the device.

[Anoob] Missed this. Thanks for pointing out.

Quoted 9 lines
Quoted 8 lines
app/test/test_cryptodev.c +7 -0
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);
+
+	return 0;
+}
#13 lore raw

PATCH v3 2/5 test/crypto: add combined mode tests

In reply to Anoob Joseph

Add framework to test IPsec features with all supported combinations of ciphers.

---
 app/test/test_cryptodev.c                |  73 +++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.c | 107 +++++++++++++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.h |  52 ++++++++++++++-
 3 files changed, 223 insertions(+), 9 deletions(-)
app/test/test_cryptodev.c +69 -4
index 73923f1..d89307d 100644
@@ -8860,7 +8860,8 @@ static int
 test_ipsec_proto_process(const struct ipsec_test_data td[],
 			 struct ipsec_test_data res_d[],
 			 int nb_td,
-			 bool silent)
+			 bool silent,
+			 const struct ipsec_test_flags *flags)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -8977,7 +8978,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 		/* Process crypto operation */
 		process_crypto_request(dev_id, ut_params->op);
 
-		ret = test_ipsec_status_check(ut_params->op, dir);
+		ret = test_ipsec_status_check(ut_params->op, flags, dir);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -8985,7 +8986,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 			res_d_tmp = &res_d[i];
 
 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
-					      res_d_tmp, silent);
+					      res_d_tmp, silent, flags);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -9013,11 +9014,71 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 static int
 test_ipsec_proto_known_vec_inb(const void *td_outb)
 {
+	struct ipsec_test_flags flags;
 	struct ipsec_test_data td_inb;
 
+	memset(&flags, 0, sizeof(flags));
+
 	test_ipsec_td_in_from_out(td_outb, &td_inb);
 
-	return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
+}
+
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags)
+{
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      nb_pkts);
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+
+static int
+test_ipsec_proto_display_list(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.display_alg = true;
+
+	return test_ipsec_proto_all(&flags);
 }
 
 static int
@@ -13926,6 +13987,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_ST(
+			"Combined test alg list",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_display_list),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +103 -4

153 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +51 -1

74 lines not on this page · raw message

Signature · 1 line
2.7.4
#14 lore raw

Re: [dpdk-dev] [PATCH v3 2/5] test/crypto: add combined mode tests

Hi Anoob,

Quoted 18 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 05:47
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v3 2/5] test/crypto: add combined mode tests

Add framework to test IPsec features with all supported combinations of ciphers.

---

<snip>

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[], · line 9034

Quoted 7 lines
app/test/test_cryptodev.c +7 -0
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags) {
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+

Is this testcase actually running multiple testcases under the hood?
I wonder could it be suited to use a sub-testsuite structure to bring the testcase results up to the top level, as done with cryptodev blockcipher tests. Have you considered this approach?

Thanks,
Ciara

Quoted 37 lines
app/test/test_cryptodev.c +37 -0
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      nb_pkts);
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+

<snip>

#15 lore raw

Re: [dpdk-dev] [PATCH v3 2/5] test/crypto: add combined mode tests

Hi Ciara,

Please see inline.

Thanks,
Anoob

Quoted 28 lines

External Email

----------------------------------------------------------------------
Hi Anoob,

Quoted 14 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 05:47
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v3 2/5] test/crypto: add combined mode tests

Quoted 1 line

Add framework to test IPsec features with all supported combinations of

ciphers.

Quoted 4 lines

---

<snip>

Quoted 12 lines

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[], · line 9034

Quoted 7 lines
app/test/test_cryptodev.c +7 -0
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags) {
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+

Is this testcase actually running multiple testcases under the hood? I wonder could it be suited to use a sub-testsuite structure to bring the testcase results up to the top level, as done with cryptodev blockcipher tests. Have you considered this approach?

[Anoob] The idea behind this framework is to test an IPsec feature (like UDP encapsulation) without tying it to any specific algorithm. So what this does is, it loops over a list of possible combinations and then runs the test for each combination. The test would be like this,

1. Do outbound processing to generate encrypted packet
2. Basic checks or validation as required for the test (for example, with UDP encapsulation, we would validate UDP hdr in the processed packet).
3. Any manipulations required (like for ICV corruption negative test)
4. Do inbound processing to get decrypted packet
5. Validate results based on the type of test (ICV corruption would give expect an error while normal tests would have the operation return original plain text packet)

It's actually the array (aead_list) and this loop which initiates the test to be run for all algos. And, since we are not having static vectors for each test case, this approach seemed more straightforward. Do you think sub-testsuite makes more sense here?

Quoted 43 lines

Thanks,
Ciara

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[],

Quoted 8 lines
app/test/test_cryptodev.c +8 -0
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      nb_pkts);
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts,

true,

Quoted 29 lines
app/test/test_cryptodev.c +29 -0
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+

<snip>

#16 lore raw

Re: [dpdk-dev] [PATCH v3 2/5] test/crypto: add combined mode tests

Hi Anoob,

Quoted 76 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 11:05
To: Power, Ciara <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: RE: [PATCH v3 2/5] test/crypto: add combined mode tests

Hi Ciara,

Please see inline.

Thanks,
Anoob

Quoted 29 lines

External Email

----------------------------------------------------------------------
Hi Anoob,

Quoted 14 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 05:47
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v3 2/5] test/crypto: add combined mode tests

Quoted 2 lines

Add framework to test IPsec features with all supported combinations of

ciphers.

Quoted 4 lines

---

<snip>

Quoted 11 lines

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[], · line 9034

Quoted 7 lines
app/test/test_cryptodev.c +7 -0
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags) {
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+

Is this testcase actually running multiple testcases under the hood? I wonder could it be suited to use a sub-testsuite structure to bring the testcase results up to the top level, as done with cryptodev blockcipher

tests.

Quoted 1 line

Have you considered this approach?

[Anoob] The idea behind this framework is to test an IPsec feature (like UDP encapsulation) without tying it to any specific algorithm. So what this does is, it loops over a list of possible combinations and then runs the test for each combination. The test would be like this,

1. Do outbound processing to generate encrypted packet 2. Basic checks or validation as required for the test (for example, with UDP encapsulation, we would validate UDP hdr in the processed packet).
3. Any manipulations required (like for ICV corruption negative test) 4. Do inbound processing to get decrypted packet 5. Validate results based on the type of test (ICV corruption would give expect an error while normal tests would have the operation return original plain text packet)

Quoted 5 lines

It's actually the array (aead_list) and this loop which initiates the test to be run for all algos. And, since we are not having static vectors for each test case, this approach seemed more straightforward. Do you think sub-testsuite makes more sense here?

Thanks for the explanation.
I still think having each test reporting its individual result to the top level provides more clarity when running tests, rather than having multiple tests being run under the disguise of one, and reporting one result.

Even without the sub-testsuite approach, I wonder could something such as the following be more descriptive when looking at results?

static struct unit_test_suite ipsec_proto_testsuite  = {
	.suite_name = "IPsec Proto Unit Test Suite",
	.setup = ipsec_proto_testsuite_setup,
	.unit_test_cases = {
		< Inbound known vector test cases as before >
		
		TEST_CASE_NAMED_WITH_DATA(
			"Combination test (AES-GCM 128)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_display_list, &aead_list[0]),
		TEST_CASE_NAMED_WITH_DATA(
			"Combination test (AES-GCM 192)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_display_list, &aead_list[1]),
		TEST_CASE_NAMED_WITH_DATA(
			"Combination test (AES-GCM 256)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_display_list, &aead_list[2]),

		TEST_CASE_NAMED_WITH_DATA(
			"IV Generation (AES-GCM 128)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_iv_gen, &aead_list[0]),

		etc.
}

static int
test_ipsec_proto_display_list(const void *data)

{
	struct ipsec_test_flags flags;

	memset(&flags, 0, sizeof(flags));

	flags.display_alg = true;

	return test_ipsec_proto(&flags, (const struct crypto_param *)data);
}

static int
test_ipsec_proto(const struct ipsec_test_flags *flags, const struct crypto_param *data)

{
	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
	unsigned int i, nb_pkts = 1, pass_cnt = 0;
	int ret;

	if (flags->iv_gen)
		nb_pkts = IPSEC_TEST_PACKETS_MAX;

	
	test_ipsec_td_prepare(&data,
				      NULL,
				      flags,
				      td_outb,
				      nb_pkts);

< the rest of the function as before but without the loop, using data instead of looping aead values >

Thanks,
Ciara

Quoted 43 lines
Quoted 43 lines

Thanks,
Ciara

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[],

Quoted 8 lines
app/test/test_cryptodev.c +8 -0
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      nb_pkts);
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts,

true,

Quoted 29 lines
app/test/test_cryptodev.c +29 -0
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+

<snip>

#17 lore raw

Re: [dpdk-dev] [PATCH v3 2/5] test/crypto: add combined mode tests

HI Ciara,

Please see inline.

Thanks,
Anoob

Quoted 159 lines

External Email

----------------------------------------------------------------------
Hi Anoob,

Quoted 9 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 11:05
To: Power, Ciara <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>;

Hemant

Quoted 73 lines

Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: RE: [PATCH v3 2/5] test/crypto: add combined mode tests

Hi Ciara,

Please see inline.

Thanks,
Anoob

Quoted 31 lines

External Email

---------------------------------------------------------------------
-
Hi Anoob,

Quoted 15 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 3 September 2021 05:47
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v3 2/5] test/crypto: add combined mode tests

Quoted 2 lines

Add framework to test IPsec features with all supported combinations of

ciphers.

Quoted 4 lines

---

<snip>

Quoted 12 lines

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[], · line 9034

Quoted 7 lines
app/test/test_cryptodev.c +7 -0
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags) {
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+

Is this testcase actually running multiple testcases under the hood? I wonder could it be suited to use a sub-testsuite structure to bring the testcase results up to the top level, as done with cryptodev blockcipher

tests.

Quoted 1 line

Have you considered this approach?

[Anoob] The idea behind this framework is to test an IPsec feature (like UDP
encapsulation) without tying it to any specific algorithm. So what this does is, it loops over a list of possible combinations and then runs the test for each combination. The test would be like this,

1. Do outbound processing to generate encrypted packet 2. Basic checks or validation as required for the test (for example, with UDP encapsulation, we would validate UDP hdr in the processed packet).
3. Any manipulations required (like for ICV corruption negative test)
4. Do inbound processing to get decrypted packet 5. Validate results based on the type of test (ICV corruption would give expect an error while normal tests would have the operation return original plain text packet)

Quoted 5 lines

It's actually the array (aead_list) and this loop which initiates the test to be run for all algos. And, since we are not having static vectors for each test case, this approach seemed more straightforward. Do you think sub-testsuite makes more sense here?

Thanks for the explanation.
I still think having each test reporting its individual result to the top level provides more clarity when running tests, rather than having multiple tests being run under the disguise of one, and reporting one result.

Even without the sub-testsuite approach, I wonder could something such as the following be more descriptive when looking at results?

static struct unit_test_suite ipsec_proto_testsuite  = {
	.suite_name = "IPsec Proto Unit Test Suite",
	.setup = ipsec_proto_testsuite_setup,
	.unit_test_cases = {
		< Inbound known vector test cases as before >

		TEST_CASE_NAMED_WITH_DATA(
			"Combination test (AES-GCM 128)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_display_list, &aead_list[0]),
		TEST_CASE_NAMED_WITH_DATA(
			"Combination test (AES-GCM 192)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_display_list, &aead_list[1]),
		TEST_CASE_NAMED_WITH_DATA(
			"Combination test (AES-GCM 256)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_display_list, &aead_list[2]),

		TEST_CASE_NAMED_WITH_DATA(
			"IV Generation (AES-GCM 128)",
			ut_setup_security, ut_teardown,
			test_ipsec_proto_iv_gen, &aead_list[0]),

		etc.
}

static int

test_ipsec_proto_display_list(const void *data) {
	struct ipsec_test_flags flags;

	memset(&flags, 0, sizeof(flags));

	flags.display_alg = true;

	return test_ipsec_proto(&flags, (const struct crypto_param *)data); }

static int
test_ipsec_proto(const struct ipsec_test_flags *flags, const struct

crypto_param *data) {
	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
	unsigned int i, nb_pkts = 1, pass_cnt = 0;
	int ret;

	if (flags->iv_gen)
		nb_pkts = IPSEC_TEST_PACKETS_MAX;


	test_ipsec_td_prepare(&data,
				      NULL,
				      flags,
				      td_outb,
				      nb_pkts);
Quoted 2 lines

< the rest of the function as before but without the loop, using data instead of looping aead values >

[Anoob] Your suggestion is to not have the loop walk through aead_list but instead let the list be defined by test-suite, right?

I agree regarding result reporting part. Squashing all results into one may not be the most desired. But then I didn't want to bombard with large number of prints from IPsec tests, either.

The only issue I see is with a long list of tests. We are actually preparing chained mode tests which would have combinations. Like, if we have AES-CBC & 3DES-CBC supported as ciphers and NULL, SHA1, SHA2 as auth supported, then we are talking about 6 combinations. And currently we have the following tests,

1. ICV corruption
2. IV generation
3. UDP encapsulation

In pipeline (submitted with proposals)
1. Soft expiry
2. Hard expiry
3. IP hdr verify
4. UDP port verify

And if we consider some of the more fundamental tests that we would add like
1. AH
2. Transport
3. Tunnel (IPv4 in IPv4)
4. Tunnel (IPv4 in IPv6)
5. Tunnel (IPv6 in IPv4)
6. Tunnel (IPv6 in IPv6)

Each of the above would become more like test suite on its own and then we would have the list just duplicated for each kind of feature test. But then, let me check an alternate approach. More like,

1. Let the common test suite setup function set flags etc to denote the IPsec feature (be it ICV corruption or UDP encap)
2. The list of tests (cipher combinations) would be common for all feature tests.

Would something like this work?

#18 lore raw

PATCH v3 3/5 test/crypto: add lookaside IPsec ICV corrupt test case

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Adding lookaside IPsec ICV corrupt test case.

---
 app/test/test_cryptodev.c                | 16 ++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 30 ++++++++++++++++++++----------
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 37 insertions(+), 10 deletions(-)
app/test/test_cryptodev.c +16 -0
index d89307d..488daed 100644
@@ -9082,6 +9082,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.icv_corrupt = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -13991,6 +14003,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			"Combined test alg list",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
+		TEST_CASE_NAMED_ST(
+			"Negative test: ICV corruption",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_err_icv_corrupt),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +20 -10
index d08e093..aebbe66 100644
@@ -175,9 +175,12 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 		memcpy(td_inb[i].output_text.data, td_outb[i].input_text.data,
 		       td_outb[i].input_text.len);
 		td_inb[i].output_text.len = td_outb->input_text.len;
-	}
 
-	RTE_SET_USED(flags);
+		if (flags->icv_corrupt) {
+			int icv_pos = td_inb[i].input_text.len - 4;
+			td_inb[i].input_text.data[icv_pos] += 1;
+		}
+	}
 }
 
 void
@@ -217,6 +220,11 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
 	uint32_t skip, len = rte_pktmbuf_pkt_len(m);
 
+	/* For negative tests, no need to do verification */
+	if (flags->icv_corrupt &&
+	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
+		return TEST_SUCCESS;
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
@@ -241,8 +249,6 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 		return TEST_FAILED;
 	}
 
-	RTE_SET_USED(flags);
-
 	return TEST_SUCCESS;
 }
 
@@ -299,13 +305,17 @@ test_ipsec_status_check(struct rte_crypto_op *op,
 {
 	int ret = TEST_SUCCESS;
 
-	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
-		printf("Security op processing failed\n");
-		ret = TEST_FAILED;
+	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->icv_corrupt) {
+		if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+			printf("ICV corruption test case failed\n");
+			ret = TEST_FAILED;
+		}
+	} else {
+		if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+			printf("Security op processing failed\n");
+			ret = TEST_FAILED;
+		}
 	}
 
-	RTE_SET_USED(flags);
-	RTE_SET_USED(dir);
-
 	return ret;
 }
app/test/test_cryptodev_security_ipsec.h +1 -0
index cbb3ee4..134fc3a 100644
@@ -49,6 +49,7 @@ struct ipsec_test_data {
 
 struct ipsec_test_flags {
 	bool display_alg;
+	bool icv_corrupt;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
#19 lore raw

PATCH v3 4/5 test/crypto: add IV gen tests

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add test cases to verify IV generated by PMD.

---
 app/test/test_cryptodev.c                | 19 ++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 52 ++++++++++++++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 72 insertions(+)
app/test/test_cryptodev.c +19 -0
index 488daed..71e6c1a 100644
@@ -9032,6 +9032,9 @@ test_ipsec_proto_all(const struct ipsec_test_flags *flags)
 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
 	int ret;
 
+	if (flags->iv_gen)
+		nb_pkts = IPSEC_TEST_PACKETS_MAX;
+
 	for (i = 0; i < RTE_DIM(aead_list); i++) {
 		test_ipsec_td_prepare(&aead_list[i],
 				      NULL,
@@ -9082,6 +9085,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_iv_gen(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.iv_gen = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags;
@@ -14004,6 +14019,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
 		TEST_CASE_NAMED_ST(
+			"IV generation",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_iv_gen),
+		TEST_CASE_NAMED_ST(
 			"Negative test: ICV corruption",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_err_icv_corrupt),
app/test/test_cryptodev_security_ipsec.c +52 -0

76 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +1 -0
index 134fc3a..d2ec63f 100644
@@ -50,6 +50,7 @@ struct ipsec_test_data {
 struct ipsec_test_flags {
 	bool display_alg;
 	bool icv_corrupt;
+	bool iv_gen;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
#20 lore raw

PATCH v3 5/5 test/crypto: add UDP encapsulation test cases

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Adding UDP encapsulation test cases.

---
 app/test/test_cryptodev.c                | 19 +++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 28 ++++++++++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 48 insertions(+)
app/test/test_cryptodev.c +19 -0
index 71e6c1a..b7c5270 100644
@@ -8898,6 +8898,9 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
 
+	if (flags->udp_encap)
+		ipsec_xform.options.udp_encap = 1;
+
 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
 	if (sec_cap == NULL)
 		return TEST_SKIPPED;
@@ -9109,6 +9112,18 @@ test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_udp_encap(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.udp_encap = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -14023,6 +14038,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_iv_gen),
 		TEST_CASE_NAMED_ST(
+			"UDP encapsulation",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_udp_encap),
+		TEST_CASE_NAMED_ST(
 			"Negative test: ICV corruption",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_err_icv_corrupt),
app/test/test_cryptodev_security_ipsec.c +28 -0
index 78c7f3a..5b54996 100644
@@ -7,6 +7,7 @@
 #include <rte_esp.h>
 #include <rte_ip.h>
 #include <rte_security.h>
+#include <rte_udp.h>
 
 #include "test.h"
 #include "test_cryptodev_security_ipsec.h"
@@ -183,6 +184,9 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 			int icv_pos = td_inb[i].input_text.len - 4;
 			td_inb[i].input_text.data[icv_pos] += 1;
 		}
+
+		if (flags->udp_encap)
+			td_inb[i].ipsec_xform.options.udp_encap = 1;
 	}
 }
 
@@ -268,6 +272,30 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
 		return TEST_SUCCESS;
 
+	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
+	   flags->udp_encap) {
+		const struct rte_ipv4_hdr *iph4;
+		const struct rte_ipv6_hdr *iph6;
+
+		if (td->ipsec_xform.tunnel.type ==
+				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
+			iph4 = (const struct rte_ipv4_hdr *)output_text;
+			if (iph4->next_proto_id != IPPROTO_UDP) {
+				printf("UDP header is not found\n");
+				return TEST_FAILED;
+			}
+		} else {
+			iph6 = (const struct rte_ipv6_hdr *)output_text;
+			if (iph6->proto != IPPROTO_UDP) {
+				printf("UDP header is not found\n");
+				return TEST_FAILED;
+			}
+		}
+
+		len -= sizeof(struct rte_udp_hdr);
+		output_text += sizeof(struct rte_udp_hdr);
+	}
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
app/test/test_cryptodev_security_ipsec.h +1 -0
index d2ec63f..e1645f4 100644
@@ -51,6 +51,7 @@ struct ipsec_test_flags {
 	bool display_alg;
 	bool icv_corrupt;
 	bool iv_gen;
+	bool udp_encap;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
#21 lore raw

v4 cover Add lookaside IPsec tests

In reply to Anoob Joseph

Add lookaside IPsec functional tests. Known vector tests and combined mode framework is added.

Known vectors are outbound vectors based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum computed correctly. And they have following properties,
1. ESP
2. Tunnel mode
3. IPv4
4. IPv4 tunnel

Known vector tests for inbound operation would generate test vectors by reversing outbound known vectors. The input_text would become encrypted packet and output_text would be the plain packet. Tests would then validate the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers supported by the PMD. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

Four test cases use combined mode,
1. Display algo coverage and basic in + out tests
2. Negative test for ICV corruption
3. IV generation
4. UDP encapsulation

IV generation test case compares IV generated for a batch of packets and returns failure if IV is repeated.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode
2. IPv6
3. Transport
4. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k
3. crypto_cn9k

Changes in v4:
- Fixed lack of device stop in case capability check fails (comment from Ciara)
- Rebased and updated release notes

Changes in v3
- Added UDP encapsulation tests

Changes in v2
- Dropped outbound known vector tests as lookaside protocol would require IV generated by PMD. The tests would be introduced with spec change to allow user to specify IV.
- Added IV generation tests
- Minor fixes in combined mode tests to handle multiple packets

Anoob Joseph (2):
test/crypto: add lookaside IPsec tests
test/crypto: add combined mode tests

Tejasree Kondoj (3):
test/crypto: add lookaside IPsec ICV corrupt test case test/crypto: add IV gen tests
test/crypto: add UDP encapsulation test cases

 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 351 ++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 401 +++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           | 119 ++++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++
 doc/guides/rel_notes/release_21_11.rst             |   7 +
 7 files changed, 1206 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
Signature · 1 line
2.7.4
#22 lore raw

PATCH v4 1/5 test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are added.

Cipher list: AES-GCM 128, 192 & 256

---
 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 232 +++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           |  66 +++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++++++
 6 files changed, 838 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
app/test/meson.build +1 -0
index a761168..f144d8b 100644
@@ -38,6 +38,7 @@ test_sources = files(
         'test_cryptodev.c',
         'test_cryptodev_asym.c',
         'test_cryptodev_blockcipher.c',
+        'test_cryptodev_security_ipsec.c',
         'test_cryptodev_security_pdcp.c',
         'test_cycles.c',
         'test_debug.c',
app/test/test.h +6 -0
index c3b2a87..7115edf 100644
@@ -124,6 +124,12 @@ struct unit_test_case {
 #define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \
 		{ setup, teardown, NULL, testcase, #testcase, 1, data }
 
+#define TEST_CASE_NAMED_ST(name, setup, teardown, testcase) \
+		{ setup, teardown, NULL, testcase, name, 1, NULL }
+
+#define TEST_CASE_NAMED_WITH_DATA(name, setup, teardown, testcase, data) \
+		{ setup, teardown, NULL, testcase, name, 1, data }
+
 #define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL }
 
 #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
app/test/test_cryptodev.c +232 -0

274 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.c new file +212 -0

212 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h new file +66 -0

66 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec_test_vectors.h new file +321 -0

321 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v4 1/5
#23 lore raw

Re: [dpdk-dev] [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Hi Anoob,
Few minor comments, Please see inline.
Apart from that,

Quoted 1 line

Update title as
Test/crypto: add lookaside IPsec cases.

app/test/test_cryptodev.c test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, · line 135

Quoted 7 lines
app/test/test_cryptodev.c +7 -0
+static int
+security_proto_supported(enum rte_security_session_action_type action,
+	enum rte_security_session_protocol proto);
+
+static int
+dev_configure_and_start(uint64_t ff_disable);
+

Do we really need to forward declare?

Quoted 19 lines

static struct rte_mbuf *
setup_test_string(struct rte_mempool *mpool,

app/test/test_cryptodev.c +11 -0
 		const char *string, size_t len, uint8_t blocksize)
@@ -753,6 +763,43 @@ crypto_gen_testsuite_setup(void)
 
 #ifdef RTE_LIB_SECURITY
 static int
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+	int ret = 0;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 781

Quoted 5 lines
app/test/test_cryptodev.c +5 -0
+				"testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */

Update comment like
/*Reconfigure to enable security and disable crypto */ BTW, shouldn't this be dev_configure_and_start(0) Why is sym and asym disabled here?

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 783

Quoted 3 lines
(quoted diff) +1 -0
+	dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO

|

app/test/test_cryptodev.c +1 -0
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);

Return value not taken care here.

Quoted 11 lines
app/test/test_cryptodev.c +3 -0
+
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +3 -0
+
+	if (security_proto_supported(
+

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,

(quoted diff) +2 -0
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec

Proto "

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 797

Quoted 6 lines
app/test/test_cryptodev.c +6 -0
+				"test not met\n");
+		ret = TEST_SKIPPED;
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);

Add a comment that the device will be started again in ut_setup_security()

Quoted 10 lines
app/test/test_cryptodev.c +10 -0
+
+		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
+					      res_d_tmp, silent);
+		if (ret != TEST_SUCCESS)
+			goto crypto_op_free;
+
+		rte_crypto_op_free(ut_params->op);
+		ut_params->op = NULL;
+
+		rte_pktmbuf_free(ut_params->ibuf);

app/test/test_cryptodev.c test_PDCP_SDAP_PROTO_decap_all(void) · line 9049

Quoted 10 lines
app/test/test_cryptodev.c +10 -0
+		ut_params->ibuf = NULL;
+	}
+
+crypto_op_free:
+	rte_crypto_op_free(ut_params->op);
+	ut_params->op = NULL;
+
+	rte_pktmbuf_free(ut_params->ibuf);
+	ut_params->ibuf = NULL;
+

Above four lines are getting executed again in the success cases.

#24 lore raw

Re: [dpdk-dev] [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Hi Akhil,

Thanks for the review. Please see inline.

Thanks,
Anoob

Quoted 14 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, September 21, 2021 9:38 PM
To: Anoob Joseph <[email protected]>; Declan Doherty <[email protected]>; Fan Zhang <[email protected]>; Konstantin Ananyev <[email protected]>; Ciara Power <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Radu Nicolau <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: RE: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Quoted 7 lines

Hi Anoob,
Few minor comments, Please see inline. Apart from that,

Quoted 1 line

Update title as
Test/crypto: add lookaside IPsec cases.

[Anoob] Will update so in v5

Quoted 11 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+static int
+security_proto_supported(enum rte_security_session_action_type

action,

app/test/test_cryptodev.c test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, · line 135

Quoted 5 lines
app/test/test_cryptodev.c +5 -0
+	enum rte_security_session_protocol proto);
+
+static int
+dev_configure_and_start(uint64_t ff_disable);
+

Do we really need to forward declare?

[Anoob] I've kept 'ipsec_proto_testsuite_setup' close to other rte_security test suite setups. The function, dev_configure_and_start() is defined later but I need to use it to enable SECURITY before doing capability check. Only other option is to move around code.

Quoted 21 lines
Quoted 21 lines

static struct rte_mbuf *
setup_test_string(struct rte_mempool *mpool,

app/test/test_cryptodev.c +12 -0
 		const char *string, size_t len, uint8_t blocksize) @@ -753,6
+763,43 @@ crypto_gen_testsuite_setup(void)
 
 #ifdef RTE_LIB_SECURITY
 static int
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+	int ret = 0;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c +1 -0
+				"testsuite not met\n");
Quoted 8 lines

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 781

Quoted 4 lines
app/test/test_cryptodev.c +4 -0
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */

Update comment like
/*Reconfigure to enable security and disable crypto */ BTW, shouldn't this be dev_configure_and_start(0) Why is sym and asym disabled here?

[Anoob] Will update the comments in v5. Sym & asym are not required for security tests. But then, I can keep ff_disable as 0. It won't affect anything.

Quoted 9 lines
Quoted 2 lines

+

dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPT
O

Quoted 2 lines

|
+

	RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);

Return value not taken care here.

[Anoob] Will fix in v5.

Quoted 13 lines
Quoted 13 lines
app/test/test_cryptodev.c +3 -0
+
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +3 -0
+
+	if (security_proto_supported(
+

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,

(quoted diff) +2 -0
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec

Proto "

Quoted 8 lines

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 797

Quoted 6 lines
app/test/test_cryptodev.c +6 -0
+				"test not met\n");
+		ret = TEST_SKIPPED;
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);

Add a comment that the device will be started again in ut_setup_security()

[Anoob] Will update so in v5.

Quoted 15 lines
Quoted 15 lines
app/test/test_cryptodev.c +14 -0
+
+		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
+					      res_d_tmp, silent);
+		if (ret != TEST_SUCCESS)
+			goto crypto_op_free;
+
+		rte_crypto_op_free(ut_params->op);
+		ut_params->op = NULL;
+
+		rte_pktmbuf_free(ut_params->ibuf);
+		ut_params->ibuf = NULL;
+	}
+
+crypto_op_free:
Quoted 8 lines

app/test/test_cryptodev.c test_PDCP_SDAP_PROTO_decap_all(void) · line 9042

Quoted 6 lines
app/test/test_cryptodev.c +6 -0
+	rte_crypto_op_free(ut_params->op);
+	ut_params->op = NULL;
+
+	rte_pktmbuf_free(ut_params->ibuf);
+	ut_params->ibuf = NULL;
+

Above four lines are getting executed again in the success cases.

[Anoob] rte_crypto_op_free() has a NULL check. So executing this for success cases is alright. I believe UT already does it this way for certain cases. If you check PDCP test cases, it has a free in the test case and there would be one free in ut_teardown() also.

#25 lore raw

Re: [dpdk-dev] [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

In reply to Anoob Joseph

Hi Anoob,

One comment inline.

Thanks,
Ciara

Quoted 29 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 17 September 2021 14:15
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are added.

Cipher list: AES-GCM 128, 192 & 256

---

app/test/meson.build                               |   1 +
app/test/test.h                                    |   6 +
app/test/test_cryptodev.c                          | 232 +++++++++++++++
app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
app/test/test_cryptodev_security_ipsec.h           |  66 +++++
.../test_cryptodev_security_ipsec_test_vectors.h   | 321

+++++++++++++++++++++

<snip>

Quoted 33 lines

#ifdef RTE_LIB_SECURITY
static int

app/test/test_cryptodev.c +11 -0
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+	int ret = 0;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c +6 -0
+				"testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */
+	dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO

|

app/test/test_cryptodev.c +4 -0
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);
+
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +3 -0
+
+	if (security_proto_supported(
+

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,

(quoted diff) +2 -0
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec

Proto "

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 793

Quoted 2 lines
app/test/test_cryptodev.c +2 -0
+				"test not met\n");
+		ret = TEST_SKIPPED;

The device still needs to be stopped here I believe if capabilities not met.

Quoted 8 lines
app/test/test_cryptodev.c +8 -0
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);
+
+	return ret;
+}
+
#26 lore raw

Re: [dpdk-dev] [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Hi Ciara,

Please see inline.

Thanks,
Anoob

Quoted 84 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Thursday, September 23, 2021 4:09 PM
To: Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

External Email

----------------------------------------------------------------------
Hi Anoob,

One comment inline.

Thanks,
Ciara

Quoted 29 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 17 September 2021 14:15
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are added.

Cipher list: AES-GCM 128, 192 & 256

---

app/test/meson.build                               |   1 +
app/test/test.h                                    |   6 +
app/test/test_cryptodev.c                          | 232 +++++++++++++++
app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
app/test/test_cryptodev_security_ipsec.h           |  66 +++++
.../test_cryptodev_security_ipsec_test_vectors.h   | 321

+++++++++++++++++++++

<snip>

Quoted 29 lines

#ifdef RTE_LIB_SECURITY
static int

app/test/test_cryptodev.c +11 -0
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+	int ret = 0;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c +6 -0
+				"testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */
+	dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO

|

app/test/test_cryptodev.c +4 -0
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);
+
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +3 -0
+
+	if (security_proto_supported(
+
Quoted 8 lines

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 793

Quoted 6 lines

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,

(quoted diff) +2 -0
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec

Proto "

app/test/test_cryptodev.c +2 -0
+				"test not met\n");
+		ret = TEST_SKIPPED;

The device still needs to be stopped here I believe if capabilities not met.

[Anoob] Here we are just setting return value. Function returns below only (after stopping device).

Quoted 9 lines
Quoted 9 lines
app/test/test_cryptodev.c +8 -0
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);
+
+	return ret;
+}
+
#27 lore raw

Re: [dpdk-dev] [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Hi Anoob,

Quoted 116 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Thursday 23 September 2021 12:09
To: Power, Ciara <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: RE: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Hi Ciara,

Please see inline.

Thanks,
Anoob

Quoted 17 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Thursday, September 23, 2021 4:09 PM
To: Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

External Email

Quoted 23 lines

----------------------------------------------------------------------
Hi Anoob,

One comment inline.

Thanks,
Ciara

Quoted 15 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 17 September 2021 14:15
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are

added.

Quoted 45 lines
Quoted 14 lines

Cipher list: AES-GCM 128, 192 & 256

---

app/test/meson.build                               |   1 +
app/test/test.h                                    |   6 +
app/test/test_cryptodev.c                          | 232 +++++++++++++++
app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
app/test/test_cryptodev_security_ipsec.h           |  66 +++++
.../test_cryptodev_security_ipsec_test_vectors.h   | 321

+++++++++++++++++++++

<snip>

Quoted 29 lines

#ifdef RTE_LIB_SECURITY
static int

app/test/test_cryptodev.c +11 -0
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+	int ret = 0;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c +6 -0
+				"testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */
+	dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO

|

app/test/test_cryptodev.c +4 -0
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);
+
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +3 -0
+
+	if (security_proto_supported(
+
Quoted 8 lines

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 793

Quoted 6 lines

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,

(quoted diff) +2 -0
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec

Proto "

app/test/test_cryptodev.c +2 -0
+				"test not met\n");
+		ret = TEST_SKIPPED;

The device still needs to be stopped here I believe if capabilities not met.

Quoted 3 lines

[Anoob] Here we are just setting return value. Function returns below only (after stopping device).

Apologies, yes I missed that. Thanks!

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
app/test/test_cryptodev.c +8 -0
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);
+
+	return ret;
+}
+
#28 lore raw

Re: [dpdk-dev] [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Hi Ciara,

I'm planning to send next version addressing Akhil's comments. Can you review and ack patches if you don't have further comments?

Thanks,
Anoob

Quoted 154 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Thursday, September 23, 2021 4:57 PM
To: Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

External Email

----------------------------------------------------------------------
Hi Anoob,

Quoted 9 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Thursday 23 September 2021 12:09
To: Power, Ciara <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>;

Hemant

Quoted 109 lines

Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: RE: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Hi Ciara,

Please see inline.

Thanks,
Anoob

Quoted 17 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Thursday, September 23, 2021 4:09 PM
To: Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

External Email

Quoted 25 lines

---------------------------------------------------------------------
-
Hi Anoob,

One comment inline.

Thanks,
Ciara

Quoted 16 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 17 September 2021 14:15
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

Added test case for lookaside IPsec. Inbound known vector tests are

added.

Quoted 45 lines
Quoted 14 lines

Cipher list: AES-GCM 128, 192 & 256

---

app/test/meson.build                               |   1 +
app/test/test.h                                    |   6 +
app/test/test_cryptodev.c                          | 232 +++++++++++++++
app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
app/test/test_cryptodev_security_ipsec.h           |  66 +++++
.../test_cryptodev_security_ipsec_test_vectors.h   | 321

+++++++++++++++++++++

<snip>

Quoted 29 lines

#ifdef RTE_LIB_SECURITY
static int

app/test/test_cryptodev.c +11 -0
+ipsec_proto_testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct rte_cryptodev_info dev_info;
+	int ret = 0;
+
+	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec

Proto "

app/test/test_cryptodev.c +6 -0
+				"testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	/* Reconfigure to enable security */
+	dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO

|

app/test/test_cryptodev.c +4 -0
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);
+
+	/* Set action type */
+	ut_params->type =

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;

app/test/test_cryptodev.c +3 -0
+
+	if (security_proto_supported(
+
Quoted 8 lines

app/test/test_cryptodev.c crypto_gen_testsuite_setup(void) · line 793

Quoted 6 lines

RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,

(quoted diff) +2 -0
+			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+		RTE_LOG(INFO, USER1, "Capability requirements for IPsec

Proto "

app/test/test_cryptodev.c +2 -0
+				"test not met\n");
+		ret = TEST_SKIPPED;

The device still needs to be stopped here I believe if capabilities not met.

Quoted 3 lines

[Anoob] Here we are just setting return value. Function returns below only (after stopping device).

Apologies, yes I missed that. Thanks!

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
app/test/test_cryptodev.c +8 -0
+	}
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);
+
+	return ret;
+}
+
#30 lore raw

PATCH v4 2/5 test/crypto: add combined mode tests

In reply to Anoob Joseph

Add framework to test IPsec features with all supported combinations of ciphers.

---
 app/test/test_cryptodev.c                |  73 +++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.c | 107 +++++++++++++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.h |  52 ++++++++++++++-
 3 files changed, 223 insertions(+), 9 deletions(-)
app/test/test_cryptodev.c +69 -4
index 9c7875c..7fd246e 100644
@@ -8904,7 +8904,8 @@ static int
 test_ipsec_proto_process(const struct ipsec_test_data td[],
 			 struct ipsec_test_data res_d[],
 			 int nb_td,
-			 bool silent)
+			 bool silent,
+			 const struct ipsec_test_flags *flags)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -9021,7 +9022,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 		/* Process crypto operation */
 		process_crypto_request(dev_id, ut_params->op);
 
-		ret = test_ipsec_status_check(ut_params->op, dir);
+		ret = test_ipsec_status_check(ut_params->op, flags, dir);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -9029,7 +9030,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 			res_d_tmp = &res_d[i];
 
 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
-					      res_d_tmp, silent);
+					      res_d_tmp, silent, flags);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -9057,11 +9058,71 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 static int
 test_ipsec_proto_known_vec_inb(const void *td_outb)
 {
+	struct ipsec_test_flags flags;
 	struct ipsec_test_data td_inb;
 
+	memset(&flags, 0, sizeof(flags));
+
 	test_ipsec_td_in_from_out(td_outb, &td_inb);
 
-	return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
+}
+
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags)
+{
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      nb_pkts);
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+
+static int
+test_ipsec_proto_display_list(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.display_alg = true;
+
+	return test_ipsec_proto_all(&flags);
 }
 
 static int
@@ -13971,6 +14032,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_ST(
+			"Combined test alg list",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_display_list),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +103 -4

153 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +51 -1

74 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v4 2/5
#31 lore raw

Re: [dpdk-dev] [PATCH v4 2/5] test/crypto: add combined mode tests

Quoted 1 line

Subject: [PATCH v4 2/5] test/crypto: add combined mode tests

Title: test/crypto: add combined mode IPSec cases

Quoted 1 line

In description explain the meaning of combined mode. Also mention that the encap and decap are done one after the other, Hence known test vectors are not required.

Apart from that,

Quoted 6 lines

Add framework to test IPsec features with all supported combinations of ciphers.

#32 lore raw

Re: [dpdk-dev] [PATCH v4 2/5] test/crypto: add combined mode tests

In reply to Anoob Joseph

HI Anoob,

Quoted 47 lines · Anoob Joseph

Add framework to test IPsec features with all supported combinations of ciphers.

---
  app/test/test_cryptodev.c                |  73 +++++++++++++++++++--
  app/test/test_cryptodev_security_ipsec.c | 107 +++++++++++++++++++++++++++++--
  app/test/test_cryptodev_security_ipsec.h |  52 ++++++++++++++-
  3 files changed, 223 insertions(+), 9 deletions(-)
app/test/test_cryptodev.c +4 -3
index 9c7875c..7fd246e 100644
@@ -8904,7 +8904,8 @@ static int
  test_ipsec_proto_process(const struct ipsec_test_data td[],
  			 struct ipsec_test_data res_d[],
  			 int nb_td,
-			 bool silent)
+			 bool silent,
+			 const struct ipsec_test_flags *flags)
  {
  	struct crypto_testsuite_params *ts_params = &testsuite_params;
  	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -9021,7 +9022,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
  		/* Process crypto operation */
  		process_crypto_request(dev_id, ut_params->op);
 
-		ret = test_ipsec_status_check(ut_params->op, dir);
+		ret = test_ipsec_status_check(ut_params->op, flags, dir);
  		if (ret != TEST_SUCCESS)
  			goto crypto_op_free;
 
@@ -9029,7 +9030,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
  			res_d_tmp = &res_d[i];
 
  		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
-					      res_d_tmp, silent);
+					      res_d_tmp, silent, flags);
  		if (ret != TEST_SUCCESS)
  			goto crypto_op_free;
 
@@ -9057,11 +9058,71 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
  static int
  test_ipsec_proto_known_vec_inb(const void *td_outb)

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[], · line 9068

Quoted 10 lines
app/test/test_cryptodev.c +4 -1
  {
+	struct ipsec_test_flags flags;
  	struct ipsec_test_data td_inb;
 
+	memset(&flags, 0, sizeof(flags));
+
  	test_ipsec_td_in_from_out(td_outb, &td_inb);
 
-	return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);

In most places, you have hardcoded this silent flag - this is for debug prints.

Will you please driver it from some macro or variable or log-level, where it can be changed easily.

#33 lore raw

Re: [dpdk-dev] [EXT] Re: [PATCH v4 2/5] test/crypto: add combined mode tests

Hi Hemant,

Please see inline.

Thanks,
Anoob

Quoted 80 lines

-----Original Message-----
From: Hemant Agrawal <[email protected]>
Sent: Friday, September 24, 2021 12:54 PM
To: Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; Declan Doherty <[email protected]>; Fan Zhang <[email protected]>; Konstantin Ananyev <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Radu Nicolau <[email protected]>; Ciara Power <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [EXT] Re: [dpdk-dev] [PATCH v4 2/5] test/crypto: add combined mode tests

External Email

----------------------------------------------------------------------
HI Anoob,

Quoted 9 lines · Anoob Joseph

Add framework to test IPsec features with all supported combinations of ciphers.

---
  app/test/test_cryptodev.c                |  73 +++++++++++++++++++--
  app/test/test_cryptodev_security_ipsec.c | 107

+++++++++++++++++++++++++++++--

Quoted 8 lines
  app/test/test_cryptodev_security_ipsec.h |  52 ++++++++++++++-
  3 files changed, 223 insertions(+), 9 deletions(-)
app/test/test_cryptodev.c +0 -0
index 9c7875c..7fd246e 100644

app/test/test_cryptodev.c static int

Quoted 10 lines
app/test/test_cryptodev.c +2 -2
@@ -8904,7 +8904,8 @@ static int
  test_ipsec_proto_process(const struct ipsec_test_data td[],
  			 struct ipsec_test_data res_d[],
  			 int nb_td,
-			 bool silent)
+			 bool silent,
+			 const struct ipsec_test_flags *flags)
  {
  	struct crypto_testsuite_params *ts_params = &testsuite_params;
  	struct crypto_unittest_params *ut_params = &unittest_params; @@
-9021,7 +9022,7 @@ test_ipsec_proto_process(const struct ipsec_test_data

td[],

app/test/test_cryptodev.c test_ipsec_proto_process(const struct

Quoted 9 lines
  		/* Process crypto operation */
  		process_crypto_request(dev_id, ut_params->op);
app/test/test_cryptodev.c +1 -1
-		ret = test_ipsec_status_check(ut_params->op, dir);
+		ret = test_ipsec_status_check(ut_params->op, flags, dir);
  		if (ret != TEST_SUCCESS)
  			goto crypto_op_free;
@@ -9029,7 +9030,7 @@ test_ipsec_proto_process(const struct

ipsec_test_data td[],

app/test/test_cryptodev.c test_ipsec_proto_process(const struct

Quoted 9 lines
app/test/test_cryptodev.c +1 -1
  			res_d_tmp = &res_d[i];
 
  		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
-					      res_d_tmp, silent);
+					      res_d_tmp, silent, flags);
  		if (ret != TEST_SUCCESS)
  			goto crypto_op_free;
 
@@ -9057,11 +9058,71 @@ test_ipsec_proto_process(const struct

ipsec_test_data td[],

Quoted 10 lines
app/test/test_cryptodev.c +3 -0
  static int
  test_ipsec_proto_known_vec_inb(const void *td_outb)
  {
+	struct ipsec_test_flags flags;
  	struct ipsec_test_data td_inb;
 
+	memset(&flags, 0, sizeof(flags));
+
  	test_ipsec_td_in_from_out(td_outb, &td_inb);
 
Quoted 8 lines

app/test/test_cryptodev.c test_ipsec_proto_process(const struct ipsec_test_data td[], · line 9068

Quoted 2 lines
app/test/test_cryptodev.c +1 -1
-	return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);

In most places, you have hardcoded this silent flag - this is for debug prints.

Will you please driver it from some macro or variable or log-level, where it can be changed easily.

[Anoob] Currently, for known vector tests, we have "silent" set as false to have more verbose output by default. For combined mode, since we attempt multiple ciphers, there would be lot of prints. Hence we kept "silent" flag as true to disable prints for such cases. The idea is, if a developer wants to quickly analyze one combined mode test case, he can do so by changing silent flag for just that. Enabling it universally could dump more info than desired.

Making it a global flag would mean, we would have same kind of prints with known vector & combined mode (which attempts combinations). Do you think a global setting is better? If yes, what do you recommend? A custom flag or RTE_LOG?

#34 lore raw

PATCH v4 3/5 test/crypto: add lookaside IPsec ICV corrupt test case

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Adding lookaside IPsec ICV corrupt test case.

---
 app/test/test_cryptodev.c                | 16 ++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 30 ++++++++++++++++++++----------
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 37 insertions(+), 10 deletions(-)
app/test/test_cryptodev.c +16 -0
index 7fd246e..19694f8 100644
@@ -9126,6 +9126,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.icv_corrupt = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -14036,6 +14048,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			"Combined test alg list",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
+		TEST_CASE_NAMED_ST(
+			"Negative test: ICV corruption",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_err_icv_corrupt),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +20 -10
index d08e093..aebbe66 100644
@@ -175,9 +175,12 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 		memcpy(td_inb[i].output_text.data, td_outb[i].input_text.data,
 		       td_outb[i].input_text.len);
 		td_inb[i].output_text.len = td_outb->input_text.len;
-	}
 
-	RTE_SET_USED(flags);
+		if (flags->icv_corrupt) {
+			int icv_pos = td_inb[i].input_text.len - 4;
+			td_inb[i].input_text.data[icv_pos] += 1;
+		}
+	}
 }
 
 void
@@ -217,6 +220,11 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
 	uint32_t skip, len = rte_pktmbuf_pkt_len(m);
 
+	/* For negative tests, no need to do verification */
+	if (flags->icv_corrupt &&
+	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
+		return TEST_SUCCESS;
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
@@ -241,8 +249,6 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 		return TEST_FAILED;
 	}
 
-	RTE_SET_USED(flags);
-
 	return TEST_SUCCESS;
 }
 
@@ -299,13 +305,17 @@ test_ipsec_status_check(struct rte_crypto_op *op,
 {
 	int ret = TEST_SUCCESS;
 
-	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
-		printf("Security op processing failed\n");
-		ret = TEST_FAILED;
+	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->icv_corrupt) {
+		if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+			printf("ICV corruption test case failed\n");
+			ret = TEST_FAILED;
+		}
+	} else {
+		if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+			printf("Security op processing failed\n");
+			ret = TEST_FAILED;
+		}
 	}
 
-	RTE_SET_USED(flags);
-	RTE_SET_USED(dir);
-
 	return ret;
 }
app/test/test_cryptodev_security_ipsec.h +1 -0
index cbb3ee4..134fc3a 100644
@@ -49,6 +49,7 @@ struct ipsec_test_data {
 
 struct ipsec_test_flags {
 	bool display_alg;
+	bool icv_corrupt;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
Acked-by on v4 3/5
#35 lore raw

Re: [dpdk-dev] [PATCH v4 3/5] test/crypto: add lookaside IPsec ICV corrupt test case

Quoted 5 lines

Subject: [PATCH v4 3/5] test/crypto: add lookaside IPsec ICV corrupt test case

From: Tejasree Kondoj <[email protected]>

Adding lookaside IPsec ICV corrupt test case.

Please elaborate the test case a bit more. There is no documentation for the test cases, we can Atleast add appropriate description.

Apart from that,

Quoted 4 lines
#37 lore raw

PATCH v4 4/5 test/crypto: add IV gen tests

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add test cases to verify IV generated by PMD.

---
 app/test/test_cryptodev.c                | 19 ++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 52 ++++++++++++++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h |  1 +
 3 files changed, 72 insertions(+)
app/test/test_cryptodev.c +19 -0
index 19694f8..0422ff3 100644
@@ -9076,6 +9076,9 @@ test_ipsec_proto_all(const struct ipsec_test_flags *flags)
 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
 	int ret;
 
+	if (flags->iv_gen)
+		nb_pkts = IPSEC_TEST_PACKETS_MAX;
+
 	for (i = 0; i < RTE_DIM(aead_list); i++) {
 		test_ipsec_td_prepare(&aead_list[i],
 				      NULL,
@@ -9126,6 +9129,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_iv_gen(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.iv_gen = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags;
@@ -14049,6 +14064,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
 		TEST_CASE_NAMED_ST(
+			"IV generation",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_iv_gen),
+		TEST_CASE_NAMED_ST(
 			"Negative test: ICV corruption",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_err_icv_corrupt),
app/test/test_cryptodev_security_ipsec.c +52 -0

76 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +1 -0
index 134fc3a..d2ec63f 100644
@@ -50,6 +50,7 @@ struct ipsec_test_data {
 struct ipsec_test_flags {
 	bool display_alg;
 	bool icv_corrupt;
+	bool iv_gen;
 };
 
 struct crypto_param {
Signature · 1 line
2.7.4
Acked-by on v4 4/5
#38 lore raw

Re: [dpdk-dev] [PATCH v4 4/5] test/crypto: add IV gen tests

Quoted 5 lines

Subject: [PATCH v4 4/5] test/crypto: add IV gen tests

From: Tejasree Kondoj <[email protected]>

Add test cases to verify IV generated by PMD.

Title and description of the patch do not specify that This is for lookaside IPSec.
Title: test/crypto: add IV gen cases for IPsec

Description:
Added cases to verify the IV generated by PMD for lookaside IPsec use case.

It can also be mentioned that encap and decap are done One after the other so that known test vector is not required.

Apart from that,

Quoted 4 lines

---

#39 lore raw

PATCH v4 5/5 test/crypto: add UDP encapsulation test cases

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Adding UDP encapsulation test cases.

---
 app/test/test_cryptodev.c                | 19 +++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 28 ++++++++++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h |  1 +
 doc/guides/rel_notes/release_21_11.rst   |  7 +++++++
 4 files changed, 55 insertions(+)
app/test/test_cryptodev.c +19 -0
index 0422ff3..b05e2ef 100644
@@ -8942,6 +8942,9 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
 
+	if (flags->udp_encap)
+		ipsec_xform.options.udp_encap = 1;
+
 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
 	if (sec_cap == NULL)
 		return TEST_SKIPPED;
@@ -9153,6 +9156,18 @@ test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_udp_encap(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.udp_encap = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -14068,6 +14083,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_iv_gen),
 		TEST_CASE_NAMED_ST(
+			"UDP encapsulation",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_udp_encap),
+		TEST_CASE_NAMED_ST(
 			"Negative test: ICV corruption",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_err_icv_corrupt),
app/test/test_cryptodev_security_ipsec.c +28 -0
index 78c7f3a..5b54996 100644
@@ -7,6 +7,7 @@
 #include <rte_esp.h>
 #include <rte_ip.h>
 #include <rte_security.h>
+#include <rte_udp.h>
 
 #include "test.h"
 #include "test_cryptodev_security_ipsec.h"
@@ -183,6 +184,9 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 			int icv_pos = td_inb[i].input_text.len - 4;
 			td_inb[i].input_text.data[icv_pos] += 1;
 		}
+
+		if (flags->udp_encap)
+			td_inb[i].ipsec_xform.options.udp_encap = 1;
 	}
 }
 
@@ -268,6 +272,30 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
 		return TEST_SUCCESS;
 
+	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
+	   flags->udp_encap) {
+		const struct rte_ipv4_hdr *iph4;
+		const struct rte_ipv6_hdr *iph6;
+
+		if (td->ipsec_xform.tunnel.type ==
+				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
+			iph4 = (const struct rte_ipv4_hdr *)output_text;
+			if (iph4->next_proto_id != IPPROTO_UDP) {
+				printf("UDP header is not found\n");
+				return TEST_FAILED;
+			}
+		} else {
+			iph6 = (const struct rte_ipv6_hdr *)output_text;
+			if (iph6->proto != IPPROTO_UDP) {
+				printf("UDP header is not found\n");
+				return TEST_FAILED;
+			}
+		}
+
+		len -= sizeof(struct rte_udp_hdr);
+		output_text += sizeof(struct rte_udp_hdr);
+	}
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
app/test/test_cryptodev_security_ipsec.h +1 -0
index d2ec63f..e1645f4 100644
@@ -51,6 +51,7 @@ struct ipsec_test_flags {
 	bool display_alg;
 	bool icv_corrupt;
 	bool iv_gen;
+	bool udp_encap;
 };
 
 struct crypto_param {
doc/guides/rel_notes/release_21_11.rst +7 -0
index 43d367b..30c9ccf 100644
@@ -87,6 +87,13 @@ New Features
   Added command-line options to specify total number of processes and
   current process ID. Each process owns subset of Rx and Tx queues.
 
+* **Added lookaside protocol (IPsec) tests in dpdk-test.**
+
+  * Added known vector tests (AES-GCM 128, 192, 256).
+  * Added tests to verify error reporting with ICV corruption.
+  * Added tests to verify IV generation.
+  * Added tests to verify UDP encapsulation.
+
 
 Removed Items
 -------------
Signature · 1 line
2.7.4
Acked-by on v4 5/5
#40 lore raw

Re: [dpdk-dev] [PATCH v4 5/5] test/crypto: add UDP encapsulation test cases

Quoted 1 line

Subject: [PATCH v4 5/5] test/crypto: add UDP encapsulation test cases

Test/crypto: add UDP encapsulated IPSec cases

Quoted 4 lines

From: Tejasree Kondoj <[email protected]>

Adding UDP encapsulation test cases.

Elaborate the description as well

Apart from that,

doc/guides/rel_notes/release_21_11.rst New Features · line 96

Quoted 12 lines

---

doc/guides/rel_notes/release_21_11.rst +7 -0
+* **Added lookaside protocol (IPsec) tests in dpdk-test.**
+
+  * Added known vector tests (AES-GCM 128, 192, 256).
+  * Added tests to verify error reporting with ICV corruption.
+  * Added tests to verify IV generation.
+  * Added tests to verify UDP encapsulation.
+

If each case is added as a separate bullet in release notes, Then each of them should be added in the corresponding patch.

Acked-by on the v4 series
#41 lore raw
In reply to Anoob Joseph

Hi Anoob,

Quoted 84 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 17 September 2021 14:15
To: Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>; Zhang, Roy Fan <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Hemant Agrawal <[email protected]>; Nicolau, Radu <[email protected]>; Power, Ciara <[email protected]>; Gagandeep Singh <[email protected]>; [email protected]
Subject: [PATCH v4 0/5] Add lookaside IPsec tests

Add lookaside IPsec functional tests. Known vector tests and combined mode framework is added.

Known vectors are outbound vectors based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum computed correctly. And they have following properties, 1. ESP 2. Tunnel mode 3. IPv4 4. IPv4 tunnel

Known vector tests for inbound operation would generate test vectors by reversing outbound known vectors. The input_text would become encrypted packet and output_text would be the plain packet. Tests would then validate the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers supported by the PMD. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

Four test cases use combined mode,
1. Display algo coverage and basic in + out tests 2. Negative test for ICV corruption 3. IV generation 4. UDP encapsulation

IV generation test case compares IV generated for a batch of packets and returns failure if IV is repeated.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode 2. IPv6 3. Transport
4. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k
3. crypto_cn9k

Changes in v4:
- Fixed lack of device stop in case capability check fails (comment from Ciara)
- Rebased and updated release notes

Changes in v3
- Added UDP encapsulation tests

Changes in v2
- Dropped outbound known vector tests as lookaside protocol would require IV
generated by PMD. The tests would be introduced with spec change to allow
user
to specify IV.
- Added IV generation tests
- Minor fixes in combined mode tests to handle multiple packets

Anoob Joseph (2):
test/crypto: add lookaside IPsec tests
test/crypto: add combined mode tests

Tejasree Kondoj (3):
test/crypto: add lookaside IPsec ICV corrupt test case test/crypto: add IV gen tests
test/crypto: add UDP encapsulation test cases

app/test/meson.build                               |   1 +
app/test/test.h                                    |   6 +
app/test/test_cryptodev.c                          | 351 ++++++++++++++++++
app/test/test_cryptodev_security_ipsec.c           | 401

+++++++++++++++++++++
app/test/test_cryptodev_security_ipsec.h | 119 ++++++
.../test_cryptodev_security_ipsec_test_vectors.h | 321
+++++++++++++++++
doc/guides/rel_notes/release_21_11.rst | 7 +

Quoted 7 lines
7 files changed, 1206 insertions(+)

create mode 100644 app/test/test_cryptodev_security_ipsec.c create mode 100644 app/test/test_cryptodev_security_ipsec.h create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h

--
2.7.4

For the series from a crypto test framework point of view,

#42 lore raw

v5 cover Add lookaside IPsec tests

In reply to Anoob Joseph

Add lookaside IPsec functional tests. Known vector tests and combined mode framework is added.

Known vectors are outbound vectors based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum computed correctly. And they have following properties,
1. ESP
2. Tunnel mode
3. IPv4
4. IPv4 tunnel

Known vector tests for inbound operation would generate test vectors by reversing outbound known vectors. The input_text would become encrypted packet and output_text would be the plain packet. Tests would then validate the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers supported by the PMD. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

Four test cases use combined mode,
1. Display algo coverage and basic in + out tests
2. Negative test for ICV corruption
3. IV generation
4. UDP encapsulation

IV generation test case compares IV generated for a batch of packets and returns failure if IV is repeated.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode
2. IPv6
3. Transport
4. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k
3. crypto_cn9k

Changes in v5:
- Fixed lack of return check with dev_configure_and_start() (comment from Akhil)
- Adjusted patch title and description (comment from Akhil)

Changes in v4:
- Fixed lack of device stop in case capability check fails (comment from Ciara)
- Rebased and updated release notes

Changes in v3
- Added UDP encapsulation tests

Changes in v2
- Dropped outbound known vector tests as lookaside protocol would require IV generated by PMD. The tests would be introduced with spec change to allow user to specify IV.
- Added IV generation tests
- Minor fixes in combined mode tests to handle multiple packets

Anoob Joseph (2):
test/crypto: add lookaside IPsec cases
test/crypto: add combined mode IPsec cases

Tejasree Kondoj (3):
test/crypto: add lookaside IPsec ICV corrupt test case test/crypto: add IV gen cases for IPsec test/crypto: add UDP encapsulated IPsec test cases

 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 355 ++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 401 +++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           | 119 ++++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++
 doc/guides/rel_notes/release_21_11.rst             |   7 +
 7 files changed, 1210 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
Signature · 1 line
2.7.4
#43 lore raw

PATCH v5 1/5 test/crypto: add lookaside IPsec cases

Added test case for lookaside IPsec. Inbound known vector tests are added.

Cipher list: AES-GCM 128, 192 & 256

---
 app/test/meson.build                               |   1 +
 app/test/test.h                                    |   6 +
 app/test/test_cryptodev.c                          | 236 +++++++++++++++
 app/test/test_cryptodev_security_ipsec.c           | 212 ++++++++++++++
 app/test/test_cryptodev_security_ipsec.h           |  66 +++++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +++++++++++++++++++++
 doc/guides/rel_notes/release_21_11.rst             |   4 +
 7 files changed, 846 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h
app/test/meson.build +1 -0
index a761168..f144d8b 100644
@@ -38,6 +38,7 @@ test_sources = files(
         'test_cryptodev.c',
         'test_cryptodev_asym.c',
         'test_cryptodev_blockcipher.c',
+        'test_cryptodev_security_ipsec.c',
         'test_cryptodev_security_pdcp.c',
         'test_cycles.c',
         'test_debug.c',
app/test/test.h +6 -0
index c3b2a87..7115edf 100644
@@ -124,6 +124,12 @@ struct unit_test_case {
 #define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \
 		{ setup, teardown, NULL, testcase, #testcase, 1, data }
 
+#define TEST_CASE_NAMED_ST(name, setup, teardown, testcase) \
+		{ setup, teardown, NULL, testcase, name, 1, NULL }
+
+#define TEST_CASE_NAMED_WITH_DATA(name, setup, teardown, testcase, data) \
+		{ setup, teardown, NULL, testcase, name, 1, data }
+
 #define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL }
 
 #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
app/test/test_cryptodev.c +236 -0

278 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.c new file +212 -0

212 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h new file +66 -0

66 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec_test_vectors.h new file +321 -0

321 lines not on this page · raw message

doc/guides/rel_notes/release_21_11.rst +4 -0
index 43d367b..cf0277d 100644
@@ -87,6 +87,10 @@ New Features
   Added command-line options to specify total number of processes and
   current process ID. Each process owns subset of Rx and Tx queues.
 
+* **Added lookaside protocol (IPsec) tests in dpdk-test.**
+
+  * Added known vector tests (AES-GCM 128, 192, 256).
+
 
 Removed Items
 -------------
Signature · 1 line
2.7.4
#44 lore raw

PATCH v5 2/5 test/crypto: add combined mode IPsec cases

In reply to Anoob Joseph

Add framework to test IPsec features with all supported combinations of ciphers.

Combined mode tests are used to test all IPsec features against all ciphers supported by the PMD. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

The tests would first do IPsec encapsulation and do sanity checks. Based on flags, packet would be updated or additional checks are done, followed by IPsec decapsulation. Since the encrypted packet is generated by the test, known vectors are not required.

---
 app/test/test_cryptodev.c                |  73 +++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.c | 107 +++++++++++++++++++++++++++++--
 app/test/test_cryptodev_security_ipsec.h |  52 ++++++++++++++-
 3 files changed, 223 insertions(+), 9 deletions(-)
app/test/test_cryptodev.c +69 -4
index f7d429b..3eacc66 100644
@@ -8908,7 +8908,8 @@ static int
 test_ipsec_proto_process(const struct ipsec_test_data td[],
 			 struct ipsec_test_data res_d[],
 			 int nb_td,
-			 bool silent)
+			 bool silent,
+			 const struct ipsec_test_flags *flags)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -9025,7 +9026,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 		/* Process crypto operation */
 		process_crypto_request(dev_id, ut_params->op);
 
-		ret = test_ipsec_status_check(ut_params->op, dir);
+		ret = test_ipsec_status_check(ut_params->op, flags, dir);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -9033,7 +9034,7 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 			res_d_tmp = &res_d[i];
 
 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
-					      res_d_tmp, silent);
+					      res_d_tmp, silent, flags);
 		if (ret != TEST_SUCCESS)
 			goto crypto_op_free;
 
@@ -9061,11 +9062,71 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 static int
 test_ipsec_proto_known_vec_inb(const void *td_outb)
 {
+	struct ipsec_test_flags flags;
 	struct ipsec_test_data td_inb;
 
+	memset(&flags, 0, sizeof(flags));
+
 	test_ipsec_td_in_from_out(td_outb, &td_inb);
 
-	return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
+}
+
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags)
+{
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	unsigned int i, nb_pkts = 1, pass_cnt = 0;
+	int ret;
+
+	for (i = 0; i < RTE_DIM(aead_list); i++) {
+		test_ipsec_td_prepare(&aead_list[i],
+				      NULL,
+				      flags,
+				      td_outb,
+				      nb_pkts);
+
+		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+					       flags);
+		if (ret == TEST_SKIPPED)
+			continue;
+
+		if (ret == TEST_FAILED)
+			return TEST_FAILED;
+
+		if (flags->display_alg)
+			test_ipsec_display_alg(&aead_list[i], NULL);
+
+		pass_cnt++;
+	}
+
+	if (pass_cnt > 0)
+		return TEST_SUCCESS;
+	else
+		return TEST_SKIPPED;
+}
+
+static int
+test_ipsec_proto_display_list(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.display_alg = true;
+
+	return test_ipsec_proto_all(&flags);
 }
 
 static int
@@ -13976,6 +14037,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_ST(
+			"Combined test alg list",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_display_list),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +103 -4

153 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +51 -1

74 lines not on this page · raw message

Signature · 1 line
2.7.4
#45 lore raw

PATCH v5 3/5 test/crypto: add lookaside IPsec ICV corrupt test case

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add negative test to validate IPsec inbound processing failure with ICV corruption. The tests would first do IPsec encapsulation and corrupt ICV of the generated IPsec packet. Then the packet is submitted to IPsec outbound processing for decapsulation. Test case would validate that PMD returns an error in such cases.

---
 app/test/test_cryptodev.c                | 16 ++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 30 ++++++++++++++++++++----------
 app/test/test_cryptodev_security_ipsec.h |  1 +
 doc/guides/rel_notes/release_21_11.rst   |  1 +
 4 files changed, 38 insertions(+), 10 deletions(-)
app/test/test_cryptodev.c +16 -0
index 3eacc66..bfaca1d 100644
@@ -9130,6 +9130,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.icv_corrupt = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -14041,6 +14053,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			"Combined test alg list",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
+		TEST_CASE_NAMED_ST(
+			"Negative test: ICV corruption",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_err_icv_corrupt),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
app/test/test_cryptodev_security_ipsec.c +20 -10
index d08e093..aebbe66 100644
@@ -175,9 +175,12 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 		memcpy(td_inb[i].output_text.data, td_outb[i].input_text.data,
 		       td_outb[i].input_text.len);
 		td_inb[i].output_text.len = td_outb->input_text.len;
-	}
 
-	RTE_SET_USED(flags);
+		if (flags->icv_corrupt) {
+			int icv_pos = td_inb[i].input_text.len - 4;
+			td_inb[i].input_text.data[icv_pos] += 1;
+		}
+	}
 }
 
 void
@@ -217,6 +220,11 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
 	uint32_t skip, len = rte_pktmbuf_pkt_len(m);
 
+	/* For negative tests, no need to do verification */
+	if (flags->icv_corrupt &&
+	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
+		return TEST_SUCCESS;
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
@@ -241,8 +249,6 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 		return TEST_FAILED;
 	}
 
-	RTE_SET_USED(flags);
-
 	return TEST_SUCCESS;
 }
 
@@ -299,13 +305,17 @@ test_ipsec_status_check(struct rte_crypto_op *op,
 {
 	int ret = TEST_SUCCESS;
 
-	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
-		printf("Security op processing failed\n");
-		ret = TEST_FAILED;
+	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->icv_corrupt) {
+		if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+			printf("ICV corruption test case failed\n");
+			ret = TEST_FAILED;
+		}
+	} else {
+		if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+			printf("Security op processing failed\n");
+			ret = TEST_FAILED;
+		}
 	}
 
-	RTE_SET_USED(flags);
-	RTE_SET_USED(dir);
-
 	return ret;
 }
app/test/test_cryptodev_security_ipsec.h +1 -0
index cbb3ee4..134fc3a 100644
@@ -49,6 +49,7 @@ struct ipsec_test_data {
 
 struct ipsec_test_flags {
 	bool display_alg;
+	bool icv_corrupt;
 };
 
 struct crypto_param {
doc/guides/rel_notes/release_21_11.rst +1 -0
index cf0277d..8fc5844 100644
@@ -90,6 +90,7 @@ New Features
 * **Added lookaside protocol (IPsec) tests in dpdk-test.**
 
   * Added known vector tests (AES-GCM 128, 192, 256).
+  * Added tests to verify error reporting with ICV corruption.
 
 
 Removed Items
Signature · 1 line
2.7.4
#46 lore raw

PATCH v5 4/5 test/crypto: add IV gen cases for IPsec

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Added cases to verify IV generated by PMD for lookaside IPsec.

The tests compare IV generated for a batch of packets and ensures that IV is not getting repeated in the batch.

---
 app/test/test_cryptodev.c                | 19 ++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 52 ++++++++++++++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h |  1 +
 doc/guides/rel_notes/release_21_11.rst   |  1 +
 4 files changed, 73 insertions(+)
app/test/test_cryptodev.c +19 -0
index bfaca1d..956541e 100644
@@ -9080,6 +9080,9 @@ test_ipsec_proto_all(const struct ipsec_test_flags *flags)
 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
 	int ret;
 
+	if (flags->iv_gen)
+		nb_pkts = IPSEC_TEST_PACKETS_MAX;
+
 	for (i = 0; i < RTE_DIM(aead_list); i++) {
 		test_ipsec_td_prepare(&aead_list[i],
 				      NULL,
@@ -9130,6 +9133,18 @@ test_ipsec_proto_display_list(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_iv_gen(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.iv_gen = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags;
@@ -14054,6 +14069,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_display_list),
 		TEST_CASE_NAMED_ST(
+			"IV generation",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_iv_gen),
+		TEST_CASE_NAMED_ST(
 			"Negative test: ICV corruption",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_err_icv_corrupt),
app/test/test_cryptodev_security_ipsec.c +52 -0

76 lines not on this page · raw message

app/test/test_cryptodev_security_ipsec.h +1 -0
index 134fc3a..d2ec63f 100644
@@ -50,6 +50,7 @@ struct ipsec_test_data {
 struct ipsec_test_flags {
 	bool display_alg;
 	bool icv_corrupt;
+	bool iv_gen;
 };
 
 struct crypto_param {
doc/guides/rel_notes/release_21_11.rst +1 -0
index 8fc5844..cda0a92 100644
@@ -91,6 +91,7 @@ New Features
 
   * Added known vector tests (AES-GCM 128, 192, 256).
   * Added tests to verify error reporting with ICV corruption.
+  * Added tests to verify IV generation.
 
 
 Removed Items
Signature · 1 line
2.7.4
#47 lore raw

PATCH v5 5/5 test/crypto: add UDP encapsulated IPsec test cases

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add tests to verify UDP encapsulation with IPsec. The tests have IPsec packets generated from plain packets and verifies that UDP header is added. Subsequently, the packets are decapsulated and then resultant packet is verified by comparing against original packet.

---
 app/test/test_cryptodev.c                | 19 +++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.c | 28 ++++++++++++++++++++++++++++
 app/test/test_cryptodev_security_ipsec.h |  1 +
 doc/guides/rel_notes/release_21_11.rst   |  1 +
 4 files changed, 49 insertions(+)
app/test/test_cryptodev.c +19 -0
index 956541e..bc2490b 100644
@@ -8946,6 +8946,9 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
 
+	if (flags->udp_encap)
+		ipsec_xform.options.udp_encap = 1;
+
 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
 	if (sec_cap == NULL)
 		return TEST_SKIPPED;
@@ -9157,6 +9160,18 @@ test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
 }
 
 static int
+test_ipsec_proto_udp_encap(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.udp_encap = true;
+
+	return test_ipsec_proto_all(&flags);
+}
+
+static int
 test_PDCP_PROTO_all(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -14073,6 +14088,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_iv_gen),
 		TEST_CASE_NAMED_ST(
+			"UDP encapsulation",
+			ut_setup_security, ut_teardown,
+			test_ipsec_proto_udp_encap),
+		TEST_CASE_NAMED_ST(
 			"Negative test: ICV corruption",
 			ut_setup_security, ut_teardown,
 			test_ipsec_proto_err_icv_corrupt),
app/test/test_cryptodev_security_ipsec.c +28 -0
index 78c7f3a..5b54996 100644
@@ -7,6 +7,7 @@
 #include <rte_esp.h>
 #include <rte_ip.h>
 #include <rte_security.h>
+#include <rte_udp.h>
 
 #include "test.h"
 #include "test_cryptodev_security_ipsec.h"
@@ -183,6 +184,9 @@ test_ipsec_td_update(struct ipsec_test_data td_inb[],
 			int icv_pos = td_inb[i].input_text.len - 4;
 			td_inb[i].input_text.data[icv_pos] += 1;
 		}
+
+		if (flags->udp_encap)
+			td_inb[i].ipsec_xform.options.udp_encap = 1;
 	}
 }
 
@@ -268,6 +272,30 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	    td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
 		return TEST_SUCCESS;
 
+	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
+	   flags->udp_encap) {
+		const struct rte_ipv4_hdr *iph4;
+		const struct rte_ipv6_hdr *iph6;
+
+		if (td->ipsec_xform.tunnel.type ==
+				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
+			iph4 = (const struct rte_ipv4_hdr *)output_text;
+			if (iph4->next_proto_id != IPPROTO_UDP) {
+				printf("UDP header is not found\n");
+				return TEST_FAILED;
+			}
+		} else {
+			iph6 = (const struct rte_ipv6_hdr *)output_text;
+			if (iph6->proto != IPPROTO_UDP) {
+				printf("UDP header is not found\n");
+				return TEST_FAILED;
+			}
+		}
+
+		len -= sizeof(struct rte_udp_hdr);
+		output_text += sizeof(struct rte_udp_hdr);
+	}
+
 	if (len != td->output_text.len) {
 		printf("Output length (%d) not matching with expected (%d)\n",
 			len, td->output_text.len);
app/test/test_cryptodev_security_ipsec.h +1 -0
index d2ec63f..e1645f4 100644
@@ -51,6 +51,7 @@ struct ipsec_test_flags {
 	bool display_alg;
 	bool icv_corrupt;
 	bool iv_gen;
+	bool udp_encap;
 };
 
 struct crypto_param {
doc/guides/rel_notes/release_21_11.rst +1 -0
index cda0a92..30c9ccf 100644
@@ -92,6 +92,7 @@ New Features
   * Added known vector tests (AES-GCM 128, 192, 256).
   * Added tests to verify error reporting with ICV corruption.
   * Added tests to verify IV generation.
+  * Added tests to verify UDP encapsulation.
 
 
 Removed Items
Signature · 1 line
2.7.4
Applied
#48 lore raw
In reply to Anoob Joseph
Quoted 45 lines

Add lookaside IPsec functional tests. Known vector tests and combined mode framework is added.

Known vectors are outbound vectors based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum computed correctly. And they have following properties,
1. ESP
2. Tunnel mode
3. IPv4
4. IPv4 tunnel

Known vector tests for inbound operation would generate test vectors by reversing outbound known vectors. The input_text would become encrypted packet and output_text would be the plain packet. Tests would then validate the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers supported by the PMD. The framework is introduced to avoid testing with any specific algo, thereby making it mandatory to be supported. Also, testing with all supported combinations will help with increasing coverage as well.

Four test cases use combined mode,
1. Display algo coverage and basic in + out tests
2. Negative test for ICV corruption
3. IV generation
4. UDP encapsulation

IV generation test case compares IV generated for a batch of packets and returns
failure if IV is repeated.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode
2. IPv6
3. Transport
4. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k
3. crypto_cn9k

Quoted 5 lines

Changes in v5:
- Fixed lack of return check with dev_configure_and_start() (comment from Akhil)
- Adjusted patch title and description (comment from Akhil)

Applied to dpdk-next-crypto

Thanks.