Skip to contentSkip to conversation

test/crypto: add PDCP vectors and cases

PATCH New Akhil Goyal 2 participants 20 messages Sep 4, 2019 – Sep 30, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/crypto: add PDCP vectors and cases

This patch add test vectors and a test framework for PDCP cplane and uplane protocol processing based on various sequence number sizes(5/7/12/15/18).

These test cases and test vectors are validated over NXP DPAA_SEC and DPAA2_SEC platforms.

This is an RFC patch. It will be split into multiple patches.

Further this patch is dependent on
http://patches.dpdk.org/project/dpdk/list/?series=6199

---
 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  714 +-
 app/test/test_cryptodev_security_pdcp.c       |  587 ++
 .../test_cryptodev_security_pdcp_test_func.h  |   48 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 6324 +++++++++++++++++
 6 files changed, 7668 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_vectors.h
app/test/Makefile +1 -0
index 26ba6fe2b..df7f77f44 100644
@@ -196,6 +196,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
+SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_cryptodev_security_pdcp.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_METRICS) += test_metrics.c
 
app/test/meson.build +1 -0
index ec40943bd..63577a5d4 100644
@@ -28,6 +28,7 @@ test_sources = files('commands.c',
 	'test_cpuflags.c',
 	'test_crc.c',
 	'test_cryptodev.c',
+	'test_cryptodev_security_pdcp.c',
 	'test_cryptodev_asym.c',
 	'test_cryptodev_blockcipher.c',
 	'test_cycles.c',
app/test/test_cryptodev.c +707 -7

756 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp.c new file +587 -0

587 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h new file +48 -0

48 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_vectors.h new file +6324 -0

1,595 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#1 lore raw

cover Add PDCP test cases

This patch add test vectors and a test framework for PDCP cplane and uplane protocol processing based on various sequence number sizes(5/7/12/15/18).

These test cases and test vectors are validated over NXP DPAA_SEC and DPAA2_SEC platforms.

This patchset is a split to the patch [1] which was sent as RFC.

Further this patchset is dependent on [2]
[1] http://patches.dpdk.org/patch/58554/
[2] http://patches.dpdk.org/project/dpdk/list/?series=6199

Akhil Goyal (7):
test/crypto: Add PDCP cplane encap cases test/crypto: Add PDCP cplane decap cases test/crypto: Add PDCP uplane encap cases test/crypto: Add PDCP uplane encap with integrity cases test/crypto: Add PDCP uplane decap cases test/crypto: Add PDCP cases for scatter gather bufs test/crypto: support wireless algos for dpaa2_sec

 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  713 +-
 app/test/test_cryptodev_security_pdcp.c       |  590 ++
 .../test_cryptodev_security_pdcp_test_func.h  |   48 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 6323 +++++++++++++++++
 6 files changed, 7669 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_vectors.h
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/7 test/crypto: Add PDCP cplane encap cases

PDCP control plane can support 5 bit and 12 bit sequence number. This patch add test cases and test vectors for all supported algo combinations of cipher+integrity (NULL+NULL, NULL+AES, NULL+SNOW, NULL+ZUC,
AES+NULL, AES+SNOW, AES+AES, AES+ZUC,
SNOW+NULL, SNOW+AES, SNOW+SNOW, SNOW+ZUC,
ZUC+NULL, ZUC+AES, ZUC+SNOW, ZUC+ZUC).

The test cases are added in DPAA_SEC and DPAA2_SEC test suite as a reference.

---
 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  221 +-
 app/test/test_cryptodev_security_pdcp.c       |  141 +
 .../test_cryptodev_security_pdcp_test_func.h  |   36 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 2491 +++++++++++++++++
 6 files changed, 2884 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_vectors.h
app/test/Makefile +1 -0
index 26ba6fe2b..df7f77f44 100644
@@ -196,6 +196,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
+SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_cryptodev_security_pdcp.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_METRICS) += test_metrics.c
 
app/test/meson.build +1 -0
index ec40943bd..2c23c6347 100644
@@ -30,6 +30,7 @@ test_sources = files('commands.c',
 	'test_cryptodev.c',
 	'test_cryptodev_asym.c',
 	'test_cryptodev_blockcipher.c',
+	'test_cryptodev_security_pdcp.c',
 	'test_cycles.c',
 	'test_debug.c',
 	'test_distributor.c',
app/test/test_cryptodev.c +214 -7

257 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp.c new file +141 -0

141 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h new file +36 -0
new file mode 100644
index 000000000..ad1e7c70a
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 NXP
+ */
+
+#ifndef SECURITY_PDCP_TEST_FUNC_H_
+#define SECURITY_PDCP_TEST_FUNC_H_
+
+#define PDCP_CPLANE_OFFSET		0
+#define PDCP_CPLANE_LONG_SN_OFFSET	32
+#define LONG_SEQ_NUM_OFFSET		0
+#define SHORT_SEQ_NUM_OFFSET		2
+#define FIFTEEN_BIT_SEQ_NUM_OFFSET	4
+#define EIGHTEEN_BIT_SEQ_NUM_OFFSET	6
+#define UPLINK				0
+#define DOWNLINK			1
+/* key length(in bytes) for F8 */
+#define F8_KEY_LEN			16
+
+enum enc_alg_off {
+	NULL_ENC = 0,
+	SNOW_ENC = 8,
+	AES_ENC = 16,
+	ZUC_ENC = 24
+};
+enum auth_alg_off {
+	NULL_AUTH = 0,
+	SNOW_AUTH = 2,
+	AES_AUTH = 4,
+	ZUC_AUTH = 6
+};
+
+int test_pdcp_proto_cplane_encap(int i);
+
+int test_PDCP_PROTO_cplane_encap_all(void);
+
+#endif /* SECURITY_PDCP_TEST_FUNC_H_ */
app/test/test_cryptodev_security_pdcp_test_vectors.h new file +2491 -0

2,491 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

PATCH 2/7 test/crypto: Add PDCP cplane decap cases

In reply to Akhil Goyal

This patch add test cases for control plane PDCP 5 and 12 bit SN test cases for decapsulation of cipher+integrity for all algo combinations

Test vectors are reused from the encap cases by swapping the input and output data.

The case are added to DPAA_SEC and DPAA2_SEC testsuite.

---
 app/test/test_cryptodev.c                     |  18 +++
 app/test/test_cryptodev_security_pdcp.c       | 105 ++++++++++++++++++
 .../test_cryptodev_security_pdcp_test_func.h  |   2 +
 3 files changed, 125 insertions(+)
app/test/test_cryptodev.c +18 -0
index 852ca5cbe..14a090667 100644
@@ -7218,6 +7218,18 @@ test_pdcp_proto_cplane_encap(int i)
 		pdcp_test_data_in_len[i]+4);
 }
 
+int
+test_pdcp_proto_cplane_decap(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_DECRYPT,
+		RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i] + 4,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i]);
+}
+
 #endif
 
 static int
