DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] test: add snow3g test cases when digest is encrypted
@ 2019-02-13  8:43 Lukasz Krakowiak
  2019-02-13 10:20 ` Lukasz Krakowiak
  2019-02-27 10:18 ` [dpdk-dev] [PATCH v2] " Lukasz Krakowiak
  0 siblings, 2 replies; 14+ messages in thread
From: Lukasz Krakowiak @ 2019-02-13  8:43 UTC (permalink / raw)
  To: pablo.de.lara.guarch; +Cc: dev, stable, Lukasz Krakowiak

Add test case for encryption, dectryption for snow3g when digest
is encrypted

Change-Id: I75bb535fa46ae23104f17d9c51278eca2c76e021
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 test/test/test_cryptodev.c                    |  91 ++++++++++--
 .../test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
 2 files changed, 210 insertions(+), 13 deletions(-)

diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 32f1893bc..d8acfc7d1 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -2833,8 +2833,8 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-			ut_params->ibuf, auth_tag_len);
+	sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
+			ut_params->ibuf, uint8_t *, data_pad_len);
 
 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
 			"no room to append auth tag");
@@ -2844,10 +2844,6 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 
 	memset(sym_op->auth.digest.data, 0, auth_tag_len);
 
-	debug_hexdump(stdout, "digest:",
-			sym_op->auth.digest.data,
-			auth_tag_len);
-
 	/* Copy cipher and auth IVs at the end of the crypto operation */
 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
 						IV_OFFSET);
@@ -4052,7 +4048,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
 					tdata->cipher_iv.len,
 					tdata->validCipherLenInBits.len,
-					0);
+					tdata->cipher.offset_bits);
 	if (retval < 0)
 		return retval;
 
@@ -4360,11 +4356,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		tdata->digest.len,
 		tdata->cipher_iv.data, tdata->cipher_iv.len,
 		tdata->auth_iv.data, tdata->auth_iv.len,
-		plaintext_pad_len,
+		tdata->digest.offset_bytes == 0 ?
+		plaintext_pad_len : tdata->digest.offset_bytes,
 		tdata->validCipherLenInBits.len,
-		0,
+		tdata->cipher.offset_bits,
 		tdata->validAuthLenInBits.len,
-		0);
+		tdata->auth.offset_bits);
 
 	if (retval < 0)
 		return retval;
@@ -4379,7 +4376,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		ciphertext = plaintext;
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+			+ (tdata->digest.offset_bytes == 0 ?
+			plaintext_pad_len : tdata->digest.offset_bytes);
+
+	debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
 
 	/* Validate obuf */
@@ -4973,6 +4973,61 @@ test_snow3g_decryption_test_case_5(void)
 {
 	return test_snow3g_decryption(&snow3g_test_case_5);
 }
+
+/*
+ * Function prepares snow3g_hash_test_data from snow3g_test_data.
+ * Pattern digest from snow3g_test_data must be allocated as
+ * 4 last bytes in plaintext.
+ */
+static void
+snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
+		struct snow3g_hash_test_data *output)
+{
+	if ((pattern != NULL) && (output != NULL)) {
+		output->key.len = pattern->key.len;
+
+		memcpy(output->key.data,
+		pattern->key.data, pattern->key.len);
+
+		output->auth_iv.len = pattern->auth_iv.len;
+
+		memcpy(output->auth_iv.data,
+		pattern->auth_iv.data, pattern->auth_iv.len);
+
+		output->plaintext.len = pattern->plaintext.len;
+
+		memcpy(output->plaintext.data,
+		pattern->plaintext.data, pattern->plaintext.len >> 3);
+
+		output->digest.len = pattern->digest.len;
+
+		memcpy(output->digest.data,
+		&pattern->plaintext.data[pattern->digest.offset_bytes],
+		pattern->digest.len);
+
+		output->validAuthLenInBits.len =
+		pattern->validAuthLenInBits.len;
+	}
+}
+
+/*
+ * Test case verify computed cipher and digest from snow3g_test_case_7 data.
+ */
+static int
+test_snow3g_decryption_with_digest_test_case_1(void)
+{
+	struct snow3g_hash_test_data snow3g_hash_data;
+
+	/*
+	 * Function prepare data for hash veryfication test case.
+	 * Digest is allocated in 4 last bytes in plaintext, pattern.
+	 */
+	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
+
+	return test_snow3g_decryption(&snow3g_test_case_7) &
+			test_snow3g_authentication_verify(&snow3g_hash_data);
+}
+
 static int
 test_snow3g_cipher_auth_test_case_1(void)
 {
@@ -4985,6 +5040,12 @@ test_snow3g_auth_cipher_test_case_1(void)
 	return test_snow3g_auth_cipher(&snow3g_test_case_6);
 }
 
+static int
+test_snow3g_auth_cipher_with_digest_test_case_1(void)
+{
+	return test_snow3g_auth_cipher(&snow3g_test_case_7);
+}
+
 static int
 test_kasumi_auth_cipher_test_case_1(void)
 {
@@ -9138,6 +9199,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9154,6 +9217,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			test_snow3g_cipher_auth_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_auth_cipher_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_auth_cipher_with_digest_test_case_1),
 
 		/** ZUC encrypt only (EEA3) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9872,6 +9937,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_auth_cipher_with_digest_test_case_1),
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_1_oop),
@@ -9894,6 +9961,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/test/test/test_cryptodev_snow3g_test_vectors.h b/test/test/test_cryptodev_snow3g_test_vectors.h
index cb9dc4b35..3e55ac1f9 100644
--- a/test/test/test_cryptodev_snow3g_test_vectors.h
+++ b/test/test/test_cryptodev_snow3g_test_vectors.h
@@ -45,8 +45,19 @@ struct snow3g_test_data {
 
 	struct {
 		uint8_t data[64];
-		unsigned len;
+		unsigned int len; /* length must be in Bytes */
+		unsigned int offset_bytes; /* offset must be in Bytes */
 	} digest;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} cipher;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} auth;
 };
 struct snow3g_test_data snow3g_test_case_1 = {
 	.key = {
@@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 = {
 		},
 		.len = 800
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 798
 	},
@@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 = {
 		},
 		.len = 512
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 510
 	},
@@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 = {
 		},
 		.len = 120
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 120
 	},
@@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 = {
 		},
 		.len = 256
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 253
 	},
@@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 = {
 		},
 		.len = 840
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 837
 	},
@@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 = {
 		},
 		.len = 384
 	},
+	.cipher = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
+	.auth = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
 	.digest = {
 		.data = {0x38, 0xB5, 0x54, 0xC0 },
-		.len  = 4
+		.len  = 4,
+		.offset_bytes = 0
 	},
 	.validDataLenInBits = {
 		.len = 384
@@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 = {
 	},
 };
 
+
+struct snow3g_test_data snow3g_test_case_7 = {
+	.key = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
+
+			},
+		.len = 16
+	},
+	.cipher_iv = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
+		},
+		.len = 16
+	},
+	.auth_iv = {
+		.data = {
+			 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0xF1,  0x9E,  0x2B,  0x6F,
+		},
+		.len = 128 << 3
+	},
+	.ciphertext = {
+		.data = {
+			0x5A,  0x5A,  0xE4,  0xAD,  0x29,  0xA2,  0x6A,  0xA6,
+			0x20,  0x1D,  0xCD,  0x08,  0x50,  0xD6,  0xE6,  0x47,
+			0xBC,  0x88,  0x08,  0x01,  0x17,  0xFA,  0x47,  0x5B,
+			0x90,  0x40,  0xBA,  0x0C,  0xB5,  0x58,  0xF3,  0x0C,
+			0xA0,  0xD4,  0x98,  0x83,  0x1B,  0xCE,  0x54,  0xE3,
+			0x29,  0x00,  0x3C,  0xA4,  0xAD,  0x74,  0xEE,  0x05,
+			0xA3,  0x6C,  0xD4,  0xAC,  0xC6,  0x30,  0x33,  0xC9,
+			0x37,  0x57,  0x41,  0x9B,  0xD4,  0x73,  0xB9,  0x77,
+			0x70,  0x8B,  0x63,  0xDD,  0x22,  0xB8,  0xE1,  0x85,
+			0xB2,  0x92,  0x7C,  0x37,  0xD3,  0x2E,  0xD9,  0xF4,
+			0x4A,  0x69,  0x25,  0x30,  0xE3,  0x5B,  0x8B,  0xF6,
+			0x0F,  0xDE,  0x0B,  0x92,  0xD5,  0x25,  0x52,  0x6D,
+			0x26,  0xEB,  0x2F,  0x8A,  0x3B,  0x8B,  0x38,  0xE2,
+			0x48,  0xD3,  0x4A,  0x98,  0xF7,  0x3A,  0xC2,  0x46,
+			0x69,  0x8D,  0x73,  0x3E,  0x57,  0x88,  0x2C,  0x80,
+			0xF0,  0xF2,  0x75,  0xB8,  0x7D,  0x27,  0xC6,  0xDA,
+
+		},
+		.len = 128 << 3
+	},
+	.cipher = {
+		.len_bits = 126 << 3,
+		.offset_bits = 2 << 3
+	},
+	.auth = {
+		.len_bits = 124 << 3,
+		.offset_bits = 0
+	},
+	.digest = {
+		.data = {
+			0x7D, 0x27, 0xC6, 0xDA
+		},
+		.len = 4,
+		.offset_bytes = 124
+	},
+	.validDataLenInBits = {
+		.len = 128 << 3
+	},
+	.validCipherLenInBits = {
+		.len = 126 << 3
+	},
+	.validAuthLenInBits = {
+		.len = 124 << 3
+	},
+};
+
 #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */
-- 
2.19.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [dpdk-dev] [PATCH] test: add snow3g test cases when digest is encrypted
  2019-02-13  8:43 [dpdk-dev] [PATCH] test: add snow3g test cases when digest is encrypted Lukasz Krakowiak
@ 2019-02-13 10:20 ` Lukasz Krakowiak
  2019-02-27 10:18 ` [dpdk-dev] [PATCH v2] " Lukasz Krakowiak
  1 sibling, 0 replies; 14+ messages in thread
From: Lukasz Krakowiak @ 2019-02-13 10:20 UTC (permalink / raw)
  To: pablo.de.lara.guarch; +Cc: dev, stable, fiona.trahe, Lukasz Krakowiak