@@ -11635,6 +11647,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 #ifdef RTE_LIBRTE_SECURITY
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_cplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11744,6 +11759,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 #ifdef RTE_LIBRTE_SECURITY
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_cplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
app/test/test_cryptodev_security_pdcp.c +105 -0

114 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +2 -0
index ad1e7c70a..21a6e8a48 100644
@@ -30,7 +30,9 @@ enum auth_alg_off {
 };
 
 int test_pdcp_proto_cplane_encap(int i);
+int test_pdcp_proto_cplane_decap(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
+int test_PDCP_PROTO_cplane_decap_all(void);
 
 #endif /* SECURITY_PDCP_TEST_FUNC_H_ */
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/7 test/crypto: Add PDCP uplane encap cases

In reply to Akhil Goyal

PDCP User/Data plane can support 5/7/12/15/18 bit sequence number. This patch add test cases and test vectors for all supported algos for cipher only. (NULL, AES, SNOW, ZUC ciphers)

The test cases are added in DPAA_SEC and DPAA2_SEC test suite as a reference.

---
 app/test/test_cryptodev.c                     |   19 +
 app/test/test_cryptodev_security_pdcp.c       |   72 ++
 .../test_cryptodev_security_pdcp_test_func.h  |    6 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 1113 +++++++++++++++++
 4 files changed, 1210 insertions(+)
app/test/test_cryptodev.c +19 -0
index 14a090667..20d410814 100644
@@ -7218,6 +7218,19 @@ test_pdcp_proto_cplane_encap(int i)
 		pdcp_test_data_in_len[i]+4);
 }
 
+int
+test_pdcp_proto_uplane_encap(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+		RTE_CRYPTO_AUTH_OP_GENERATE,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i],
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i]);
+
+}
+
 int
 test_pdcp_proto_cplane_decap(int i)
 {
@@ -11650,6 +11663,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_encap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11762,6 +11778,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_encap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
app/test/test_cryptodev_security_pdcp.c +72 -0

81 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +6 -0
index 21a6e8a48..7051790c8 100644
@@ -7,6 +7,7 @@
 
 #define PDCP_CPLANE_OFFSET		0
 #define PDCP_CPLANE_LONG_SN_OFFSET	32
+#define PDCP_UPLANE_OFFSET		64
 #define LONG_SEQ_NUM_OFFSET		0
 #define SHORT_SEQ_NUM_OFFSET		2
 #define FIFTEEN_BIT_SEQ_NUM_OFFSET	4
@@ -16,6 +17,9 @@
 /* key length(in bytes) for F8 */
 #define F8_KEY_LEN			16
 
+#define PDCP_UPLANE_12BIT_OFFSET	(PDCP_UPLANE_OFFSET + 32)
+#define PDCP_UPLANE_18BIT_OFFSET	(PDCP_UPLANE_12BIT_OFFSET + 32)
+
 enum enc_alg_off {
 	NULL_ENC = 0,
 	SNOW_ENC = 8,
@@ -30,9 +34,11 @@ enum auth_alg_off {
 };
 
 int test_pdcp_proto_cplane_encap(int i);
+int test_pdcp_proto_uplane_encap(int i);
 int test_pdcp_proto_cplane_decap(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
 int test_PDCP_PROTO_cplane_decap_all(void);
+int test_PDCP_PROTO_uplane_encap_all(void);
 
 #endif /* SECURITY_PDCP_TEST_FUNC_H_ */
app/test/test_cryptodev_security_pdcp_test_vectors.h +1113 -0

1,179 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

PATCH 4/7 test/crypto: Add PDCP uplane encap with integrity cases

In reply to Akhil Goyal

PDCP User/Data plane can optionally support integrity along with confidentiality.
This patch add test cases and test vectors for all supported algos combos for cipher+integrity for 12 and 18bit SN.

The test cases are added in DPAA_SEC and DPAA2_SEC test suite as a reference.

---
 app/test/test_cryptodev.c                     |   12 +
 app/test/test_cryptodev_security_pdcp.c       |   99 +
 .../test_cryptodev_security_pdcp_test_func.h  |    1 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 4079 ++++++++++++++---
 4 files changed, 3511 insertions(+), 680 deletions(-)
app/test/test_cryptodev.c +12 -0
index 20d410814..aa8602f94 100644
@@ -7231,6 +7231,18 @@ test_pdcp_proto_uplane_encap(int i)
 
 }
 
+int
+test_pdcp_proto_uplane_encap_with_int(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+		RTE_CRYPTO_AUTH_OP_GENERATE,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i],
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i] + 4);
+}
+
 int
 test_pdcp_proto_cplane_decap(int i)
 {
app/test/test_cryptodev_security_pdcp.c +99 -0

111 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +1 -0
index 7051790c8..473cdaecc 100644
@@ -35,6 +35,7 @@ enum auth_alg_off {
 
 int test_pdcp_proto_cplane_encap(int i);
 int test_pdcp_proto_uplane_encap(int i);
+int test_pdcp_proto_uplane_encap_with_int(int i);
 int test_pdcp_proto_cplane_decap(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
app/test/test_cryptodev_security_pdcp_test_vectors.h +3399 -680

2,864 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#6 lore raw

PATCH 5/7 test/crypto: Add PDCP uplane decap cases

In reply to Akhil Goyal

This patch add test cases for user plane PDCP 5/7/12/15/18 bit SN test cases for decapsulation of cipher only and 12/18 bit for cipher + integrity for all algo combinations.

Test vectors are reused from the encap cases by swapping the input and output data.

The case are added to DPAA_SEC and DPAA2_SEC testsuite.

---
 app/test/test_cryptodev.c                     |  30 +++
 app/test/test_cryptodev_security_pdcp.c       | 173 ++++++++++++++++++
 .../test_cryptodev_security_pdcp_test_func.h  |   3 +
 3 files changed, 206 insertions(+)
app/test/test_cryptodev.c +30 -0
index aa8602f94..837969430 100644
@@ -7255,6 +7255,30 @@ test_pdcp_proto_cplane_decap(int i)
 		pdcp_test_data_in_len[i]);
 }
 
+int
+test_pdcp_proto_uplane_decap(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_DECRYPT,
+		RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i],
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i]);
+}
+
+int
+test_pdcp_proto_uplane_decap_with_int(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_DECRYPT,
+		RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i] + 4,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i]);
+}
+
 #endif
 
 static int
@@ -11678,6 +11702,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11793,6 +11820,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
app/test/test_cryptodev_security_pdcp.c +173 -0

188 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +3 -0
index 473cdaecc..f3dc93e2f 100644
@@ -37,9 +37,12 @@ int test_pdcp_proto_cplane_encap(int i);
 int test_pdcp_proto_uplane_encap(int i);
 int test_pdcp_proto_uplane_encap_with_int(int i);
 int test_pdcp_proto_cplane_decap(int i);
+int test_pdcp_proto_uplane_decap(int i);
+int test_pdcp_proto_uplane_decap_with_int(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
 int test_PDCP_PROTO_cplane_decap_all(void);
 int test_PDCP_PROTO_uplane_encap_all(void);
+int test_PDCP_PROTO_uplane_decap_all(void);
 
 #endif /* SECURITY_PDCP_TEST_FUNC_H_ */
Signature · 1 line
2.17.1
#7 lore raw

PATCH 6/7 test/crypto: Add PDCP cases for scatter gather bufs

In reply to Akhil Goyal

Test cases for PDCP with scattered input and output buffers are added for both inplace and out of place scenarios.
1. input SG - output non SG
2. input and output both SG and inplace buffers
3. input and output both SG with different segment sizes
4. input SG and output non-SG

---
 app/test/test_cryptodev.c | 349 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 349 insertions(+)
app/test/test_cryptodev.c +349 -0
index 837969430..568fa84a9 100644
@@ -7206,6 +7206,276 @@ test_pdcp_proto(int i, int oop,
 	return ret;
 }
 
+static int
+test_pdcp_proto_SGL(int i, int oop,
+	enum rte_crypto_cipher_operation opc,
+	enum rte_crypto_auth_operation opa,
+	uint8_t *input_vec,
+	unsigned int input_vec_len,
+	uint8_t *output_vec,
+	unsigned int output_vec_len,
+	uint32_t fragsz,
+	uint32_t fragsz_oop)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	uint8_t *plaintext;
+	struct rte_mbuf *buf, *buf_oop = NULL;
+	int ret = TEST_SUCCESS;
+	int to_trn = 0;
+	int to_trn_tbl[16];
+	int segs = 1;
+	unsigned int trn_data = 0;
+
+	if (fragsz > input_vec_len)
+		fragsz = input_vec_len;
+
+	uint16_t plaintext_len = fragsz;
+	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
+
+	if (fragsz_oop > output_vec_len)
+		frag_size_oop = output_vec_len;
+
+	int ecx = 0;
+	if (input_vec_len % fragsz != 0) {
+		if (input_vec_len / fragsz + 1 > 16)
+			return 1;
+	} else if (input_vec_len / fragsz > 16)
+		return 1;
+
+	/* Out of place support */
+	if (oop) {
+		/*
+		 * For out-op-place we need to alloc another mbuf
+		 */
+		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
+		buf_oop = ut_params->obuf;
+	}
+
+	/* Generate test mbuf data */
+	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+	/* clear mbuf payload */
+	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+			rte_pktmbuf_tailroom(ut_params->ibuf));
+
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+						  plaintext_len);
+	memcpy(plaintext, input_vec, plaintext_len);
+	trn_data += plaintext_len;
+
+	buf = ut_params->ibuf;
+
+	/*
+	 * Loop until no more fragments
+	 */
+
+	while (trn_data < input_vec_len) {
+		++segs;
+		to_trn = (input_vec_len - trn_data < fragsz) ?
+				(input_vec_len - trn_data) : fragsz;
+
+		to_trn_tbl[ecx++] = to_trn;
+
+		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+		buf = buf->next;
+
+		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
+				rte_pktmbuf_tailroom(buf));
+
+		/* OOP */
+		if (oop && !fragsz_oop) {
+			buf_oop->next =
+					rte_pktmbuf_alloc(ts_params->mbuf_pool);
+			buf_oop = buf_oop->next;
+			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
+					0, rte_pktmbuf_tailroom(buf_oop));
+			rte_pktmbuf_append(buf_oop, to_trn);
+		}
+
+		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
+				to_trn);
+
+		memcpy(plaintext, input_vec + trn_data, to_trn);
+		trn_data += to_trn;
+	}
+
+	ut_params->ibuf->nb_segs = segs;
+
+	segs = 1;
+	if (fragsz_oop && oop) {
+		to_trn = 0;
+		ecx = 0;
+
+		trn_data = frag_size_oop;
+		while (trn_data < output_vec_len) {
+			++segs;
+			to_trn =
+				(output_vec_len - trn_data <
+						frag_size_oop) ?
+				(output_vec_len - trn_data) :
+						frag_size_oop;
+
+			to_trn_tbl[ecx++] = to_trn;
+
+			buf_oop->next =
+				rte_pktmbuf_alloc(ts_params->mbuf_pool);
+			buf_oop = buf_oop->next;
+			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
+					0, rte_pktmbuf_tailroom(buf_oop));
+			rte_pktmbuf_append(buf_oop, to_trn);
+
+			trn_data += to_trn;
+		}
+		ut_params->obuf->nb_segs = segs;
+	}
+
+	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
+
+	/* Setup Cipher Parameters */
+	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
+	ut_params->cipher_xform.cipher.op = opc;
+	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
+	ut_params->cipher_xform.cipher.key.length =
+					pdcp_test_params[i].cipher_key_len;
+	ut_params->cipher_xform.cipher.iv.length = 0;
+
+	/* Setup HMAC Parameters if ICV header is required */
+	if (pdcp_test_params[i].auth_alg != 0) {
+		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
+		ut_params->auth_xform.next = NULL;
+		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
+		ut_params->auth_xform.auth.op = opa;
+		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
+		ut_params->auth_xform.auth.key.length =
+					pdcp_test_params[i].auth_key_len;
+
+		ut_params->cipher_xform.next = &ut_params->auth_xform;
+	} else {
+		ut_params->cipher_xform.next = NULL;
+	}
+
+	struct rte_security_session_conf sess_conf = {
+		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
+		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
+		{.pdcp = {
+			.bearer = pdcp_test_bearer[i],
+			.domain = pdcp_test_params[i].domain,
+			.pkt_dir = pdcp_test_packet_direction[i],
+			.sn_size = pdcp_test_data_sn_size[i],
+			.hfn = pdcp_test_hfn[i],
+			.hfn_threshold = pdcp_test_hfn_threshold[i],
+		} },
+		.crypto_xform = &ut_params->cipher_xform
+	};
+
+	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
+				rte_cryptodev_get_sec_ctx(
+				ts_params->valid_devs[0]);
+
+	/* Create security session */
+	ut_params->sec_session = rte_security_session_create(ctx,
+				&sess_conf, ts_params->session_mpool);
+
+	if (!ut_params->sec_session) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__, "Failed to allocate session");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	/* Generate crypto op data structure */
+	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
+			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+	if (!ut_params->op) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__,
+			"Failed to allocate symmetric crypto operation struct");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	rte_security_attach_session(ut_params->op, ut_params->sec_session);
+
+	/* set crypto operation source mbuf */
+	ut_params->op->sym->m_src = ut_params->ibuf;
+	if (oop)
+		ut_params->op->sym->m_dst = ut_params->obuf;
+
+	/* Process crypto operation */
+	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
+		== NULL) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__,
+			"failed to process sym crypto op");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__, "crypto op processing failed");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	/* Validate obuf */
+	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
+			uint8_t *);
+	if (oop) {
+		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
+				uint8_t *);
+	}
+	if (fragsz_oop)
+		fragsz = frag_size_oop;
+	if (memcmp(ciphertext, output_vec, fragsz)) {
+		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
+		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
+		rte_hexdump(stdout, "reference", output_vec, fragsz);
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	buf = ut_params->op->sym->m_src->next;
+	if (oop)
+		buf = ut_params->op->sym->m_dst->next;
+
+	unsigned int off = fragsz;
+
+	ecx = 0;
+	while (buf) {
+		ciphertext = rte_pktmbuf_mtod(buf,
+				uint8_t *);
+		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
+			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
+			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
+			rte_hexdump(stdout, "reference", output_vec + off, to_trn_tbl[ecx]);
+			ret = TEST_FAILED;
+			goto on_err;
+		}
+		off += to_trn_tbl[ecx++];
+		buf = buf->next;
+	}
+on_err:
+	rte_crypto_op_free(ut_params->op);
+	ut_params->op = NULL;
+
+	if (ut_params->sec_session)
+		rte_security_session_destroy(ctx, ut_params->sec_session);
+	ut_params->sec_session = NULL;
+
+	rte_pktmbuf_free(ut_params->ibuf);
+	ut_params->ibuf = NULL;
+	if (oop) {
+		rte_pktmbuf_free(ut_params->obuf);
+		ut_params->obuf = NULL;
+	}
+
+	return ret;
+}
+
 int
 test_pdcp_proto_cplane_encap(int i)
 {
@@ -7279,6 +7549,67 @@ test_pdcp_proto_uplane_decap_with_int(int i)
 		pdcp_test_data_in_len[i]);
 }
 