Add test case for encryption, dectryption for snow3g when digest
is encrypted

Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 test/test/test_cryptodev.c                    |  91 ++++++++++--
 .../test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
 2 files changed, 210 insertions(+), 13 deletions(-)

diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 32f1893bc..d8acfc7d1 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -2833,8 +2833,8 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-			ut_params->ibuf, auth_tag_len);
+	sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
+			ut_params->ibuf, uint8_t *, data_pad_len);
 
 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
 			"no room to append auth tag");
@@ -2844,10 +2844,6 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 
 	memset(sym_op->auth.digest.data, 0, auth_tag_len);
 
-	debug_hexdump(stdout, "digest:",
-			sym_op->auth.digest.data,
-			auth_tag_len);
-
 	/* Copy cipher and auth IVs at the end of the crypto operation */
 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
 						IV_OFFSET);
@@ -4052,7 +4048,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
 					tdata->cipher_iv.len,
 					tdata->validCipherLenInBits.len,
-					0);
+					tdata->cipher.offset_bits);
 	if (retval < 0)
 		return retval;
 
@@ -4360,11 +4356,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		tdata->digest.len,
 		tdata->cipher_iv.data, tdata->cipher_iv.len,
 		tdata->auth_iv.data, tdata->auth_iv.len,
-		plaintext_pad_len,
+		tdata->digest.offset_bytes == 0 ?
+		plaintext_pad_len : tdata->digest.offset_bytes,
 		tdata->validCipherLenInBits.len,
-		0,
+		tdata->cipher.offset_bits,
 		tdata->validAuthLenInBits.len,
-		0);
+		tdata->auth.offset_bits);
 
 	if (retval < 0)
 		return retval;
@@ -4379,7 +4376,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		ciphertext = plaintext;
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+			+ (tdata->digest.offset_bytes == 0 ?
+			plaintext_pad_len : tdata->digest.offset_bytes);
+
+	debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
 
 	/* Validate obuf */
@@ -4973,6 +4973,61 @@ test_snow3g_decryption_test_case_5(void)
 {
 	return test_snow3g_decryption(&snow3g_test_case_5);
 }
+
+/*
+ * Function prepares snow3g_hash_test_data from snow3g_test_data.
+ * Pattern digest from snow3g_test_data must be allocated as
+ * 4 last bytes in plaintext.
+ */
+static void
+snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
+		struct snow3g_hash_test_data *output)
+{
+	if ((pattern != NULL) && (output != NULL)) {
+		output->key.len = pattern->key.len;
+
+		memcpy(output->key.data,
+		pattern->key.data, pattern->key.len);
+
+		output->auth_iv.len = pattern->auth_iv.len;
+
+		memcpy(output->auth_iv.data,
+		pattern->auth_iv.data, pattern->auth_iv.len);
+
+		output->plaintext.len = pattern->plaintext.len;
+
+		memcpy(output->plaintext.data,
+		pattern->plaintext.data, pattern->plaintext.len >> 3);
+
+		output->digest.len = pattern->digest.len;
+
+		memcpy(output->digest.data,
+		&pattern->plaintext.data[pattern->digest.offset_bytes],
+		pattern->digest.len);
+
+		output->validAuthLenInBits.len =
+		pattern->validAuthLenInBits.len;
+	}
+}
+
+/*
+ * Test case verify computed cipher and digest from snow3g_test_case_7 data.
+ */
+static int
+test_snow3g_decryption_with_digest_test_case_1(void)
+{
+	struct snow3g_hash_test_data snow3g_hash_data;
+
+	/*
+	 * Function prepare data for hash veryfication test case.
+	 * Digest is allocated in 4 last bytes in plaintext, pattern.
+	 */
+	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
+
+	return test_snow3g_decryption(&snow3g_test_case_7) &
+			test_snow3g_authentication_verify(&snow3g_hash_data);
+}
+
 static int
 test_snow3g_cipher_auth_test_case_1(void)
 {
@@ -4985,6 +5040,12 @@ test_snow3g_auth_cipher_test_case_1(void)
 	return test_snow3g_auth_cipher(&snow3g_test_case_6);
 }
 
+static int
+test_snow3g_auth_cipher_with_digest_test_case_1(void)
+{
+	return test_snow3g_auth_cipher(&snow3g_test_case_7);
+}
+
 static int
 test_kasumi_auth_cipher_test_case_1(void)
 {
@@ -9138,6 +9199,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9154,6 +9217,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			test_snow3g_cipher_auth_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_auth_cipher_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_auth_cipher_with_digest_test_case_1),
 
 		/** ZUC encrypt only (EEA3) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9872,6 +9937,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_auth_cipher_with_digest_test_case_1),
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_1_oop),
@@ -9894,6 +9961,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/test/test/test_cryptodev_snow3g_test_vectors.h b/test/test/test_cryptodev_snow3g_test_vectors.h
index cb9dc4b35..3e55ac1f9 100644
--- a/test/test/test_cryptodev_snow3g_test_vectors.h
+++ b/test/test/test_cryptodev_snow3g_test_vectors.h
@@ -45,8 +45,19 @@ struct snow3g_test_data {
 
 	struct {
 		uint8_t data[64];
-		unsigned len;
+		unsigned int len; /* length must be in Bytes */
+		unsigned int offset_bytes; /* offset must be in Bytes */
 	} digest;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} cipher;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} auth;
 };
 struct snow3g_test_data snow3g_test_case_1 = {
 	.key = {
@@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 = {
 		},
 		.len = 800
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 798
 	},
@@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 = {
 		},
 		.len = 512
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 510
 	},
@@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 = {
 		},
 		.len = 120
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 120
 	},
@@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 = {
 		},
 		.len = 256
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 253
 	},
@@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 = {
 		},
 		.len = 840
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 837
 	},
@@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 = {
 		},
 		.len = 384
 	},
+	.cipher = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
+	.auth = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
 	.digest = {
 		.data = {0x38, 0xB5, 0x54, 0xC0 },
-		.len  = 4
+		.len  = 4,
+		.offset_bytes = 0
 	},
 	.validDataLenInBits = {
 		.len = 384
@@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 = {
 	},
 };
 
+
+struct snow3g_test_data snow3g_test_case_7 = {
+	.key = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
+
+			},
+		.len = 16
+	},
+	.cipher_iv = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
+		},
+		.len = 16
+	},
+	.auth_iv = {
+		.data = {
+			 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0xF1,  0x9E,  0x2B,  0x6F,
+		},
+		.len = 128 << 3
+	},
+	.ciphertext = {
+		.data = {
+			0x5A,  0x5A,  0xE4,  0xAD,  0x29,  0xA2,  0x6A,  0xA6,
+			0x20,  0x1D,  0xCD,  0x08,  0x50,  0xD6,  0xE6,  0x47,
+			0xBC,  0x88,  0x08,  0x01,  0x17,  0xFA,  0x47,  0x5B,
+			0x90,  0x40,  0xBA,  0x0C,  0xB5,  0x58,  0xF3,  0x0C,
+			0xA0,  0xD4,  0x98,  0x83,  0x1B,  0xCE,  0x54,  0xE3,
+			0x29,  0x00,  0x3C,  0xA4,  0xAD,  0x74,  0xEE,  0x05,
+			0xA3,  0x6C,  0xD4,  0xAC,  0xC6,  0x30,  0x33,  0xC9,
+			0x37,  0x57,  0x41,  0x9B,  0xD4,  0x73,  0xB9,  0x77,
+			0x70,  0x8B,  0x63,  0xDD,  0x22,  0xB8,  0xE1,  0x85,
+			0xB2,  0x92,  0x7C,  0x37,  0xD3,  0x2E,  0xD9,  0xF4,
+			0x4A,  0x69,  0x25,  0x30,  0xE3,  0x5B,  0x8B,  0xF6,
+			0x0F,  0xDE,  0x0B,  0x92,  0xD5,  0x25,  0x52,  0x6D,
+			0x26,  0xEB,  0x2F,  0x8A,  0x3B,  0x8B,  0x38,  0xE2,
+			0x48,  0xD3,  0x4A,  0x98,  0xF7,  0x3A,  0xC2,  0x46,
+			0x69,  0x8D,  0x73,  0x3E,  0x57,  0x88,  0x2C,  0x80,
+			0xF0,  0xF2,  0x75,  0xB8,  0x7D,  0x27,  0xC6,  0xDA,
+
+		},
+		.len = 128 << 3
+	},
+	.cipher = {
+		.len_bits = 126 << 3,
+		.offset_bits = 2 << 3
+	},
+	.auth = {
+		.len_bits = 124 << 3,
+		.offset_bits = 0
+	},
+	.digest = {
+		.data = {
+			0x7D, 0x27, 0xC6, 0xDA
+		},
+		.len = 4,
+		.offset_bytes = 124
+	},
+	.validDataLenInBits = {
+		.len = 128 << 3
+	},
+	.validCipherLenInBits = {
+		.len = 126 << 3
+	},
+	.validAuthLenInBits = {
+		.len = 124 << 3
+	},
+};
+
 #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */
-- 
2.19.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [dpdk-dev] [PATCH v2] test: add snow3g test cases when digest is encrypted
  2019-02-13  8:43 [dpdk-dev] [PATCH] test: add snow3g test cases when digest is encrypted Lukasz Krakowiak
  2019-02-13 10:20 ` Lukasz Krakowiak
@ 2019-02-27 10:18 ` Lukasz Krakowiak
  2019-03-01 17:36   ` Kusztal, ArkadiuszX
  2019-03-25 10:47   ` [dpdk-dev] [PATCH v3] " Lukasz Krakowiak
  1 sibling, 2 replies; 14+ messages in thread
From: Lukasz Krakowiak @ 2019-02-27 10:18 UTC (permalink / raw)
  To: pablo.de.lara.guarch; +Cc: dev, fiona.trahe, Lukasz Krakowiak

Add test case for encryption, dectryption for snow3g when digest
is encrypted

Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 test/test/test_cryptodev.c                    |  91 ++++++++++--
 .../test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
 2 files changed, 210 insertions(+), 13 deletions(-)

diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 32f1893bc..d8acfc7d1 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -2833,8 +2833,8 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-			ut_params->ibuf, auth_tag_len);
+	sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
+			ut_params->ibuf, uint8_t *, data_pad_len);
 
 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
 			"no room to append auth tag");