+static int
+test_PDCP_PROTO_SGL_in_place_32B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is uplane 12-bit AES-SNOW DL encap */
+	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
+	return test_pdcp_proto_SGL(i, IN_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i]+4,
+			32, 0);
+}
+static int
+test_PDCP_PROTO_SGL_oop_32B_128B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is uplane 18-bit NULL-NULL DL encap */
+	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
+	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i]+4,
+			32, 128);
+}
+static int
+test_PDCP_PROTO_SGL_oop_32B_40B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is uplane 18-bit AES DL encap */
+	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
+			+ DOWNLINK;
+	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i],
+			32, 40);
+}
+static int
+test_PDCP_PROTO_SGL_oop_128B_32B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is cplane 12-bit AES-ZUC DL encap */
+	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
+	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i]+4,
+			128, 32);
+}
 #endif
 
 static int
@@ -11705,6 +12036,15 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_in_place_32B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_128B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_40B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_128B_32B),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11823,6 +12163,15 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_in_place_32B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_128B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_40B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_128B_32B),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
Signature · 1 line
2.17.1
#8 lore raw

PATCH 7/7 test/crypto: support wireless algos for dpaa2_sec

In reply to Akhil Goyal

SNOW and ZUC plain crypto operations for cipher only and auth only are now supported in dpaa2_sec.

---
 app/test/test_cryptodev.c | 64 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
app/test/test_cryptodev.c +64 -0
index 568fa84a9..f9fc2d44d 100644
@@ -12285,6 +12285,70 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
 
+		/** SNOW 3G encrypt only (UEA2) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_5),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop_sgl),
+
+		/** SNOW 3G decrypt only (UEA2) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_5),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_3),
+
+		/** ZUC encrypt only (EEA3) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_5),
+
+		/** ZUC authenticate (EIA3) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_hash_generate_test_case_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_hash_generate_test_case_7),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_hash_generate_test_case_8),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
Signature · 1 line
2.17.1
#9 lore raw

Re: [dpdk-dev] [PATCH 0/7] Add PDCP test cases

In reply to Akhil Goyal

Hi Anoob, Konstantin,

Any comments on this patchset.

Regards,
Akhil

Quoted 38 lines

This patch add test vectors and a test framework for PDCP cplane and uplane protocol processing based on various sequence number sizes(5/7/12/15/18).

These test cases and test vectors are validated over NXP DPAA_SEC and DPAA2_SEC platforms.

This patchset is a split to the patch [1] which was sent as RFC.

Further this patchset is dependent on [2]
[1] http://patches.dpdk.org/patch/58554/
[2] http://patches.dpdk.org/project/dpdk/list/?series=6199

Akhil Goyal (7):
test/crypto: Add PDCP cplane encap cases test/crypto: Add PDCP cplane decap cases test/crypto: Add PDCP uplane encap cases test/crypto: Add PDCP uplane encap with integrity cases test/crypto: Add PDCP uplane decap cases test/crypto: Add PDCP cases for scatter gather bufs test/crypto: support wireless algos for dpaa2_sec

 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  713 +-
 app/test/test_cryptodev_security_pdcp.c       |  590 ++
 .../test_cryptodev_security_pdcp_test_func.h  |   48 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 6323
+++++++++++++++++
 6 files changed, 7669 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644

app/test/test_cryptodev_security_pdcp_test_vectors.h

--
2.17.1

Acked-by on the v1 series
#10 lore raw

Re: [dpdk-dev] [PATCH 0/7] Add PDCP test cases

In reply to Akhil Goyal

Series

Quoted 58 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Akhil Goyal
Sent: Thursday, September 5, 2019 8:18 PM
To: [email protected]
Cc: Hemant Agrawal <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Vakul Garg <[email protected]>; Akhil Goyal <[email protected]>
Subject: [dpdk-dev] [PATCH 0/7] Add PDCP test cases

This patch add test vectors and a test framework for PDCP cplane and uplane protocol processing based on various sequence number sizes(5/7/12/15/18).

These test cases and test vectors are validated over NXP DPAA_SEC and DPAA2_SEC platforms.

This patchset is a split to the patch [1] which was sent as RFC.

Further this patchset is dependent on [2]
[1]
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
es.dpdk.org%2Fpatch%2F58554%2F&amp;data=02%7C01%7Cnipun.gupta%4 0nxp.com%7Ceb1d916e4f6c41a31b7a08d732120ef2%7C686ea1d3bc2b4c6fa9 2cd99c5c301635%7C0%7C0%7C637032925451063511&amp;sdata=aFlt8cawf8f eLEe6ju3w3heRJUVlWSGzhPwHZwKQ2Tk%3D&amp;reserved=0
[2]
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
es.dpdk.org%2Fproject%2Fdpdk%2Flist%2F%3Fseries%3D6199&amp;data=0 2%7C01%7Cnipun.gupta%40nxp.com%7Ceb1d916e4f6c41a31b7a08d732120ef 2%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63703292545107350 2&amp;sdata=f5IPo2%2F9mjrP1F4n%2FLzHKOEJOoCBBpR520oD0lchFxM%3D &amp;reserved=0

Akhil Goyal (7):
test/crypto: Add PDCP cplane encap cases test/crypto: Add PDCP cplane decap cases test/crypto: Add PDCP uplane encap cases test/crypto: Add PDCP uplane encap with integrity cases test/crypto: Add PDCP uplane decap cases test/crypto: Add PDCP cases for scatter gather bufs test/crypto: support wireless algos for dpaa2_sec

 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  713 +-
 app/test/test_cryptodev_security_pdcp.c       |  590 ++
 .../test_cryptodev_security_pdcp_test_func.h  |   48 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 6323
+++++++++++++++++
 6 files changed, 7669 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644

app/test/test_cryptodev_security_pdcp_test_vectors.h

--
2.17.1

#11 lore raw

v2 cover Add PDCP test cases

In reply to Akhil Goyal

This patch add test vectors and a test framework for PDCP cplane and uplane protocol processing based on various sequence number sizes(5/7/12/15/18).

These test cases and test vectors are validated over NXP DPAA_SEC and DPAA2_SEC platforms.

This patchset is a split to the patch [1] which was sent as RFC.

Changes in v2:
fix checkpatch warnings

Further this patchset is dependent on [2]
[1] http://patches.dpdk.org/patch/58554/
[2] http://patches.dpdk.org/project/dpdk/list/?series=6623

Akhil Goyal (7):
test/crypto: add PDCP cplane encap cases test/crypto: add PDCP cplane decap cases test/crypto: add PDCP uplane encap cases test/crypto: add PDCP uplane encap with integrity cases test/crypto: add PDCP uplane decap cases test/crypto: add PDCP cases for scatter gather bufs test/crypto: support wireless algos for dpaa2-sec

 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  715 +-
 app/test/test_cryptodev_security_pdcp.c       |  590 ++
 .../test_cryptodev_security_pdcp_test_func.h  |   48 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 6323 +++++++++++++++++
 6 files changed, 7671 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_vectors.h
Signature · 1 line
2.17.1
#12 lore raw

PATCH v2 1/7 test/crypto: add PDCP cplane encap cases

PDCP control plane can support 5 bit and 12 bit sequence number. This patch add test cases and test vectors for all supported algo combinations of cipher+integrity (NULL+NULL, NULL+AES, NULL+SNOW, NULL+ZUC,
AES+NULL, AES+SNOW, AES+AES, AES+ZUC,
SNOW+NULL, SNOW+AES, SNOW+SNOW, SNOW+ZUC,
ZUC+NULL, ZUC+AES, ZUC+SNOW, ZUC+ZUC).

The test cases are added in DPAA_SEC and DPAA2_SEC test suite as a reference.

---
 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  218 +-
 app/test/test_cryptodev_security_pdcp.c       |  140 +
 .../test_cryptodev_security_pdcp_test_func.h  |   36 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 2491 +++++++++++++++++
 6 files changed, 2880 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_vectors.h
app/test/Makefile +1 -0
index 26ba6fe2b..df7f77f44 100644
@@ -196,6 +196,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
+SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_cryptodev_security_pdcp.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_METRICS) += test_metrics.c
 
app/test/meson.build +1 -0
index ec40943bd..2c23c6347 100644
@@ -30,6 +30,7 @@ test_sources = files('commands.c',
 	'test_cryptodev.c',
 	'test_cryptodev_asym.c',
 	'test_cryptodev_blockcipher.c',
+	'test_cryptodev_security_pdcp.c',
 	'test_cycles.c',
 	'test_debug.c',
 	'test_distributor.c',
app/test/test_cryptodev.c +211 -7

254 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp.c new file +140 -0

140 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h new file +36 -0
new file mode 100644
index 000000000..ad1e7c70a
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 NXP
+ */
+
+#ifndef SECURITY_PDCP_TEST_FUNC_H_
+#define SECURITY_PDCP_TEST_FUNC_H_
+
+#define PDCP_CPLANE_OFFSET		0
+#define PDCP_CPLANE_LONG_SN_OFFSET	32
+#define LONG_SEQ_NUM_OFFSET		0
+#define SHORT_SEQ_NUM_OFFSET		2
+#define FIFTEEN_BIT_SEQ_NUM_OFFSET	4
+#define EIGHTEEN_BIT_SEQ_NUM_OFFSET	6
+#define UPLINK				0
+#define DOWNLINK			1
+/* key length(in bytes) for F8 */
+#define F8_KEY_LEN			16
+
+enum enc_alg_off {
+	NULL_ENC = 0,
+	SNOW_ENC = 8,
+	AES_ENC = 16,
+	ZUC_ENC = 24
+};
+enum auth_alg_off {
+	NULL_AUTH = 0,
+	SNOW_AUTH = 2,
+	AES_AUTH = 4,
+	ZUC_AUTH = 6
+};
+
+int test_pdcp_proto_cplane_encap(int i);
+
+int test_PDCP_PROTO_cplane_encap_all(void);
+
+#endif /* SECURITY_PDCP_TEST_FUNC_H_ */
app/test/test_cryptodev_security_pdcp_test_vectors.h new file +2491 -0

2,491 lines not on this page · raw message

Signature · 1 line
2.17.1
#13 lore raw

PATCH v2 2/7 test/crypto: add PDCP cplane decap cases

In reply to Akhil Goyal

This patch add test cases for control plane PDCP 5 and 12 bit SN test cases for decapsulation of cipher+integrity for all algo combinations

Test vectors are reused from the encap cases by swapping the input and output data.

The case are added to DPAA_SEC and DPAA2_SEC testsuite.

---
 app/test/test_cryptodev.c                     |  18 +++
 app/test/test_cryptodev_security_pdcp.c       | 105 ++++++++++++++++++
 .../test_cryptodev_security_pdcp_test_func.h  |   2 +
 3 files changed, 125 insertions(+)
app/test/test_cryptodev.c +18 -0
index 35fe16aaa..ac575c8a3 100644
@@ -7215,6 +7215,18 @@ test_pdcp_proto_cplane_encap(int i)
 		pdcp_test_data_in_len[i]+4);
 }
 
+int
+test_pdcp_proto_cplane_decap(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_DECRYPT,
+		RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i] + 4,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i]);
+}
+
 #endif
 
 static int
@@ -11632,6 +11644,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 #ifdef RTE_LIBRTE_SECURITY
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_cplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11741,6 +11756,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 #ifdef RTE_LIBRTE_SECURITY
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_cplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
app/test/test_cryptodev_security_pdcp.c +105 -0

114 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +2 -0
index ad1e7c70a..21a6e8a48 100644
@@ -30,7 +30,9 @@ enum auth_alg_off {
 };
 
 int test_pdcp_proto_cplane_encap(int i);