@@ -2844,10 +2844,6 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 
 	memset(sym_op->auth.digest.data, 0, auth_tag_len);
 
-	debug_hexdump(stdout, "digest:",
-			sym_op->auth.digest.data,
-			auth_tag_len);
-
 	/* Copy cipher and auth IVs at the end of the crypto operation */
 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
 						IV_OFFSET);
@@ -4052,7 +4048,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
 					tdata->cipher_iv.len,
 					tdata->validCipherLenInBits.len,
-					0);
+					tdata->cipher.offset_bits);
 	if (retval < 0)
 		return retval;
 
@@ -4360,11 +4356,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		tdata->digest.len,
 		tdata->cipher_iv.data, tdata->cipher_iv.len,
 		tdata->auth_iv.data, tdata->auth_iv.len,
-		plaintext_pad_len,
+		tdata->digest.offset_bytes == 0 ?
+		plaintext_pad_len : tdata->digest.offset_bytes,
 		tdata->validCipherLenInBits.len,
-		0,
+		tdata->cipher.offset_bits,
 		tdata->validAuthLenInBits.len,
-		0);
+		tdata->auth.offset_bits);
 
 	if (retval < 0)
 		return retval;
@@ -4379,7 +4376,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		ciphertext = plaintext;
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+			+ (tdata->digest.offset_bytes == 0 ?
+			plaintext_pad_len : tdata->digest.offset_bytes);
+
+	debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
 
 	/* Validate obuf */
@@ -4973,6 +4973,61 @@ test_snow3g_decryption_test_case_5(void)
 {
 	return test_snow3g_decryption(&snow3g_test_case_5);
 }
+
+/*
+ * Function prepares snow3g_hash_test_data from snow3g_test_data.
+ * Pattern digest from snow3g_test_data must be allocated as
+ * 4 last bytes in plaintext.
+ */
+static void
+snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
+		struct snow3g_hash_test_data *output)
+{
+	if ((pattern != NULL) && (output != NULL)) {
+		output->key.len = pattern->key.len;
+
+		memcpy(output->key.data,
+		pattern->key.data, pattern->key.len);
+
+		output->auth_iv.len = pattern->auth_iv.len;
+
+		memcpy(output->auth_iv.data,
+		pattern->auth_iv.data, pattern->auth_iv.len);
+
+		output->plaintext.len = pattern->plaintext.len;
+
+		memcpy(output->plaintext.data,
+		pattern->plaintext.data, pattern->plaintext.len >> 3);
+
+		output->digest.len = pattern->digest.len;
+
+		memcpy(output->digest.data,
+		&pattern->plaintext.data[pattern->digest.offset_bytes],
+		pattern->digest.len);
+
+		output->validAuthLenInBits.len =
+		pattern->validAuthLenInBits.len;
+	}
+}
+
+/*
+ * Test case verify computed cipher and digest from snow3g_test_case_7 data.
+ */
+static int
+test_snow3g_decryption_with_digest_test_case_1(void)
+{
+	struct snow3g_hash_test_data snow3g_hash_data;
+
+	/*
+	 * Function prepare data for hash veryfication test case.
+	 * Digest is allocated in 4 last bytes in plaintext, pattern.
+	 */
+	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
+
+	return test_snow3g_decryption(&snow3g_test_case_7) &
+			test_snow3g_authentication_verify(&snow3g_hash_data);
+}
+
 static int
 test_snow3g_cipher_auth_test_case_1(void)
 {
@@ -4985,6 +5040,12 @@ test_snow3g_auth_cipher_test_case_1(void)
 	return test_snow3g_auth_cipher(&snow3g_test_case_6);
 }
 
+static int
+test_snow3g_auth_cipher_with_digest_test_case_1(void)
+{
+	return test_snow3g_auth_cipher(&snow3g_test_case_7);
+}
+
 static int
 test_kasumi_auth_cipher_test_case_1(void)
 {
@@ -9138,6 +9199,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9154,6 +9217,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			test_snow3g_cipher_auth_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_auth_cipher_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_auth_cipher_with_digest_test_case_1),
 
 		/** ZUC encrypt only (EEA3) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9872,6 +9937,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_auth_cipher_with_digest_test_case_1),
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_1_oop),
@@ -9894,6 +9961,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/test/test/test_cryptodev_snow3g_test_vectors.h b/test/test/test_cryptodev_snow3g_test_vectors.h
index cb9dc4b35..3e55ac1f9 100644
--- a/test/test/test_cryptodev_snow3g_test_vectors.h
+++ b/test/test/test_cryptodev_snow3g_test_vectors.h
@@ -45,8 +45,19 @@ struct snow3g_test_data {
 
 	struct {
 		uint8_t data[64];
-		unsigned len;
+		unsigned int len; /* length must be in Bytes */
+		unsigned int offset_bytes; /* offset must be in Bytes */
 	} digest;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} cipher;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} auth;
 };
 struct snow3g_test_data snow3g_test_case_1 = {
 	.key = {
@@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 = {
 		},
 		.len = 800
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 798
 	},
@@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 = {
 		},
 		.len = 512
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 510
 	},
@@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 = {
 		},
 		.len = 120
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 120
 	},
@@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 = {
 		},
 		.len = 256
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 253
 	},
@@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 = {
 		},
 		.len = 840
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 837
 	},
@@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 = {
 		},
 		.len = 384
 	},
+	.cipher = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
+	.auth = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
 	.digest = {
 		.data = {0x38, 0xB5, 0x54, 0xC0 },
-		.len  = 4
+		.len  = 4,
+		.offset_bytes = 0
 	},
 	.validDataLenInBits = {
 		.len = 384
@@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 = {
 	},
 };
 
+
+struct snow3g_test_data snow3g_test_case_7 = {
+	.key = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
+
+			},
+		.len = 16
+	},
+	.cipher_iv = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
+		},
+		.len = 16
+	},
+	.auth_iv = {
+		.data = {
+			 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0xF1,  0x9E,  0x2B,  0x6F,
+		},
+		.len = 128 << 3
+	},
+	.ciphertext = {
+		.data = {
+			0x5A,  0x5A,  0xE4,  0xAD,  0x29,  0xA2,  0x6A,  0xA6,
+			0x20,  0x1D,  0xCD,  0x08,  0x50,  0xD6,  0xE6,  0x47,
+			0xBC,  0x88,  0x08,  0x01,  0x17,  0xFA,  0x47,  0x5B,
+			0x90,  0x40,  0xBA,  0x0C,  0xB5,  0x58,  0xF3,  0x0C,
+			0xA0,  0xD4,  0x98,  0x83,  0x1B,  0xCE,  0x54,  0xE3,
+			0x29,  0x00,  0x3C,  0xA4,  0xAD,  0x74,  0xEE,  0x05,
+			0xA3,  0x6C,  0xD4,  0xAC,  0xC6,  0x30,  0x33,  0xC9,
+			0x37,  0x57,  0x41,  0x9B,  0xD4,  0x73,  0xB9,  0x77,
+			0x70,  0x8B,  0x63,  0xDD,  0x22,  0xB8,  0xE1,  0x85,
+			0xB2,  0x92,  0x7C,  0x37,  0xD3,  0x2E,  0xD9,  0xF4,
+			0x4A,  0x69,  0x25,  0x30,  0xE3,  0x5B,  0x8B,  0xF6,
+			0x0F,  0xDE,  0x0B,  0x92,  0xD5,  0x25,  0x52,  0x6D,
+			0x26,  0xEB,  0x2F,  0x8A,  0x3B,  0x8B,  0x38,  0xE2,
+			0x48,  0xD3,  0x4A,  0x98,  0xF7,  0x3A,  0xC2,  0x46,
+			0x69,  0x8D,  0x73,  0x3E,  0x57,  0x88,  0x2C,  0x80,
+			0xF0,  0xF2,  0x75,  0xB8,  0x7D,  0x27,  0xC6,  0xDA,
+
+		},
+		.len = 128 << 3
+	},
+	.cipher = {
+		.len_bits = 126 << 3,
+		.offset_bits = 2 << 3
+	},
+	.auth = {
+		.len_bits = 124 << 3,
+		.offset_bits = 0
+	},
+	.digest = {
+		.data = {
+			0x7D, 0x27, 0xC6, 0xDA
+		},
+		.len = 4,
+		.offset_bytes = 124
+	},
+	.validDataLenInBits = {
+		.len = 128 << 3
+	},
+	.validCipherLenInBits = {
+		.len = 126 << 3
+	},
+	.validAuthLenInBits = {
+		.len = 124 << 3
+	},
+};
+
 #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */
-- 
2.19.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v2] test: add snow3g test cases when digest is encrypted
  2019-02-27 10:18 ` [dpdk-dev] [PATCH v2] " Lukasz Krakowiak
@ 2019-03-01 17:36   ` Kusztal, ArkadiuszX
  2019-03-22 14:51     ` Akhil Goyal
  2019-03-25 10:47   ` [dpdk-dev] [PATCH v3] " Lukasz Krakowiak
  1 sibling, 1 reply; 14+ messages in thread
From: Kusztal, ArkadiuszX @ 2019-03-01 17:36 UTC (permalink / raw)
  To: Krakowiak, LukaszX, De Lara Guarch, Pablo
  Cc: dev, Trahe, Fiona, Krakowiak, LukaszX



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Lukasz Krakowiak
> Sent: Wednesday, February 27, 2019 11:18 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak,
> LukaszX <lukaszx.krakowiak@intel.com>
> Subject: [dpdk-dev] [PATCH v2] test: add snow3g test cases when digest is
> encrypted
> 
> Add test case for encryption, dectryption for snow3g when digest is
> encrypted
> 
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
>  test/test/test_cryptodev.c                    |  91 ++++++++++--
>  .../test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
>  2 files changed, 210 insertions(+), 13 deletions(-)
> 
> diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index
> 32f1893bc..d8acfc7d1 100644
> --- a/test/test/test_cryptodev.c
> +++ b/test/test/test_cryptodev.c

Acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v2] test: add snow3g test cases when digest is encrypted
  2019-03-01 17:36   ` Kusztal, ArkadiuszX
@ 2019-03-22 14:51     ` Akhil Goyal
  2019-03-22 14:51       ` Akhil Goyal
  0 siblings, 1 reply; 14+ messages in thread
From: Akhil Goyal @ 2019-03-22 14:51 UTC (permalink / raw)
  To: Kusztal, ArkadiuszX, Krakowiak, LukaszX, De Lara Guarch, Pablo
  Cc: dev, Trahe, Fiona

Hi Lukasz,

On 3/1/2019 11:06 PM, Kusztal, ArkadiuszX wrote:
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Lukasz Krakowiak
>> Sent: Wednesday, February 27, 2019 11:18 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak,
>> LukaszX <lukaszx.krakowiak@intel.com>
>> Subject: [dpdk-dev] [PATCH v2] test: add snow3g test cases when digest is
>> encrypted
>>
>> Add test case for encryption, dectryption for snow3g when digest is
>> encrypted
>>
>> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
>> ---
>>   test/test/test_cryptodev.c                    |  91 ++++++++++--
>>   .../test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
>>   2 files changed, 210 insertions(+), 13 deletions(-)
>>
>> diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index
>> 32f1893bc..d8acfc7d1 100644
>> --- a/test/test/test_cryptodev.c
>> +++ b/test/test/test_cryptodev.c
> Acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
Could you please rebase this patch.
test directory has moved to app

Thanks,
Akhil

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v2] test: add snow3g test cases when digest is encrypted
  2019-03-22 14:51     ` Akhil Goyal
@ 2019-03-22 14:51       ` Akhil Goyal
  0 siblings, 0 replies; 14+ messages in thread
From: Akhil Goyal @ 2019-03-22 14:51 UTC (permalink / raw)
  To: Kusztal, ArkadiuszX, Krakowiak, LukaszX, De Lara Guarch, Pablo
  Cc: dev, Trahe, Fiona

Hi Lukasz,

On 3/1/2019 11:06 PM, Kusztal, ArkadiuszX wrote:
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Lukasz Krakowiak
>> Sent: Wednesday, February 27, 2019 11:18 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak,
>> LukaszX <lukaszx.krakowiak@intel.com>
>> Subject: [dpdk-dev] [PATCH v2] test: add snow3g test cases when digest is
>> encrypted
>>
>> Add test case for encryption, dectryption for snow3g when digest is
>> encrypted
>>
>> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
>> ---
>>   test/test/test_cryptodev.c                    |  91 ++++++++++--
>>   .../test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
>>   2 files changed, 210 insertions(+), 13 deletions(-)
>>
>> diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index
>> 32f1893bc..d8acfc7d1 100644
>> --- a/test/test/test_cryptodev.c
>> +++ b/test/test/test_cryptodev.c
> Acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
Could you please rebase this patch.
test directory has moved to app

Thanks,
Akhil

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-02-27 10:18 ` [dpdk-dev] [PATCH v2] " Lukasz Krakowiak
  2019-03-01 17:36   ` Kusztal, ArkadiuszX
@ 2019-03-25 10:47   ` Lukasz Krakowiak
  2019-03-25 10:47     ` Lukasz Krakowiak
                       ` (2 more replies)
  1 sibling, 3 replies; 14+ messages in thread
From: Lukasz Krakowiak @ 2019-03-25 10:47 UTC (permalink / raw)
  To: pablo.de.lara.guarch; +Cc: dev, fiona.trahe, Lukasz Krakowiak

Add test case for encryption, dectryption for snow3g when digest
is encrypted

---
v3:
* fixed path for test directory.

v2:
* coding style improved

Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 app/test/test_cryptodev.c                     |  91 ++++++++++--
 app/test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
 2 files changed, 210 insertions(+), 13 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 2ff204137..9f31aaa7e 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2834,8 +2834,8 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-			ut_params->ibuf, auth_tag_len);
+	sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
+			ut_params->ibuf, uint8_t *, data_pad_len);
 
 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
 			"no room to append auth tag");
@@ -2845,10 +2845,6 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 
 	memset(sym_op->auth.digest.data, 0, auth_tag_len);
 
-	debug_hexdump(stdout, "digest:",
-			sym_op->auth.digest.data,
-			auth_tag_len);
-
 	/* Copy cipher and auth IVs at the end of the crypto operation */
 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
 						IV_OFFSET);
@@ -4053,7 +4049,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
 					tdata->cipher_iv.len,
 					tdata->validCipherLenInBits.len,
-					0);
+					tdata->cipher.offset_bits);
 	if (retval < 0)
 		return retval;
 
@@ -4361,11 +4357,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		tdata->digest.len,
 		tdata->cipher_iv.data, tdata->cipher_iv.len,
 		tdata->auth_iv.data, tdata->auth_iv.len,
-		plaintext_pad_len,
+		tdata->digest.offset_bytes == 0 ?
+		plaintext_pad_len : tdata->digest.offset_bytes,
 		tdata->validCipherLenInBits.len,
-		0,
+		tdata->cipher.offset_bits,
 		tdata->validAuthLenInBits.len,
-		0);
+		tdata->auth.offset_bits);
 
 	if (retval < 0)
 		return retval;
@@ -4380,7 +4377,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		ciphertext = plaintext;
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+			+ (tdata->digest.offset_bytes == 0 ?
+			plaintext_pad_len : tdata->digest.offset_bytes);
+
+	debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
 
 	/* Validate obuf */
@@ -4974,6 +4974,61 @@ test_snow3g_decryption_test_case_5(void)
 {
 	return test_snow3g_decryption(&snow3g_test_case_5);
 }
+
+/*
+ * Function prepares snow3g_hash_test_data from snow3g_test_data.
+ * Pattern digest from snow3g_test_data must be allocated as
+ * 4 last bytes in plaintext.
+ */
+static void
+snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
+		struct snow3g_hash_test_data *output)
+{
+	if ((pattern != NULL) && (output != NULL)) {
+		output->key.len = pattern->key.len;
+
+		memcpy(output->key.data,
+		pattern->key.data, pattern->key.len);
+
+		output->auth_iv.len = pattern->auth_iv.len;
+
+		memcpy(output->auth_iv.data,
+		pattern->auth_iv.data, pattern->auth_iv.len);
+
+		output->plaintext.len = pattern->plaintext.len;
+
+		memcpy(output->plaintext.data,
+		pattern->plaintext.data, pattern->plaintext.len >> 3);
+
+		output->digest.len = pattern->digest.len;
+
+		memcpy(output->digest.data,
+		&pattern->plaintext.data[pattern->digest.offset_bytes],
+		pattern->digest.len);
+
+		output->validAuthLenInBits.len =
+		pattern->validAuthLenInBits.len;
+	}
+}
+
+/*
+ * Test case verify computed cipher and digest from snow3g_test_case_7 data.
+ */
+static int
+test_snow3g_decryption_with_digest_test_case_1(void)
+{
+	struct snow3g_hash_test_data snow3g_hash_data;
+
+	/*
+	 * Function prepare data for hash veryfication test case.
+	 * Digest is allocated in 4 last bytes in plaintext, pattern.
+	 */
+	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
+
+	return test_snow3g_decryption(&snow3g_test_case_7) &
+			test_snow3g_authentication_verify(&snow3g_hash_data);
+}
+
 static int
 test_snow3g_cipher_auth_test_case_1(void)
 {
@@ -4986,6 +5041,12 @@ test_snow3g_auth_cipher_test_case_1(void)
 	return test_snow3g_auth_cipher(&snow3g_test_case_6);
 }
 
+static int
+test_snow3g_auth_cipher_with_digest_test_case_1(void)
+{
+	return test_snow3g_auth_cipher(&snow3g_test_case_7);
+}
+
 static int
 test_kasumi_auth_cipher_test_case_1(void)
 {
@@ -9139,6 +9200,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9155,6 +9218,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			test_snow3g_cipher_auth_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_auth_cipher_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_auth_cipher_with_digest_test_case_1),
 
 		/** ZUC encrypt only (EEA3) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9873,6 +9938,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_auth_cipher_with_digest_test_case_1),
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_1_oop),
@@ -9895,6 +9962,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/app/test/test_cryptodev_snow3g_test_vectors.h b/app/test/test_cryptodev_snow3g_test_vectors.h
index cb9dc4b35..3e55ac1f9 100644
--- a/app/test/test_cryptodev_snow3g_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_test_vectors.h
@@ -45,8 +45,19 @@ struct snow3g_test_data {
 
 	struct {
 		uint8_t data[64];
-		unsigned len;
+		unsigned int len; /* length must be in Bytes */
+		unsigned int offset_bytes; /* offset must be in Bytes */
 	} digest;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} cipher;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} auth;
 };
 struct snow3g_test_data snow3g_test_case_1 = {
 	.key = {
@@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 = {
 		},
 		.len = 800
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 798
 	},
@@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 = {
 		},
 		.len = 512
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 510
 	},
@@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 = {
 		},
 		.len = 120
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 120
 	},
@@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 = {
 		},
 		.len = 256
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 253
 	},
@@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 = {
 		},
 		.len = 840
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 837
 	},
@@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 = {
 		},
 		.len = 384
 	},
+	.cipher = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
+	.auth = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
 	.digest = {
 		.data = {0x38, 0xB5, 0x54, 0xC0 },
-		.len  = 4
+		.len  = 4,
+		.offset_bytes = 0
 	},
 	.validDataLenInBits = {
 		.len = 384
@@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 = {
 	},
 };
 