+int test_pdcp_proto_cplane_decap(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
+int test_PDCP_PROTO_cplane_decap_all(void);
 
 #endif /* SECURITY_PDCP_TEST_FUNC_H_ */
Signature · 1 line
2.17.1
#14 lore raw

PATCH v2 3/7 test/crypto: add PDCP uplane encap cases

In reply to Akhil Goyal

PDCP User/Data plane can support 5/7/12/15/18 bit sequence number. This patch add test cases and test vectors for all supported algos for cipher only. (NULL, AES, SNOW, ZUC ciphers)

The test cases are added in DPAA_SEC and DPAA2_SEC test suite as a reference.

---
 app/test/test_cryptodev.c                     |   19 +
 app/test/test_cryptodev_security_pdcp.c       |   73 ++
 .../test_cryptodev_security_pdcp_test_func.h  |    6 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 1113 +++++++++++++++++
 4 files changed, 1211 insertions(+)
app/test/test_cryptodev.c +19 -0
index ac575c8a3..86ead9c27 100644
@@ -7215,6 +7215,19 @@ test_pdcp_proto_cplane_encap(int i)
 		pdcp_test_data_in_len[i]+4);
 }
 
+int
+test_pdcp_proto_uplane_encap(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+		RTE_CRYPTO_AUTH_OP_GENERATE,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i],
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i]);
+
+}
+
 int
 test_pdcp_proto_cplane_decap(int i)
 {
@@ -11647,6 +11660,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_encap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11759,6 +11775,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_cplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_encap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
app/test/test_cryptodev_security_pdcp.c +73 -0

82 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +6 -0
index 21a6e8a48..7051790c8 100644
@@ -7,6 +7,7 @@
 
 #define PDCP_CPLANE_OFFSET		0
 #define PDCP_CPLANE_LONG_SN_OFFSET	32
+#define PDCP_UPLANE_OFFSET		64
 #define LONG_SEQ_NUM_OFFSET		0
 #define SHORT_SEQ_NUM_OFFSET		2
 #define FIFTEEN_BIT_SEQ_NUM_OFFSET	4
@@ -16,6 +17,9 @@
 /* key length(in bytes) for F8 */
 #define F8_KEY_LEN			16
 
+#define PDCP_UPLANE_12BIT_OFFSET	(PDCP_UPLANE_OFFSET + 32)
+#define PDCP_UPLANE_18BIT_OFFSET	(PDCP_UPLANE_12BIT_OFFSET + 32)
+
 enum enc_alg_off {
 	NULL_ENC = 0,
 	SNOW_ENC = 8,
@@ -30,9 +34,11 @@ enum auth_alg_off {
 };
 
 int test_pdcp_proto_cplane_encap(int i);
+int test_pdcp_proto_uplane_encap(int i);
 int test_pdcp_proto_cplane_decap(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
 int test_PDCP_PROTO_cplane_decap_all(void);
+int test_PDCP_PROTO_uplane_encap_all(void);
 
 #endif /* SECURITY_PDCP_TEST_FUNC_H_ */
app/test/test_cryptodev_security_pdcp_test_vectors.h +1113 -0

1,179 lines not on this page · raw message

Signature · 1 line
2.17.1
#15 lore raw

PATCH v2 4/7 test/crypto: add PDCP uplane encap with integrity cases

In reply to Akhil Goyal

PDCP User/Data plane can optionally support integrity along with confidentiality.
This patch add test cases and test vectors for all supported algos combos for cipher+integrity for 12 and 18bit SN.

The test cases are added in DPAA_SEC and DPAA2_SEC test suite as a reference.

---
 app/test/test_cryptodev.c                     |   12 +
 app/test/test_cryptodev_security_pdcp.c       |   99 +
 .../test_cryptodev_security_pdcp_test_func.h  |    1 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 4079 ++++++++++++++---
 4 files changed, 3511 insertions(+), 680 deletions(-)
app/test/test_cryptodev.c +12 -0
index 86ead9c27..4666317aa 100644
@@ -7228,6 +7228,18 @@ test_pdcp_proto_uplane_encap(int i)
 
 }
 
+int
+test_pdcp_proto_uplane_encap_with_int(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+		RTE_CRYPTO_AUTH_OP_GENERATE,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i],
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i] + 4);
+}
+
 int
 test_pdcp_proto_cplane_decap(int i)
 {
app/test/test_cryptodev_security_pdcp.c +99 -0

111 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +1 -0
index 7051790c8..473cdaecc 100644
@@ -35,6 +35,7 @@ enum auth_alg_off {
 
 int test_pdcp_proto_cplane_encap(int i);
 int test_pdcp_proto_uplane_encap(int i);
+int test_pdcp_proto_uplane_encap_with_int(int i);
 int test_pdcp_proto_cplane_decap(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
app/test/test_cryptodev_security_pdcp_test_vectors.h +3399 -680

2,864 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#16 lore raw

PATCH v2 5/7 test/crypto: add PDCP uplane decap cases

In reply to Akhil Goyal

This patch add test cases for user plane PDCP 5/7/12/15/18 bit SN test cases for decapsulation of cipher only and 12/18 bit for cipher + integrity for all algo combinations.

Test vectors are reused from the encap cases by swapping the input and output data.

The case are added to DPAA_SEC and DPAA2_SEC testsuite.

---
 app/test/test_cryptodev.c                     |  30 +++
 app/test/test_cryptodev_security_pdcp.c       | 173 ++++++++++++++++++
 .../test_cryptodev_security_pdcp_test_func.h  |   3 +
 3 files changed, 206 insertions(+)
app/test/test_cryptodev.c +30 -0
index 4666317aa..afc296bf9 100644
@@ -7252,6 +7252,30 @@ test_pdcp_proto_cplane_decap(int i)
 		pdcp_test_data_in_len[i]);
 }
 
+int
+test_pdcp_proto_uplane_decap(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_DECRYPT,
+		RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i],
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i]);
+}
+
+int
+test_pdcp_proto_uplane_decap_with_int(int i)
+{
+	return test_pdcp_proto(i, 0,
+		RTE_CRYPTO_CIPHER_OP_DECRYPT,
+		RTE_CRYPTO_AUTH_OP_VERIFY,
+		pdcp_test_data_out[i],
+		pdcp_test_data_in_len[i] + 4,
+		pdcp_test_data_in[i],
+		pdcp_test_data_in_len[i]);
+}
+
 #endif
 
 static int
@@ -11675,6 +11699,9 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11790,6 +11817,9 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_encap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_uplane_decap_all),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
app/test/test_cryptodev_security_pdcp.c +173 -0

188 lines not on this page · raw message

app/test/test_cryptodev_security_pdcp_test_func.h +3 -0
index 473cdaecc..f3dc93e2f 100644
@@ -37,9 +37,12 @@ int test_pdcp_proto_cplane_encap(int i);
 int test_pdcp_proto_uplane_encap(int i);
 int test_pdcp_proto_uplane_encap_with_int(int i);
 int test_pdcp_proto_cplane_decap(int i);
+int test_pdcp_proto_uplane_decap(int i);
+int test_pdcp_proto_uplane_decap_with_int(int i);
 
 int test_PDCP_PROTO_cplane_encap_all(void);
 int test_PDCP_PROTO_cplane_decap_all(void);
 int test_PDCP_PROTO_uplane_encap_all(void);
+int test_PDCP_PROTO_uplane_decap_all(void);
 
 #endif /* SECURITY_PDCP_TEST_FUNC_H_ */
Signature · 1 line
2.17.1
#17 lore raw

PATCH v2 6/7 test/crypto: add PDCP cases for scatter gather bufs

In reply to Akhil Goyal

Test cases for PDCP with scattered input and output buffers are added for both inplace and out of place scenarios.
1. input SG - output non SG
2. input and output both SG and inplace buffers
3. input and output both SG with different segment sizes
4. input SG and output non-SG

---
 app/test/test_cryptodev.c | 354 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 354 insertions(+)
app/test/test_cryptodev.c +354 -0
index afc296bf9..ca6c35c87 100644
@@ -7203,6 +7203,277 @@ test_pdcp_proto(int i, int oop,
 	return ret;
 }
 
+static int
+test_pdcp_proto_SGL(int i, int oop,
+	enum rte_crypto_cipher_operation opc,
+	enum rte_crypto_auth_operation opa,
+	uint8_t *input_vec,
+	unsigned int input_vec_len,
+	uint8_t *output_vec,
+	unsigned int output_vec_len,
+	uint32_t fragsz,
+	uint32_t fragsz_oop)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	uint8_t *plaintext;
+	struct rte_mbuf *buf, *buf_oop = NULL;
+	int ret = TEST_SUCCESS;
+	int to_trn = 0;
+	int to_trn_tbl[16];
+	int segs = 1;
+	unsigned int trn_data = 0;
+
+	if (fragsz > input_vec_len)
+		fragsz = input_vec_len;
+
+	uint16_t plaintext_len = fragsz;
+	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
+
+	if (fragsz_oop > output_vec_len)
+		frag_size_oop = output_vec_len;
+
+	int ecx = 0;
+	if (input_vec_len % fragsz != 0) {
+		if (input_vec_len / fragsz + 1 > 16)
+			return 1;
+	} else if (input_vec_len / fragsz > 16)
+		return 1;
+
+	/* Out of place support */
+	if (oop) {
+		/*
+		 * For out-op-place we need to alloc another mbuf
+		 */
+		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
+		buf_oop = ut_params->obuf;
+	}
+
+	/* Generate test mbuf data */
+	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+	/* clear mbuf payload */
+	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+			rte_pktmbuf_tailroom(ut_params->ibuf));
+
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+						  plaintext_len);
+	memcpy(plaintext, input_vec, plaintext_len);
+	trn_data += plaintext_len;
+
+	buf = ut_params->ibuf;
+
+	/*
+	 * Loop until no more fragments
+	 */
+
+	while (trn_data < input_vec_len) {
+		++segs;
+		to_trn = (input_vec_len - trn_data < fragsz) ?
+				(input_vec_len - trn_data) : fragsz;
+
+		to_trn_tbl[ecx++] = to_trn;
+
+		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+		buf = buf->next;
+
+		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
+				rte_pktmbuf_tailroom(buf));
+
+		/* OOP */
+		if (oop && !fragsz_oop) {
+			buf_oop->next =
+					rte_pktmbuf_alloc(ts_params->mbuf_pool);
+			buf_oop = buf_oop->next;
+			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
+					0, rte_pktmbuf_tailroom(buf_oop));
+			rte_pktmbuf_append(buf_oop, to_trn);
+		}
+
+		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
+				to_trn);
+
+		memcpy(plaintext, input_vec + trn_data, to_trn);
+		trn_data += to_trn;
+	}
+
+	ut_params->ibuf->nb_segs = segs;
+
+	segs = 1;
+	if (fragsz_oop && oop) {
+		to_trn = 0;
+		ecx = 0;
+
+		trn_data = frag_size_oop;
+		while (trn_data < output_vec_len) {
+			++segs;
+			to_trn =
+				(output_vec_len - trn_data <
+						frag_size_oop) ?
+				(output_vec_len - trn_data) :
+						frag_size_oop;
+
+			to_trn_tbl[ecx++] = to_trn;
+
+			buf_oop->next =
+				rte_pktmbuf_alloc(ts_params->mbuf_pool);
+			buf_oop = buf_oop->next;
+			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
+					0, rte_pktmbuf_tailroom(buf_oop));
+			rte_pktmbuf_append(buf_oop, to_trn);
+
+			trn_data += to_trn;
+		}
+		ut_params->obuf->nb_segs = segs;
+	}
+
+	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
+
+	/* Setup Cipher Parameters */
+	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
+	ut_params->cipher_xform.cipher.op = opc;
+	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
+	ut_params->cipher_xform.cipher.key.length =
+					pdcp_test_params[i].cipher_key_len;
+	ut_params->cipher_xform.cipher.iv.length = 0;
+
+	/* Setup HMAC Parameters if ICV header is required */
+	if (pdcp_test_params[i].auth_alg != 0) {
+		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
+		ut_params->auth_xform.next = NULL;
+		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
+		ut_params->auth_xform.auth.op = opa;
+		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
+		ut_params->auth_xform.auth.key.length =
+					pdcp_test_params[i].auth_key_len;
+
+		ut_params->cipher_xform.next = &ut_params->auth_xform;
+	} else {
+		ut_params->cipher_xform.next = NULL;
+	}
+
+	struct rte_security_session_conf sess_conf = {
+		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
+		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
+		{.pdcp = {
+			.bearer = pdcp_test_bearer[i],
+			.domain = pdcp_test_params[i].domain,
+			.pkt_dir = pdcp_test_packet_direction[i],
+			.sn_size = pdcp_test_data_sn_size[i],
+			.hfn = pdcp_test_hfn[i],
+			.hfn_threshold = pdcp_test_hfn_threshold[i],
+		} },
+		.crypto_xform = &ut_params->cipher_xform
+	};
+
+	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
+				rte_cryptodev_get_sec_ctx(
+				ts_params->valid_devs[0]);
+
+	/* Create security session */
+	ut_params->sec_session = rte_security_session_create(ctx,
+				&sess_conf, ts_params->session_mpool);
+
+	if (!ut_params->sec_session) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__, "Failed to allocate session");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	/* Generate crypto op data structure */
+	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
+			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+	if (!ut_params->op) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__,
+			"Failed to allocate symmetric crypto operation struct");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	rte_security_attach_session(ut_params->op, ut_params->sec_session);
+
+	/* set crypto operation source mbuf */
+	ut_params->op->sym->m_src = ut_params->ibuf;
+	if (oop)
+		ut_params->op->sym->m_dst = ut_params->obuf;
+
+	/* Process crypto operation */
+	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
+		== NULL) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__,
+			"failed to process sym crypto op");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+		printf("TestCase %s()-%d line %d failed %s: ",
+			__func__, i, __LINE__, "crypto op processing failed");
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	/* Validate obuf */
+	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
+			uint8_t *);
+	if (oop) {
+		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
+				uint8_t *);
+	}
+	if (fragsz_oop)
+		fragsz = frag_size_oop;
+	if (memcmp(ciphertext, output_vec, fragsz)) {
+		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
+		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
+		rte_hexdump(stdout, "reference", output_vec, fragsz);
+		ret = TEST_FAILED;
+		goto on_err;
+	}
+
+	buf = ut_params->op->sym->m_src->next;
+	if (oop)
+		buf = ut_params->op->sym->m_dst->next;
+
+	unsigned int off = fragsz;
+
+	ecx = 0;
+	while (buf) {
+		ciphertext = rte_pktmbuf_mtod(buf,
+				uint8_t *);
+		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
+			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
+			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
+			rte_hexdump(stdout, "reference", output_vec + off,
+					to_trn_tbl[ecx]);
+			ret = TEST_FAILED;
+			goto on_err;
+		}
+		off += to_trn_tbl[ecx++];
+		buf = buf->next;
+	}
+on_err:
+	rte_crypto_op_free(ut_params->op);
+	ut_params->op = NULL;
+
+	if (ut_params->sec_session)
+		rte_security_session_destroy(ctx, ut_params->sec_session);
+	ut_params->sec_session = NULL;
+
+	rte_pktmbuf_free(ut_params->ibuf);
+	ut_params->ibuf = NULL;
+	if (oop) {
+		rte_pktmbuf_free(ut_params->obuf);
+		ut_params->obuf = NULL;
+	}
+
+	return ret;
+}
+
 int
 test_pdcp_proto_cplane_encap(int i)
 {
@@ -7276,6 +7547,71 @@ test_pdcp_proto_uplane_decap_with_int(int i)
 		pdcp_test_data_in_len[i]);
 }
 