+
+struct snow3g_test_data snow3g_test_case_7 = {
+	.key = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
+
+			},
+		.len = 16
+	},
+	.cipher_iv = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
+		},
+		.len = 16
+	},
+	.auth_iv = {
+		.data = {
+			 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0xF1,  0x9E,  0x2B,  0x6F,
+		},
+		.len = 128 << 3
+	},
+	.ciphertext = {
+		.data = {
+			0x5A,  0x5A,  0xE4,  0xAD,  0x29,  0xA2,  0x6A,  0xA6,
+			0x20,  0x1D,  0xCD,  0x08,  0x50,  0xD6,  0xE6,  0x47,
+			0xBC,  0x88,  0x08,  0x01,  0x17,  0xFA,  0x47,  0x5B,
+			0x90,  0x40,  0xBA,  0x0C,  0xB5,  0x58,  0xF3,  0x0C,
+			0xA0,  0xD4,  0x98,  0x83,  0x1B,  0xCE,  0x54,  0xE3,
+			0x29,  0x00,  0x3C,  0xA4,  0xAD,  0x74,  0xEE,  0x05,
+			0xA3,  0x6C,  0xD4,  0xAC,  0xC6,  0x30,  0x33,  0xC9,
+			0x37,  0x57,  0x41,  0x9B,  0xD4,  0x73,  0xB9,  0x77,
+			0x70,  0x8B,  0x63,  0xDD,  0x22,  0xB8,  0xE1,  0x85,
+			0xB2,  0x92,  0x7C,  0x37,  0xD3,  0x2E,  0xD9,  0xF4,
+			0x4A,  0x69,  0x25,  0x30,  0xE3,  0x5B,  0x8B,  0xF6,
+			0x0F,  0xDE,  0x0B,  0x92,  0xD5,  0x25,  0x52,  0x6D,
+			0x26,  0xEB,  0x2F,  0x8A,  0x3B,  0x8B,  0x38,  0xE2,
+			0x48,  0xD3,  0x4A,  0x98,  0xF7,  0x3A,  0xC2,  0x46,
+			0x69,  0x8D,  0x73,  0x3E,  0x57,  0x88,  0x2C,  0x80,
+			0xF0,  0xF2,  0x75,  0xB8,  0x7D,  0x27,  0xC6,  0xDA,
+
+		},
+		.len = 128 << 3
+	},
+	.cipher = {
+		.len_bits = 126 << 3,
+		.offset_bits = 2 << 3
+	},
+	.auth = {
+		.len_bits = 124 << 3,
+		.offset_bits = 0
+	},
+	.digest = {
+		.data = {
+			0x7D, 0x27, 0xC6, 0xDA
+		},
+		.len = 4,
+		.offset_bytes = 124
+	},
+	.validDataLenInBits = {
+		.len = 128 << 3
+	},
+	.validCipherLenInBits = {
+		.len = 126 << 3
+	},
+	.validAuthLenInBits = {
+		.len = 124 << 3
+	},
+};
+
 #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */
-- 
2.19.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-03-25 10:47   ` [dpdk-dev] [PATCH v3] " Lukasz Krakowiak
@ 2019-03-25 10:47     ` Lukasz Krakowiak
  2019-03-28 13:09     ` Trahe, Fiona
  2019-03-28 13:10     ` Trahe, Fiona
  2 siblings, 0 replies; 14+ messages in thread
From: Lukasz Krakowiak @ 2019-03-25 10:47 UTC (permalink / raw)
  To: pablo.de.lara.guarch; +Cc: dev, fiona.trahe, Lukasz Krakowiak

Add test case for encryption, dectryption for snow3g when digest
is encrypted

---
v3:
* fixed path for test directory.

v2:
* coding style improved

Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 app/test/test_cryptodev.c                     |  91 ++++++++++--
 app/test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
 2 files changed, 210 insertions(+), 13 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 2ff204137..9f31aaa7e 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2834,8 +2834,8 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-			ut_params->ibuf, auth_tag_len);
+	sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
+			ut_params->ibuf, uint8_t *, data_pad_len);
 
 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
 			"no room to append auth tag");
@@ -2845,10 +2845,6 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
 
 	memset(sym_op->auth.digest.data, 0, auth_tag_len);
 
-	debug_hexdump(stdout, "digest:",
-			sym_op->auth.digest.data,
-			auth_tag_len);
-
 	/* Copy cipher and auth IVs at the end of the crypto operation */
 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
 						IV_OFFSET);
@@ -4053,7 +4049,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
 					tdata->cipher_iv.len,
 					tdata->validCipherLenInBits.len,
-					0);
+					tdata->cipher.offset_bits);
 	if (retval < 0)
 		return retval;
 
@@ -4361,11 +4357,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		tdata->digest.len,
 		tdata->cipher_iv.data, tdata->cipher_iv.len,
 		tdata->auth_iv.data, tdata->auth_iv.len,
-		plaintext_pad_len,
+		tdata->digest.offset_bytes == 0 ?
+		plaintext_pad_len : tdata->digest.offset_bytes,
 		tdata->validCipherLenInBits.len,
-		0,
+		tdata->cipher.offset_bits,
 		tdata->validAuthLenInBits.len,
-		0);
+		tdata->auth.offset_bits);
 
 	if (retval < 0)
 		return retval;
@@ -4380,7 +4377,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
 		ciphertext = plaintext;
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+			+ (tdata->digest.offset_bytes == 0 ?
+			plaintext_pad_len : tdata->digest.offset_bytes);
+
+	debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
 
 	/* Validate obuf */
@@ -4974,6 +4974,61 @@ test_snow3g_decryption_test_case_5(void)
 {
 	return test_snow3g_decryption(&snow3g_test_case_5);
 }
+
+/*
+ * Function prepares snow3g_hash_test_data from snow3g_test_data.
+ * Pattern digest from snow3g_test_data must be allocated as
+ * 4 last bytes in plaintext.
+ */
+static void
+snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
+		struct snow3g_hash_test_data *output)
+{
+	if ((pattern != NULL) && (output != NULL)) {
+		output->key.len = pattern->key.len;
+
+		memcpy(output->key.data,
+		pattern->key.data, pattern->key.len);
+
+		output->auth_iv.len = pattern->auth_iv.len;
+
+		memcpy(output->auth_iv.data,
+		pattern->auth_iv.data, pattern->auth_iv.len);
+
+		output->plaintext.len = pattern->plaintext.len;
+
+		memcpy(output->plaintext.data,
+		pattern->plaintext.data, pattern->plaintext.len >> 3);
+
+		output->digest.len = pattern->digest.len;
+
+		memcpy(output->digest.data,
+		&pattern->plaintext.data[pattern->digest.offset_bytes],
+		pattern->digest.len);
+
+		output->validAuthLenInBits.len =
+		pattern->validAuthLenInBits.len;
+	}
+}
+
+/*
+ * Test case verify computed cipher and digest from snow3g_test_case_7 data.
+ */
+static int
+test_snow3g_decryption_with_digest_test_case_1(void)
+{
+	struct snow3g_hash_test_data snow3g_hash_data;
+
+	/*
+	 * Function prepare data for hash veryfication test case.
+	 * Digest is allocated in 4 last bytes in plaintext, pattern.
+	 */
+	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
+
+	return test_snow3g_decryption(&snow3g_test_case_7) &
+			test_snow3g_authentication_verify(&snow3g_hash_data);
+}
+
 static int
 test_snow3g_cipher_auth_test_case_1(void)
 {
@@ -4986,6 +5041,12 @@ test_snow3g_auth_cipher_test_case_1(void)
 	return test_snow3g_auth_cipher(&snow3g_test_case_6);
 }
 
+static int
+test_snow3g_auth_cipher_with_digest_test_case_1(void)
+{
+	return test_snow3g_auth_cipher(&snow3g_test_case_7);
+}
+
 static int
 test_kasumi_auth_cipher_test_case_1(void)
 {
@@ -9139,6 +9200,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9155,6 +9218,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
 			test_snow3g_cipher_auth_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_auth_cipher_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_auth_cipher_with_digest_test_case_1),
 
 		/** ZUC encrypt only (EEA3) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
@@ -9873,6 +9938,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_auth_cipher_with_digest_test_case_1),
 
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_1_oop),
@@ -9895,6 +9962,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			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_decryption_with_digest_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/app/test/test_cryptodev_snow3g_test_vectors.h b/app/test/test_cryptodev_snow3g_test_vectors.h
index cb9dc4b35..3e55ac1f9 100644
--- a/app/test/test_cryptodev_snow3g_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_test_vectors.h
@@ -45,8 +45,19 @@ struct snow3g_test_data {
 
 	struct {
 		uint8_t data[64];
-		unsigned len;
+		unsigned int len; /* length must be in Bytes */
+		unsigned int offset_bytes; /* offset must be in Bytes */
 	} digest;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} cipher;
+
+	struct {
+		unsigned int len_bits; /* length must be in Bits */
+		unsigned int offset_bits;
+	} auth;
 };
 struct snow3g_test_data snow3g_test_case_1 = {
 	.key = {
@@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 = {
 		},
 		.len = 800
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 798
 	},
@@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 = {
 		},
 		.len = 512
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 510
 	},
@@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 = {
 		},
 		.len = 120
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 120
 	},
@@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 = {
 		},
 		.len = 256
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 253
 	},
@@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 = {
 		},
 		.len = 840
 	},
+	.cipher = {
+		.offset_bits = 0
+	},
 	.validDataLenInBits = {
 		.len = 837
 	},
@@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 = {
 		},
 		.len = 384
 	},
+	.cipher = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
+	.auth = {
+		.len_bits = 384,
+		.offset_bits = 0
+	},
 	.digest = {
 		.data = {0x38, 0xB5, 0x54, 0xC0 },
-		.len  = 4
+		.len  = 4,
+		.offset_bytes = 0
 	},
 	.validDataLenInBits = {
 		.len = 384
@@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 = {
 	},
 };
 
+
+struct snow3g_test_data snow3g_test_case_7 = {
+	.key = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
+
+			},
+		.len = 16
+	},
+	.cipher_iv = {
+		.data = {
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
+		},
+		.len = 16
+	},
+	.auth_iv = {
+		.data = {
+			 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+			 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
+			0x5A,  0x5A,  0x5A,  0x5A,  0xF1,  0x9E,  0x2B,  0x6F,
+		},
+		.len = 128 << 3
+	},
+	.ciphertext = {
+		.data = {
+			0x5A,  0x5A,  0xE4,  0xAD,  0x29,  0xA2,  0x6A,  0xA6,
+			0x20,  0x1D,  0xCD,  0x08,  0x50,  0xD6,  0xE6,  0x47,
+			0xBC,  0x88,  0x08,  0x01,  0x17,  0xFA,  0x47,  0x5B,
+			0x90,  0x40,  0xBA,  0x0C,  0xB5,  0x58,  0xF3,  0x0C,
+			0xA0,  0xD4,  0x98,  0x83,  0x1B,  0xCE,  0x54,  0xE3,
+			0x29,  0x00,  0x3C,  0xA4,  0xAD,  0x74,  0xEE,  0x05,
+			0xA3,  0x6C,  0xD4,  0xAC,  0xC6,  0x30,  0x33,  0xC9,
+			0x37,  0x57,  0x41,  0x9B,  0xD4,  0x73,  0xB9,  0x77,
+			0x70,  0x8B,  0x63,  0xDD,  0x22,  0xB8,  0xE1,  0x85,
+			0xB2,  0x92,  0x7C,  0x37,  0xD3,  0x2E,  0xD9,  0xF4,
+			0x4A,  0x69,  0x25,  0x30,  0xE3,  0x5B,  0x8B,  0xF6,
+			0x0F,  0xDE,  0x0B,  0x92,  0xD5,  0x25,  0x52,  0x6D,
+			0x26,  0xEB,  0x2F,  0x8A,  0x3B,  0x8B,  0x38,  0xE2,
+			0x48,  0xD3,  0x4A,  0x98,  0xF7,  0x3A,  0xC2,  0x46,
+			0x69,  0x8D,  0x73,  0x3E,  0x57,  0x88,  0x2C,  0x80,
+			0xF0,  0xF2,  0x75,  0xB8,  0x7D,  0x27,  0xC6,  0xDA,
+
+		},
+		.len = 128 << 3
+	},
+	.cipher = {
+		.len_bits = 126 << 3,
+		.offset_bits = 2 << 3
+	},
+	.auth = {
+		.len_bits = 124 << 3,
+		.offset_bits = 0
+	},
+	.digest = {
+		.data = {
+			0x7D, 0x27, 0xC6, 0xDA
+		},
+		.len = 4,
+		.offset_bytes = 124
+	},
+	.validDataLenInBits = {
+		.len = 128 << 3
+	},
+	.validCipherLenInBits = {
+		.len = 126 << 3
+	},
+	.validAuthLenInBits = {
+		.len = 124 << 3
+	},
+};
+
 #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */
-- 
2.19.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-03-25 10:47   ` [dpdk-dev] [PATCH v3] " Lukasz Krakowiak
  2019-03-25 10:47     ` Lukasz Krakowiak
@ 2019-03-28 13:09     ` Trahe, Fiona
  2019-03-28 13:09       ` Trahe, Fiona
  2019-03-28 13:10     ` Trahe, Fiona
  2 siblings, 1 reply; 14+ messages in thread
From: Trahe, Fiona @ 2019-03-28 13:09 UTC (permalink / raw)
  To: Krakowiak, LukaszX, De Lara Guarch, Pablo; +Cc: dev, Trahe, Fiona



> -----Original Message-----
> From: Krakowiak, LukaszX
> Sent: Monday, March 25, 2019 10:48 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak, LukaszX
> <lukaszx.krakowiak@intel.com>
> Subject: [PATCH v3] test: add snow3g test cases when digest is encrypted
> 
> Add test case for encryption, dectryption for snow3g when digest
> is encrypted
> 
> ---
> v3:
> * fixed path for test directory.
> 
> v2:
> * coding style improved
> 
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
>  app/test/test_cryptodev.c                     |  91 ++++++++++--
>  app/test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
>  2 files changed, 210 insertions(+), 13 deletions(-)
> 
> diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
> index 2ff204137..9f31aaa7e 100644
> --- a/app/test/test_cryptodev.c
> +++ b/app/test/test_cryptodev.c
> @@ -2834,8 +2834,8 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
>  	sym_op->m_src = ut_params->ibuf;
> 
>  	/* digest */
> -	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
> -			ut_params->ibuf, auth_tag_len);
> +	sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
> +			ut_params->ibuf, uint8_t *, data_pad_len);
> 
>  	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
>  			"no room to append auth tag");
> @@ -2845,10 +2845,6 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
> 
>  	memset(sym_op->auth.digest.data, 0, auth_tag_len);
> 
> -	debug_hexdump(stdout, "digest:",
> -			sym_op->auth.digest.data,
> -			auth_tag_len);
> -
>  	/* Copy cipher and auth IVs at the end of the crypto operation */
>  	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
>  						IV_OFFSET);
> @@ -4053,7 +4049,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
>  	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
>  					tdata->cipher_iv.len,
>  					tdata->validCipherLenInBits.len,
> -					0);
> +					tdata->cipher.offset_bits);
>  	if (retval < 0)
>  		return retval;
> 
> @@ -4361,11 +4357,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
>  		tdata->digest.len,
>  		tdata->cipher_iv.data, tdata->cipher_iv.len,
>  		tdata->auth_iv.data, tdata->auth_iv.len,
> -		plaintext_pad_len,
> +		tdata->digest.offset_bytes == 0 ?
> +		plaintext_pad_len : tdata->digest.offset_bytes,
>  		tdata->validCipherLenInBits.len,
> -		0,
> +		tdata->cipher.offset_bits,
>  		tdata->validAuthLenInBits.len,
> -		0);
> +		tdata->auth.offset_bits);
> 
>  	if (retval < 0)
>  		return retval;
> @@ -4380,7 +4377,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
>  		ciphertext = plaintext;
> 
>  	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
> -			+ plaintext_pad_len;
> +			+ (tdata->digest.offset_bytes == 0 ?
> +			plaintext_pad_len : tdata->digest.offset_bytes);
> +
> +	debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
>  	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
> 
>  	/* Validate obuf */
> @@ -4974,6 +4974,61 @@ test_snow3g_decryption_test_case_5(void)
>  {
>  	return test_snow3g_decryption(&snow3g_test_case_5);
>  }
> +
> +/*
> + * Function prepares snow3g_hash_test_data from snow3g_test_data.
> + * Pattern digest from snow3g_test_data must be allocated as
> + * 4 last bytes in plaintext.
> + */
> +static void
> +snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
> +		struct snow3g_hash_test_data *output)
> +{
> +	if ((pattern != NULL) && (output != NULL)) {
> +		output->key.len = pattern->key.len;
> +
> +		memcpy(output->key.data,
> +		pattern->key.data, pattern->key.len);
> +
> +		output->auth_iv.len = pattern->auth_iv.len;
> +
> +		memcpy(output->auth_iv.data,
> +		pattern->auth_iv.data, pattern->auth_iv.len);
> +
> +		output->plaintext.len = pattern->plaintext.len;
> +
> +		memcpy(output->plaintext.data,
> +		pattern->plaintext.data, pattern->plaintext.len >> 3);
> +
> +		output->digest.len = pattern->digest.len;
> +
> +		memcpy(output->digest.data,
> +		&pattern->plaintext.data[pattern->digest.offset_bytes],
> +		pattern->digest.len);
> +
> +		output->validAuthLenInBits.len =
> +		pattern->validAuthLenInBits.len;
> +	}
> +}
> +
> +/*
> + * Test case verify computed cipher and digest from snow3g_test_case_7 data.
> + */
> +static int
> +test_snow3g_decryption_with_digest_test_case_1(void)
> +{
> +	struct snow3g_hash_test_data snow3g_hash_data;
> +
> +	/*
> +	 * Function prepare data for hash veryfication test case.
> +	 * Digest is allocated in 4 last bytes in plaintext, pattern.
> +	 */
> +	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
> +
> +	return test_snow3g_decryption(&snow3g_test_case_7) &
> +			test_snow3g_authentication_verify(&snow3g_hash_data);
> +}
> +
>  static int
>  test_snow3g_cipher_auth_test_case_1(void)
>  {
> @@ -4986,6 +5041,12 @@ test_snow3g_auth_cipher_test_case_1(void)
>  	return test_snow3g_auth_cipher(&snow3g_test_case_6);
>  }
> 
> +static int
> +test_snow3g_auth_cipher_with_digest_test_case_1(void)
> +{
> +	return test_snow3g_auth_cipher(&snow3g_test_case_7);
> +}
> +
>  static int
>  test_kasumi_auth_cipher_test_case_1(void)
>  {
> @@ -9139,6 +9200,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
>  			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_decryption_with_digest_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_hash_generate_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
> @@ -9155,6 +9218,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
>  			test_snow3g_cipher_auth_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_auth_cipher_test_case_1),
> +		TEST_CASE_ST(ut_setup, ut_teardown,
> +			test_snow3g_auth_cipher_with_digest_test_case_1),
> 
>  		/** ZUC encrypt only (EEA3) */
>  		TEST_CASE_ST(ut_setup, ut_teardown,
> @@ -9873,6 +9938,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
>  			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_auth_cipher_with_digest_test_case_1),
> 
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_encryption_test_case_1_oop),
> @@ -9895,6 +9962,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
>  			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_decryption_with_digest_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_hash_generate_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
> diff --git a/app/test/test_cryptodev_snow3g_test_vectors.h
> b/app/test/test_cryptodev_snow3g_test_vectors.h
> index cb9dc4b35..3e55ac1f9 100644
> --- a/app/test/test_cryptodev_snow3g_test_vectors.h
> +++ b/app/test/test_cryptodev_snow3g_test_vectors.h
> @@ -45,8 +45,19 @@ struct snow3g_test_data {
> 
>  	struct {
>  		uint8_t data[64];
> -		unsigned len;
> +		unsigned int len; /* length must be in Bytes */
> +		unsigned int offset_bytes; /* offset must be in Bytes */
>  	} digest;
> +
> +	struct {
> +		unsigned int len_bits; /* length must be in Bits */
> +		unsigned int offset_bits;
> +	} cipher;
> +
> +	struct {
> +		unsigned int len_bits; /* length must be in Bits */
> +		unsigned int offset_bits;
> +	} auth;
>  };
>  struct snow3g_test_data snow3g_test_case_1 = {
>  	.key = {
> @@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 = {
>  		},
>  		.len = 800
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 798
>  	},
> @@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 = {
>  		},
>  		.len = 512
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 510
>  	},
> @@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 = {
>  		},
>  		.len = 120
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 120
>  	},
> @@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 = {
>  		},
>  		.len = 256
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 253
>  	},
> @@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 = {
>  		},
>  		.len = 840
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 837
>  	},
> @@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 = {
>  		},
>  		.len = 384
>  	},
> +	.cipher = {
> +		.len_bits = 384,
> +		.offset_bits = 0
> +	},
> +	.auth = {
> +		.len_bits = 384,
> +		.offset_bits = 0
> +	},
>  	.digest = {
>  		.data = {0x38, 0xB5, 0x54, 0xC0 },
> -		.len  = 4
> +		.len  = 4,
> +		.offset_bytes = 0
>  	},
>  	.validDataLenInBits = {
>  		.len = 384
> @@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 = {
>  	},
>  };
> 
> +
> +struct snow3g_test_data snow3g_test_case_7 = {
> +	.key = {
> +		.data = {
> +			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> +			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
> +
> +			},
> +		.len = 16
> +	},
> +	.cipher_iv = {
> +		.data = {
> +			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> +			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
> +		},
> +		.len = 16
> +	},
> +	.auth_iv = {
> +		.data = {
> +			 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> +			 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> +		},
> +		.len = 16
> +	},
> +	.plaintext = {
> +		.data = {
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0xF1,  0x9E,  0x2B,  0x6F,
> +		},
> +		.len = 128 << 3
> +	},
> +	.ciphertext = {
> +		.data = {
> +			0x5A,  0x5A,  0xE4,  0xAD,  0x29,  0xA2,  0x6A,  0xA6,
> +			0x20,  0x1D,  0xCD,  0x08,  0x50,  0xD6,  0xE6,  0x47,
> +			0xBC,  0x88,  0x08,  0x01,  0x17,  0xFA,  0x47,  0x5B,
> +			0x90,  0x40,  0xBA,  0x0C,  0xB5,  0x58,  0xF3,  0x0C,
> +			0xA0,  0xD4,  0x98,  0x83,  0x1B,  0xCE,  0x54,  0xE3,
> +			0x29,  0x00,  0x3C,  0xA4,  0xAD,  0x74,  0xEE,  0x05,
> +			0xA3,  0x6C,  0xD4,  0xAC,  0xC6,  0x30,  0x33,  0xC9,
> +			0x37,  0x57,  0x41,  0x9B,  0xD4,  0x73,  0xB9,  0x77,
> +			0x70,  0x8B,  0x63,  0xDD,  0x22,  0xB8,  0xE1,  0x85,
> +			0xB2,  0x92,  0x7C,  0x37,  0xD3,  0x2E,  0xD9,  0xF4,
> +			0x4A,  0x69,  0x25,  0x30,  0xE3,  0x5B,  0x8B,  0xF6,
> +			0x0F,  0xDE,  0x0B,  0x92,  0xD5,  0x25,  0x52,  0x6D,
> +			0x26,  0xEB,  0x2F,  0x8A,  0x3B,  0x8B,  0x38,  0xE2,
> +			0x48,  0xD3,  0x4A,  0x98,  0xF7,  0x3A,  0xC2,  0x46,
> +			0x69,  0x8D,  0x73,  0x3E,  0x57,  0x88,  0x2C,  0x80,
> +			0xF0,  0xF2,  0x75,  0xB8,  0x7D,  0x27,  0xC6,  0xDA,
> +
> +		},
> +		.len = 128 << 3
> +	},
> +	.cipher = {
> +		.len_bits = 126 << 3,
> +		.offset_bits = 2 << 3
> +	},
> +	.auth = {
> +		.len_bits = 124 << 3,
> +		.offset_bits = 0
> +	},
> +	.digest = {
> +		.data = {
> +			0x7D, 0x27, 0xC6, 0xDA
> +		},
> +		.len = 4,
> +		.offset_bytes = 124
> +	},
> +	.validDataLenInBits = {
> +		.len = 128 << 3
> +	},
> +	.validCipherLenInBits = {
> +		.len = 126 << 3
> +	},
> +	.validAuthLenInBits = {
> +		.len = 124 << 3
> +	},
> +};
> +
>  #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */
> --
> 2.19.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-03-28 13:09     ` Trahe, Fiona
@ 2019-03-28 13:09       ` Trahe, Fiona
  0 siblings, 0 replies; 14+ messages in thread
From: Trahe, Fiona @ 2019-03-28 13:09 UTC (permalink / raw)
  To: Krakowiak, LukaszX, De Lara Guarch, Pablo; +Cc: dev, Trahe, Fiona



> -----Original Message-----
> From: Krakowiak, LukaszX
> Sent: Monday, March 25, 2019 10:48 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak, LukaszX
> <lukaszx.krakowiak@intel.com>
> Subject: [PATCH v3] test: add snow3g test cases when digest is encrypted
> 
> Add test case for encryption, dectryption for snow3g when digest
> is encrypted
> 
> ---
> v3:
> * fixed path for test directory.
> 
> v2:
> * coding style improved
> 
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
>  app/test/test_cryptodev.c                     |  91 ++++++++++--
>  app/test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++-
>  2 files changed, 210 insertions(+), 13 deletions(-)
> 
> diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
> index 2ff204137..9f31aaa7e 100644
> --- a/app/test/test_cryptodev.c
> +++ b/app/test/test_cryptodev.c
> @@ -2834,8 +2834,8 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
>  	sym_op->m_src = ut_params->ibuf;
> 
>  	/* digest */
> -	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
> -			ut_params->ibuf, auth_tag_len);
> +	sym_op->auth.digest.data = (uint8_t *) rte_pktmbuf_mtod_offset(
> +			ut_params->ibuf, uint8_t *, data_pad_len);
> 
>  	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
>  			"no room to append auth tag");
> @@ -2845,10 +2845,6 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
> 
>  	memset(sym_op->auth.digest.data, 0, auth_tag_len);
> 
> -	debug_hexdump(stdout, "digest:",
> -			sym_op->auth.digest.data,
> -			auth_tag_len);
> -
>  	/* Copy cipher and auth IVs at the end of the crypto operation */
>  	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
>  						IV_OFFSET);
> @@ -4053,7 +4049,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
>  	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
>  					tdata->cipher_iv.len,
>  					tdata->validCipherLenInBits.len,
> -					0);
> +					tdata->cipher.offset_bits);
>  	if (retval < 0)
>  		return retval;
> 
> @@ -4361,11 +4357,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
>  		tdata->digest.len,
>  		tdata->cipher_iv.data, tdata->cipher_iv.len,
>  		tdata->auth_iv.data, tdata->auth_iv.len,
> -		plaintext_pad_len,
> +		tdata->digest.offset_bytes == 0 ?
> +		plaintext_pad_len : tdata->digest.offset_bytes,
>  		tdata->validCipherLenInBits.len,
> -		0,
> +		tdata->cipher.offset_bits,
>  		tdata->validAuthLenInBits.len,
> -		0);
> +		tdata->auth.offset_bits);
> 
>  	if (retval < 0)
>  		return retval;
> @@ -4380,7 +4377,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
>  		ciphertext = plaintext;
> 
>  	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
> -			+ plaintext_pad_len;
> +			+ (tdata->digest.offset_bytes == 0 ?
> +			plaintext_pad_len : tdata->digest.offset_bytes);
> +
> +	debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len);
>  	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
> 
>  	/* Validate obuf */
> @@ -4974,6 +4974,61 @@ test_snow3g_decryption_test_case_5(void)
>  {
>  	return test_snow3g_decryption(&snow3g_test_case_5);
>  }
> +
> +/*
> + * Function prepares snow3g_hash_test_data from snow3g_test_data.
> + * Pattern digest from snow3g_test_data must be allocated as
> + * 4 last bytes in plaintext.
> + */
> +static void
> +snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
> +		struct snow3g_hash_test_data *output)
> +{
> +	if ((pattern != NULL) && (output != NULL)) {
> +		output->key.len = pattern->key.len;
> +
> +		memcpy(output->key.data,
> +		pattern->key.data, pattern->key.len);
> +
> +		output->auth_iv.len = pattern->auth_iv.len;
> +
> +		memcpy(output->auth_iv.data,
> +		pattern->auth_iv.data, pattern->auth_iv.len);
> +
> +		output->plaintext.len = pattern->plaintext.len;
> +
> +		memcpy(output->plaintext.data,
> +		pattern->plaintext.data, pattern->plaintext.len >> 3);
> +
> +		output->digest.len = pattern->digest.len;
> +
> +		memcpy(output->digest.data,
> +		&pattern->plaintext.data[pattern->digest.offset_bytes],
> +		pattern->digest.len);
> +
> +		output->validAuthLenInBits.len =
> +		pattern->validAuthLenInBits.len;
> +	}
> +}
> +
> +/*
> + * Test case verify computed cipher and digest from snow3g_test_case_7 data.
> + */
> +static int
> +test_snow3g_decryption_with_digest_test_case_1(void)
> +{
> +	struct snow3g_hash_test_data snow3g_hash_data;
> +
> +	/*
> +	 * Function prepare data for hash veryfication test case.
> +	 * Digest is allocated in 4 last bytes in plaintext, pattern.
> +	 */
> +	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
> +
> +	return test_snow3g_decryption(&snow3g_test_case_7) &
> +			test_snow3g_authentication_verify(&snow3g_hash_data);
> +}
> +
>  static int
>  test_snow3g_cipher_auth_test_case_1(void)
>  {
> @@ -4986,6 +5041,12 @@ test_snow3g_auth_cipher_test_case_1(void)
>  	return test_snow3g_auth_cipher(&snow3g_test_case_6);
>  }
> 
> +static int
> +test_snow3g_auth_cipher_with_digest_test_case_1(void)
> +{
> +	return test_snow3g_auth_cipher(&snow3g_test_case_7);
> +}
> +
>  static int
>  test_kasumi_auth_cipher_test_case_1(void)
>  {
> @@ -9139,6 +9200,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
>  			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_decryption_with_digest_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_hash_generate_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
> @@ -9155,6 +9218,8 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
>  			test_snow3g_cipher_auth_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_auth_cipher_test_case_1),
> +		TEST_CASE_ST(ut_setup, ut_teardown,
> +			test_snow3g_auth_cipher_with_digest_test_case_1),
> 
>  		/** ZUC encrypt only (EEA3) */
>  		TEST_CASE_ST(ut_setup, ut_teardown,
> @@ -9873,6 +9938,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
>  			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_auth_cipher_with_digest_test_case_1),
> 
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_encryption_test_case_1_oop),
> @@ -9895,6 +9962,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
>  			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_decryption_with_digest_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
>  			test_snow3g_hash_generate_test_case_1),
>  		TEST_CASE_ST(ut_setup, ut_teardown,
> diff --git a/app/test/test_cryptodev_snow3g_test_vectors.h
> b/app/test/test_cryptodev_snow3g_test_vectors.h
> index cb9dc4b35..3e55ac1f9 100644
> --- a/app/test/test_cryptodev_snow3g_test_vectors.h
> +++ b/app/test/test_cryptodev_snow3g_test_vectors.h
> @@ -45,8 +45,19 @@ struct snow3g_test_data {
> 
>  	struct {
>  		uint8_t data[64];
> -		unsigned len;
> +		unsigned int len; /* length must be in Bytes */
> +		unsigned int offset_bytes; /* offset must be in Bytes */
>  	} digest;
> +
> +	struct {
> +		unsigned int len_bits; /* length must be in Bits */
> +		unsigned int offset_bits;
> +	} cipher;
> +
> +	struct {
> +		unsigned int len_bits; /* length must be in Bits */
> +		unsigned int offset_bits;
> +	} auth;
>  };
>  struct snow3g_test_data snow3g_test_case_1 = {
>  	.key = {
> @@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 = {
>  		},
>  		.len = 800
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 798
>  	},
> @@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 = {
>  		},
>  		.len = 512
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 510
>  	},
> @@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 = {
>  		},
>  		.len = 120
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 120
>  	},
> @@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 = {
>  		},
>  		.len = 256
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 253
>  	},
> @@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 = {
>  		},
>  		.len = 840
>  	},
> +	.cipher = {
> +		.offset_bits = 0
> +	},
>  	.validDataLenInBits = {
>  		.len = 837
>  	},
> @@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 = {
>  		},
>  		.len = 384
>  	},
> +	.cipher = {
> +		.len_bits = 384,
> +		.offset_bits = 0
> +	},
> +	.auth = {
> +		.len_bits = 384,
> +		.offset_bits = 0
> +	},
>  	.digest = {
>  		.data = {0x38, 0xB5, 0x54, 0xC0 },
> -		.len  = 4
> +		.len  = 4,
> +		.offset_bytes = 0
>  	},
>  	.validDataLenInBits = {
>  		.len = 384
> @@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 = {
>  	},
>  };
> 
> +
> +struct snow3g_test_data snow3g_test_case_7 = {
> +	.key = {
> +		.data = {
> +			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> +			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
> +
> +			},
> +		.len = 16
> +	},
> +	.cipher_iv = {
> +		.data = {
> +			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> +			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
> +		},
> +		.len = 16
> +	},
> +	.auth_iv = {
> +		.data = {
> +			 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> +			 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> +		},
> +		.len = 16
> +	},
> +	.plaintext = {
> +		.data = {
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,  0x5A,
> +			0x5A,  0x5A,  0x5A,  0x5A,  0xF1,  0x9E,  0x2B,  0x6F,
> +		},
> +		.len = 128 << 3
> +	},
> +	.ciphertext = {
> +		.data = {
> +			0x5A,  0x5A,  0xE4,  0xAD,  0x29,  0xA2,  0x6A,  0xA6,
> +			0x20,  0x1D,  0xCD,  0x08,  0x50,  0xD6,  0xE6,  0x47,
> +			0xBC,  0x88,  0x08,  0x01,  0x17,  0xFA,  0x47,  0x5B,
> +			0x90,  0x40,  0xBA,  0x0C,  0xB5,  0x58,  0xF3,  0x0C,
> +			0xA0,  0xD4,  0x98,  0x83,  0x1B,  0xCE,  0x54,  0xE3,
> +			0x29,  0x00,  0x3C,  0xA4,  0xAD,  0x74,  0xEE,  0x05,
> +			0xA3,  0x6C,  0xD4,  0xAC,  0xC6,  0x30,  0x33,  0xC9,
> +			0x37,  0x57,  0x41,  0x9B,  0xD4,  0x73,  0xB9,  0x77,
> +			0x70,  0x8B,  0x63,  0xDD,  0x22,  0xB8,  0xE1,  0x85,
> +			0xB2,  0x92,  0x7C,  0x37,  0xD3,  0x2E,  0xD9,  0xF4,
> +			0x4A,  0x69,  0x25,  0x30,  0xE3,  0x5B,  0x8B,  0xF6,
> +			0x0F,  0xDE,  0x0B,  0x92,  0xD5,  0x25,  0x52,  0x6D,
> +			0x26,  0xEB,  0x2F,  0x8A,  0x3B,  0x8B,  0x38,  0xE2,
> +			0x48,  0xD3,  0x4A,  0x98,  0xF7,  0x3A,  0xC2,  0x46,
> +			0x69,  0x8D,  0x73,  0x3E,  0x57,  0x88,  0x2C,  0x80,
> +			0xF0,  0xF2,  0x75,  0xB8,  0x7D,  0x27,  0xC6,  0xDA,
> +
> +		},
> +		.len = 128 << 3
> +	},
> +	.cipher = {
> +		.len_bits = 126 << 3,
> +		.offset_bits = 2 << 3
> +	},
> +	.auth = {
> +		.len_bits = 124 << 3,
> +		.offset_bits = 0
> +	},
> +	.digest = {
> +		.data = {
> +			0x7D, 0x27, 0xC6, 0xDA
> +		},
> +		.len = 4,
> +		.offset_bytes = 124
> +	},
> +	.validDataLenInBits = {
> +		.len = 128 << 3
> +	},
> +	.validCipherLenInBits = {
> +		.len = 126 << 3
> +	},
> +	.validAuthLenInBits = {
> +		.len = 124 << 3
> +	},
> +};
> +
>  #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */
> --
> 2.19.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-03-25 10:47   ` [dpdk-dev] [PATCH v3] " Lukasz Krakowiak
  2019-03-25 10:47     ` Lukasz Krakowiak
  2019-03-28 13:09     ` Trahe, Fiona
@ 2019-03-28 13:10     ` Trahe, Fiona
  2019-03-28 13:10       ` Trahe, Fiona
  2019-03-29 14:28       ` Akhil Goyal
  2 siblings, 2 replies; 14+ messages in thread
From: Trahe, Fiona @ 2019-03-28 13:10 UTC (permalink / raw)
  To: Krakowiak, LukaszX, De Lara Guarch, Pablo; +Cc: dev, Trahe, Fiona

Sorry, ignore last email - it was meant to be an ack - here's the correct one.

> -----Original Message-----
> From: Krakowiak, LukaszX
> Sent: Monday, March 25, 2019 10:48 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak, LukaszX
> <lukaszx.krakowiak@intel.com>
> Subject: [PATCH v3] test: add snow3g test cases when digest is encrypted
> 
> Add test case for encryption, dectryption for snow3g when digest
> is encrypted
> 
> ---
> v3:
> * fixed path for test directory.
> 
> v2:
> * coding style improved
> 
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-03-28 13:10     ` Trahe, Fiona
@ 2019-03-28 13:10       ` Trahe, Fiona
  2019-03-29 14:28       ` Akhil Goyal
  1 sibling, 0 replies; 14+ messages in thread
From: Trahe, Fiona @ 2019-03-28 13:10 UTC (permalink / raw)
  To: Krakowiak, LukaszX, De Lara Guarch, Pablo; +Cc: dev, Trahe, Fiona