+static int
+test_PDCP_PROTO_SGL_in_place_32B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is uplane 12-bit AES-SNOW DL encap
+	 */
+	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
+	return test_pdcp_proto_SGL(i, IN_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i]+4,
+			32, 0);
+}
+static int
+test_PDCP_PROTO_SGL_oop_32B_128B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is uplane 18-bit NULL-NULL DL encap
+	 */
+	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
+	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i]+4,
+			32, 128);
+}
+static int
+test_PDCP_PROTO_SGL_oop_32B_40B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is uplane 18-bit AES DL encap
+	 */
+	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
+			+ DOWNLINK;
+	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i],
+			32, 40);
+}
+static int
+test_PDCP_PROTO_SGL_oop_128B_32B(void)
+{
+	/* i can be used for running any PDCP case
+	 * In this case it is cplane 12-bit AES-ZUC DL encap
+	 */
+	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
+	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
+			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			pdcp_test_data_in[i],
+			pdcp_test_data_in_len[i],
+			pdcp_test_data_out[i],
+			pdcp_test_data_in_len[i]+4,
+			128, 32);
+}
 #endif
 
 static int
@@ -11702,6 +12038,15 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_in_place_32B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_128B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_40B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_128B_32B),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11820,6 +12165,15 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_PDCP_PROTO_uplane_decap_all),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_in_place_32B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_128B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_32B_40B),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_PDCP_PROTO_SGL_oop_128B_32B),
 #endif
 		/** AES GCM Authenticated Encryption */
 		TEST_CASE_ST(ut_setup, ut_teardown,
Signature · 1 line
2.17.1
#18 lore raw

PATCH v2 7/7 test/crypto: support wireless algos for dpaa2-sec

In reply to Akhil Goyal

SNOW and ZUC plain crypto operations for cipher only and auth only are now supported in dpaa2_sec.

---
 app/test/test_cryptodev.c | 64 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
app/test/test_cryptodev.c +64 -0
index ca6c35c87..bb5ff3c89 100644
@@ -12287,6 +12287,70 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
 
+		/** SNOW 3G encrypt only (UEA2) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_5),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop_sgl),
+
+		/** SNOW 3G decrypt only (UEA2) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_5),
+
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_3),
+
+		/** ZUC encrypt only (EEA3) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_encryption_test_case_5),
+
+		/** ZUC authenticate (EIA3) */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_hash_generate_test_case_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_hash_generate_test_case_7),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_zuc_hash_generate_test_case_8),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
Signature · 1 line
2.17.1
#19 lore raw

Re: [dpdk-dev] [PATCH v2 0/7] Add PDCP test cases

In reply to Akhil Goyal
Quoted 50 lines

This patch add test vectors and a test framework for PDCP cplane and uplane protocol processing based on various sequence number sizes(5/7/12/15/18).

These test cases and test vectors are validated over NXP DPAA_SEC and DPAA2_SEC platforms.

This patchset is a split to the patch [1] which was sent as RFC.

Changes in v2:
fix checkpatch warnings

Further this patchset is dependent on [2]
[1]
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.d
pdk.org%2Fpatch%2F58554%2F&amp;data=02%7C01%7Cakhil.goyal%40nxp.co m%7Cdf8803416fca4c88f3cb08d745de67ae%7C686ea1d3bc2b4c6fa92cd99c5c 301635%7C0%7C0%7C637054693829071299&amp;sdata=%2BcE1X8iiVVX%2B7 D3QHScFjSdhYNaDdLuAuxzHri4ClL8%3D&amp;reserved=0
[2]
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.d
pdk.org%2Fproject%2Fdpdk%2Flist%2F%3Fseries%3D6623&amp;data=02%7C01 %7Cakhil.goyal%40nxp.com%7Cdf8803416fca4c88f3cb08d745de67ae%7C686e a1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637054693829081293&amp;sd ata=GZhpFRgIWjlvVowx1AruRBpM%2F2fhdnaeM9Mmai9%2FxP4%3D&amp;rese rved=0

Akhil Goyal (7):
test/crypto: add PDCP cplane encap cases test/crypto: add PDCP cplane decap cases test/crypto: add PDCP uplane encap cases test/crypto: add PDCP uplane encap with integrity cases test/crypto: add PDCP uplane decap cases test/crypto: add PDCP cases for scatter gather bufs test/crypto: support wireless algos for dpaa2-sec

 app/test/Makefile                             |    1 +
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev.c                     |  715 +-
 app/test/test_cryptodev_security_pdcp.c       |  590 ++
 .../test_cryptodev_security_pdcp_test_func.h  |   48 +
 ...est_cryptodev_security_pdcp_test_vectors.h | 6323 +++++++++++++++++
 6 files changed, 7671 insertions(+), 7 deletions(-)
 create mode 100644 app/test/test_cryptodev_security_pdcp.c
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_func.h
 create mode 100644 app/test/test_cryptodev_security_pdcp_test_vectors.h
Quoted 2 lines

--
2.17.1

Series Applied to dpdk-next-crypto