Sorry, ignore last email - it was meant to be an ack - here's the correct one.

> -----Original Message-----
> From: Krakowiak, LukaszX
> Sent: Monday, March 25, 2019 10:48 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak, LukaszX
> <lukaszx.krakowiak@intel.com>
> Subject: [PATCH v3] test: add snow3g test cases when digest is encrypted
> 
> Add test case for encryption, dectryption for snow3g when digest
> is encrypted
> 
> ---
> v3:
> * fixed path for test directory.
> 
> v2:
> * coding style improved
> 
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-03-28 13:10     ` Trahe, Fiona
  2019-03-28 13:10       ` Trahe, Fiona
@ 2019-03-29 14:28       ` Akhil Goyal
  2019-03-29 14:28         ` Akhil Goyal
  1 sibling, 1 reply; 14+ messages in thread
From: Akhil Goyal @ 2019-03-29 14:28 UTC (permalink / raw)
  To: Trahe, Fiona, Krakowiak, LukaszX, De Lara Guarch, Pablo; +Cc: dev



On 3/28/2019 6:40 PM, Trahe, Fiona wrote:
> Sorry, ignore last email - it was meant to be an ack - here's the correct one.
>
>> -----Original Message-----
>> From: Krakowiak, LukaszX
>> Sent: Monday, March 25, 2019 10:48 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak, LukaszX
>> <lukaszx.krakowiak@intel.com>
>> Subject: [PATCH v3] test: add snow3g test cases when digest is encrypted
>>
>> Add test case for encryption, dectryption for snow3g when digest
>> is encrypted
>>
>> ---
>> v3:
>> * fixed path for test directory.
>>
>> v2:
>> * coding style improved
>>
>> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
>
Applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted
  2019-03-29 14:28       ` Akhil Goyal
@ 2019-03-29 14:28         ` Akhil Goyal
  0 siblings, 0 replies; 14+ messages in thread
From: Akhil Goyal @ 2019-03-29 14:28 UTC (permalink / raw)
  To: Trahe, Fiona, Krakowiak, LukaszX, De Lara Guarch, Pablo; +Cc: dev



On 3/28/2019 6:40 PM, Trahe, Fiona wrote:
> Sorry, ignore last email - it was meant to be an ack - here's the correct one.
>
>> -----Original Message-----
>> From: Krakowiak, LukaszX
>> Sent: Monday, March 25, 2019 10:48 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Krakowiak, LukaszX
>> <lukaszx.krakowiak@intel.com>
>> Subject: [PATCH v3] test: add snow3g test cases when digest is encrypted
>>
>> Add test case for encryption, dectryption for snow3g when digest
>> is encrypted
>>
>> ---
>> v3:
>> * fixed path for test directory.
>>
>> v2:
>> * coding style improved
>>
>> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
>
Applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-03-29 14:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-13  8:43 [dpdk-dev] [PATCH] test: add snow3g test cases when digest is encrypted Lukasz Krakowiak
2019-02-13 10:20 ` Lukasz Krakowiak
2019-02-27 10:18 ` [dpdk-dev] [PATCH v2] " Lukasz Krakowiak
2019-03-01 17:36   ` Kusztal, ArkadiuszX
2019-03-22 14:51     ` Akhil Goyal
2019-03-22 14:51       ` Akhil Goyal
2019-03-25 10:47   ` [dpdk-dev] [PATCH v3] " Lukasz Krakowiak
2019-03-25 10:47     ` Lukasz Krakowiak
2019-03-28 13:09     ` Trahe, Fiona
2019-03-28 13:09       ` Trahe, Fiona
2019-03-28 13:10     ` Trahe, Fiona
2019-03-28 13:10       ` Trahe, Fiona
2019-03-29 14:28       ` Akhil Goyal
2019-03-29 14:28         ` Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).