Skip to contentSkip to conversation

FIPS improvements

PATCH In review [email protected] 3 participants 36 messages Aug 26, 2019 – Oct 15, 2019

lore
Share & tools
lore
#0 lore raw

cover FIPS improvements

From: Michael Shamis <[email protected]>

Added support for ECB mode in TDES and AES.
Fixed some bugs in TDES and AES-GCM.

Michael Shamis (12):
examples/fips: added support for SHA algorithm in FIPS tests examples/fips: added support for TDES ECB mode in FIPS tests examples/fips: added support AES ECB mode in FIPS tests examples/fips: fix bad return code in fips_test_parse_header() examples/fips: AES-GCM vectors will use aead structure examples/fips: set initial IV in AES-GCM if configured only salt value examples/fips: keep digest after crypto text examples/fips: AES-GCM decryption vectors fix examples/fips: fix KEY and PT output prints for TDES mode examples/fips: supported IV, PT and CT init for TDES ECB mode examples/fips: algorithm definition by folder if it's not in file examples/fips: erroneous overwrite of PLAINTEXT after DECRYPT

 examples/fips_validation/fips_validation.c    |  92 ++++++--
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_gcm.c     |  39 +++-
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 204 +++++++++++++++---
 6 files changed, 301 insertions(+), 49 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/12 examples/fips: added support for SHA algorithm in FIPS tests

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/fips_validation.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
examples/fips_validation/fips_validation.c +7 -5
index 8d43b267e..80fd482a1 100644
@@ -145,11 +145,13 @@ fips_test_parse_header(void)
 				if (ret < 0)
 					return 0;
 			} else if (strstr(info.vec[i], "SHA-")) {
-				algo_parsed = 1;
-				info.algo = FIPS_TEST_ALGO_SHA;
-				ret = parse_test_sha_init();
-				if (ret < 0)
-					return ret;
+				if (info.algo != FIPS_TEST_ALGO_HMAC) {
+					algo_parsed = 1;
+					info.algo = FIPS_TEST_ALGO_SHA;
+					ret = parse_test_sha_init();
+					if (ret < 0)
+						return ret;
+				}
 			}
 		}
 
Signature · 1 line
2.23.0
#2 lore raw

PATCH 2/12 examples/fips: added support for TDES ECB mode in FIPS tests

In reply to [email protected]

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/fips_validation.c    |  1 +
 examples/fips_validation/fips_validation.h    |  7 +++++
 .../fips_validation/fips_validation_tdes.c    |  7 +++++
 examples/fips_validation/main.c               | 27 ++++++++++++++++---
 4 files changed, 38 insertions(+), 4 deletions(-)
examples/fips_validation/fips_validation.c +1 -0
index 80fd482a1..fe3bcc386 100644
@@ -259,6 +259,7 @@ fips_test_init(const char *req_file_path, const char *rsp_file_path,
 
 	fips_test_clear();
 
+	strcpy(info.file_name, req_file_path);
 	info.algo = FIPS_TEST_ALGO_MAX;
 	if (parse_file_type(req_file_path) < 0) {
 		RTE_LOG(ERR, USER1, "File %s type not supported\n",
examples/fips_validation/fips_validation.h +7 -0
index b604db9ec..d487fb005 100644
@@ -105,6 +105,11 @@ enum fips_tdes_test_types {
 	TDES_MMT /* Multi block Message Test */
 };
 
+enum fips_tdes_test_mode {
+	TDES_MODE_CBC = 0,
+	TDES_MODE_ECB
+};
+
 enum fips_ccm_test_types {
 	CCM_VADT	= 1, /* Variable Associated Data Test */
 	CCM_VPT,		 /* Variable Payload Test */
@@ -130,6 +135,7 @@ struct hmac_interim_data {
 
 struct tdes_interim_data {
 	enum fips_tdes_test_types test_type;
+	enum fips_tdes_test_mode test_mode;
 	uint32_t nb_keys;
 };
 
@@ -156,6 +162,7 @@ struct fips_test_interim_info {
 	char *vec[MAX_LINE_PER_VECTOR];
 	uint32_t nb_vec_lines;
 	char device_name[MAX_STRING_SIZE];
+	char file_name[MAX_STRING_SIZE];
 
 	union {
 		struct aesavs_interim_data aes_data;
examples/fips_validation/fips_validation_tdes.c +7 -0
index 15ee434e1..d7f4d58b0 100644
@@ -12,6 +12,7 @@
 
 #define NEW_LINE_STR	"#"
 #define TEST_TYPE_KEY	" for CBC"
+#define TEST_TYPE_ECB_KEY	" for ECB"
 #define TEST_CBCI_KEY	" for CBCI"
 
 #define ENC_STR		"[ENCRYPT]"
@@ -250,6 +251,12 @@ parse_test_tdes_init(void)
 			if (strstr(line, test_types[j].desc)) {
 				info.interim_info.tdes_data.test_type =
 						test_types[j].type;
+				if (strstr(line, TEST_TYPE_ECB_KEY))
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_ECB;
+				else
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_CBC;
 				break;
 			}
 	}
examples/fips_validation/main.c +23 -4
index 813534068..7a379bc99 100644
@@ -689,16 +689,24 @@ prepare_tdes_xform(struct rte_crypto_sym_xform *xform)
 
 	xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
-	cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (info.interim_info.tdes_data.test_mode == TDES_MODE_CBC)
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	else
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_ECB;
 	cipher_xform->op = (info.op == FIPS_TEST_ENC_AUTH_GEN) ?
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT :
 			RTE_CRYPTO_CIPHER_OP_DECRYPT;
 	cipher_xform->key.data = vec.cipher_auth.key.val;
 	cipher_xform->key.length = vec.cipher_auth.key.len;
-	cipher_xform->iv.length = vec.iv.len;
-	cipher_xform->iv.offset = IV_OFF;
 
-	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (cipher_xform->algo == RTE_CRYPTO_CIPHER_3DES_CBC) {
+		cipher_xform->iv.length = vec.iv.len;
+		cipher_xform->iv.offset = IV_OFF;
+	} else {
+		cipher_xform->iv.length = 0;
+		cipher_xform->iv.offset = 0;
+	}
+	cap_idx.algo.cipher = cipher_xform->algo;
 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
 	cap = rte_cryptodev_sym_capability_get(env.dev_id, &cap_idx);
@@ -1387,6 +1395,17 @@ init_test_ops(void)
 			test_ops.test = fips_generic_test;
 		break;
 	default:
+		if (strstr(info.file_name, "TECB") ||
+				strstr(info.file_name, "TCBC")) {
+			info.algo = FIPS_TEST_ALGO_TDES;
+			test_ops.prepare_op = prepare_cipher_op;
+			test_ops.prepare_xform	= prepare_tdes_xform;
+			if (info.interim_info.tdes_data.test_type == TDES_MCT)
+				test_ops.test = fips_mct_tdes_test;
+			else
+				test_ops.test = fips_generic_test;
+			break;
+		}
 		return -1;
 	}
 
Signature · 1 line
2.23.0
#3 lore raw

PATCH 3/12 examples/fips: added support AES ECB mode in FIPS tests

In reply to [email protected]

From: Michael Shamis <[email protected]>

---
 .../fips_validation/fips_validation_aes.c     |  1 +
 examples/fips_validation/main.c               | 96 +++++++++++++++++--
 2 files changed, 91 insertions(+), 6 deletions(-)
examples/fips_validation/fips_validation_aes.c +1 -0
index 8cbc158eb..010a82627 100644
@@ -44,6 +44,7 @@ struct aes_test_algo {
 	enum rte_crypto_cipher_algorithm algo;
 } const algo_con[] = {
 		{"CBC", RTE_CRYPTO_CIPHER_AES_CBC},
+		{"ECB", RTE_CRYPTO_CIPHER_AES_ECB},
 };
 
 static int
examples/fips_validation/main.c +90 -6

125 lines not on this page · raw message

Signature · 1 line
2.23.0
#4 lore raw

PATCH 4/12 examples/fips: fix bad return code in fips_test_parse_header()

In reply to [email protected]

From: Michael Shamis <[email protected]>

Returning correct error value by fips_test_parse_header() allows graceful exit of fips application.

---
 examples/fips_validation/fips_validation.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
examples/fips_validation/fips_validation.c +3 -3
index fe3bcc386..91e6d48e7 100644
@@ -125,13 +125,13 @@ fips_test_parse_header(void)
 				info.algo = FIPS_TEST_ALGO_AES_CMAC;
 				ret = parse_test_cmac_init();
 				if (ret < 0)
-					return 0;
+					return ret;
 			} else if (strstr(info.vec[i], "CCM")) {
 				algo_parsed = 1;
 				info.algo = FIPS_TEST_ALGO_AES_CCM;
 				ret = parse_test_ccm_init();
 				if (ret < 0)
-					return 0;
+					return ret;
 			} else if (strstr(info.vec[i], "HMAC")) {
 				algo_parsed = 1;
 				info.algo = FIPS_TEST_ALGO_HMAC;
@@ -143,7 +143,7 @@ fips_test_parse_header(void)
 				info.algo = FIPS_TEST_ALGO_TDES;
 				ret = parse_test_tdes_init();
 				if (ret < 0)
-					return 0;
+					return ret;
 			} else if (strstr(info.vec[i], "SHA-")) {
 				if (info.algo != FIPS_TEST_ALGO_HMAC) {
 					algo_parsed = 1;
Signature · 1 line
2.23.0
#5 lore raw

Re: [dpdk-dev] [PATCH 04/12] examples/fips: fix bad return code in fips_test_parse_header()

Hi Michael,

Title should be " examples/fips_validation: fix bad return value "

Quoted 3 lines

Returning correct error value by fips_test_parse_header() allows graceful exit of fips application.

Please add a fixes line here and cc stable.

It would be good if you can separate out the fixes from this patchset which add some functionality.

-Akhil

Quoted 38 lines
---
 examples/fips_validation/fips_validation.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
examples/fips_validation/fips_validation.c +3 -4
index fe3bcc386..91e6d48e7 100644
@@ -125,13 +125,13 @@ fips_test_parse_header(void)
 				info.algo = FIPS_TEST_ALGO_AES_CMAC;
 				ret = parse_test_cmac_init();
 				if (ret < 0)
-					return 0;
+					return ret;
 			} else if (strstr(info.vec[i], "CCM")) {
 				algo_parsed = 1;
 				info.algo = FIPS_TEST_ALGO_AES_CCM;
 				ret = parse_test_ccm_init();
 				if (ret < 0)
-					return 0;
+					return ret;
 			} else if (strstr(info.vec[i], "HMAC")) {
 				algo_parsed = 1;
 				info.algo = FIPS_TEST_ALGO_HMAC;
@@ -143,7 +143,7 @@ fips_test_parse_header(void)
 				info.algo = FIPS_TEST_ALGO_TDES;
 				ret = parse_test_tdes_init();
 				if (ret < 0)
-					return 0;
+					return ret;
 			} else if (strstr(info.vec[i], "SHA-")) {
 				if (info.algo != FIPS_TEST_ALGO_HMAC) {
 					algo_parsed = 1;
--

2.23.0

#6 lore raw

PATCH 5/12 examples/fips: AES-GCM vectors will use aead structure

In reply to [email protected]

From: Michael Shamis <[email protected]>

Before the fix AES-GCM vectores were defined by cipher_auth structure but handled by aead structure and that leads to FIPS test failure.

---
 examples/fips_validation/fips_validation_gcm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
examples/fips_validation/fips_validation_gcm.c +8 -8
index 0509b101a..ea48ddf70 100644
@@ -34,29 +34,29 @@
 #define NEG_TEST_STR	"FAIL"
 
 struct fips_test_callback gcm_dec_vectors[] = {
-		{KEY_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.key},
+		{KEY_STR, parse_uint8_known_len_hex_str, &vec.aead.key},
 		{IV_STR, parse_uint8_known_len_hex_str, &vec.iv},
 		{CT_STR, parse_uint8_known_len_hex_str, &vec.ct},
-		{AAD_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.aad},
+		{AAD_STR, parse_uint8_known_len_hex_str, &vec.aead.aad},
 		{TAG_STR, parse_uint8_known_len_hex_str,
-				&vec.cipher_auth.digest},
+				&vec.aead.digest},
 		{NULL, NULL, NULL} /**< end pointer */
 };
 struct fips_test_callback gcm_interim_vectors[] = {
-		{KEYLEN_STR, parser_read_uint32_bit_val, &vec.cipher_auth.key},
+		{KEYLEN_STR, parser_read_uint32_bit_val, &vec.aead.key},
 		{IVLEN_STR, parser_read_uint32_bit_val, &vec.iv},
 		{PTLEN_STR, parser_read_uint32_bit_val, &vec.pt},
-		{AADLEN_STR, parser_read_uint32_bit_val, &vec.cipher_auth.aad},
+		{AADLEN_STR, parser_read_uint32_bit_val, &vec.aead.aad},
 		{TAGLEN_STR, parser_read_uint32_bit_val,
-				&vec.cipher_auth.digest},
+				&vec.aead.digest},
 		{NULL, NULL, NULL} /**< end pointer */
 };
 
 struct fips_test_callback gcm_enc_vectors[] = {
-		{KEY_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.key},
+		{KEY_STR, parse_uint8_known_len_hex_str, &vec.aead.key},
 		{IV_STR, parse_uint8_known_len_hex_str, &vec.iv},
 		{PT_STR, parse_uint8_known_len_hex_str, &vec.pt},
-		{AAD_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.aad},
+		{AAD_STR, parse_uint8_known_len_hex_str, &vec.aead.aad},
 		{NULL, NULL, NULL} /**< end pointer */
 };
 
Signature · 1 line
2.23.0
#7 lore raw

PATCH 6/12 examples/fips: set initial IV in AES-GCM if configured only salt value

In reply to [email protected]

From: Michael Shamis <[email protected]>

Configurated AES-GCM IV may include only salt value which length is 12B. In this case driver should set second part of IV to initial value = 0x1.

---
 examples/fips_validation/main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
examples/fips_validation/main.c +9 -2
index c83763b13..895bfa7d8 100644
@@ -25,6 +25,7 @@
 #define CRYPTODEV_BK_DIR_KEY	"broken-test-dir"
 #define CRYPTODEV_ENC_KEYWORD	"enc"
 #define CRYPTODEV_DEC_KEYWORD	"dec"
+#define IV_SALT_LEN 12
 
 struct fips_test_vector vec;
 struct fips_test_interim_info info;
@@ -580,10 +581,16 @@ prepare_aead_op(void)
 	__rte_crypto_op_reset(env.op, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
 	rte_pktmbuf_reset(env.mbuf);
 
-	if (info.algo == FIPS_TEST_ALGO_AES_CCM)
+	if (info.algo == FIPS_TEST_ALGO_AES_CCM) {
 		memcpy(iv + 1, vec.iv.val, vec.iv.len);
-	else
+	} else {
 		memcpy(iv, vec.iv.val, vec.iv.len);
+		/* Set initial IV if specified only salt IV value */
+		if (vec.iv.len == IV_SALT_LEN) {
+			memset(&iv[vec.iv.len], 0, 4);
+			iv[vec.iv.len + 3] = 1;
+		}
+	}
 
 	sym->m_src = env.mbuf;
 	sym->aead.data.offset = 0;
Signature · 1 line
2.23.0
#8 lore raw

PATCH 7/12 examples/fips: keep digest after crypto text

In reply to [email protected]

From: Michael Shamis <[email protected]>

Fix of GCM FIPS bug: ICV was not copied after the crypto text in decryption operation so SAM failed to check authentication in GCM mode.

---
 examples/fips_validation/main.c | 4 ++++
 1 file changed, 4 insertions(+)
examples/fips_validation/main.c +4 -0
index 895bfa7d8..1d621f60a 100644
@@ -636,6 +636,10 @@ prepare_aead_op(void)
 		}
 
 		memcpy(ct, vec.ct.val, vec.ct.len);
+
+		/* keep digest after crypto text */
+		memcpy(ct + vec.ct.len, vec.aead.digest.val,
+			vec.aead.digest.len);
 		sym->aead.data.length = vec.ct.len;
 		sym->aead.digest.data = vec.aead.digest.val;
 		sym->aead.digest.phys_addr = rte_malloc_virt2iova(
Signature · 1 line
2.23.0
#9 lore raw

PATCH 8/12 examples/fips: AES-GCM decryption vectors fix

In reply to [email protected]

From: Michael Shamis <[email protected]>

AES-GCM CAVS vectors for decryption set PTlen (plain text length) but provide crypto text and application expected CTlen to be not null. Now we assign PTlen to CTlen in decryption scenario and it allows to application to handle AES-GCM decryption vectors.

---
 .../fips_validation/fips_validation_gcm.c     | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
examples/fips_validation/fips_validation_gcm.c +22 -1
index ea48ddf70..f68b4ea82 100644
@@ -33,10 +33,15 @@
 
 #define NEG_TEST_STR	"FAIL"
 
+static int
+parse_uint8_known_len_hex_str_dec(const char *key,
+						char *src,
+						struct fips_val *val);
+
 struct fips_test_callback gcm_dec_vectors[] = {
 		{KEY_STR, parse_uint8_known_len_hex_str, &vec.aead.key},
 		{IV_STR, parse_uint8_known_len_hex_str, &vec.iv},
-		{CT_STR, parse_uint8_known_len_hex_str, &vec.ct},
+		{CT_STR, parse_uint8_known_len_hex_str_dec, &vec.ct},
 		{AAD_STR, parse_uint8_known_len_hex_str, &vec.aead.aad},
 		{TAG_STR, parse_uint8_known_len_hex_str,
 				&vec.aead.digest},
@@ -123,3 +128,19 @@ parse_test_gcm_init(void)
 
 	return 0;
 }
+
+static int
+parse_uint8_known_len_hex_str_dec(const char *key,
+						char *src,
+						struct fips_val *val)
+{
+	/* AES-GCM CAVS vectors for decryption set PTlen (plain text length)
+	 * but provide crypto text.
+	 * In order to compensate the behavior we assign PTlen to CTlen
+	 * (crypto text length) which is used for calculations
+	 */
+	if (info.op == FIPS_TEST_DEC_AUTH_VERIF)
+		vec.ct.len = vec.pt.len;
+
+	return parse_uint8_known_len_hex_str(key, src, val);
+}
Signature · 1 line
2.23.0
#10 lore raw

PATCH 9/12 examples/fips: fix KEY and PT output prints for TDES mode

In reply to [email protected]

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/fips_validation.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
examples/fips_validation/fips_validation.c +20 -0
index 91e6d48e7..ba513672e 100644
@@ -11,6 +11,10 @@
 
 #include "fips_validation.h"
 
+#define COUNT0_STR	"COUNT = 0  "
+#define KEY_STR		"KEY"
+#define NK_STR		"NumKey"
+
 #define skip_white_spaces(pos)			\
 ({						\
 	__typeof__(pos) _p = (pos);		\
@@ -68,6 +72,22 @@ fips_test_fetch_one_block(void)
 		if (size == 0)
 			break;
 
+		/* if first line is KEY-line then insert COUNT-line */
+		if (i == 0) {
+			if (strstr(info.one_line_text, KEY_STR)) {
+				info.vec[0] = calloc(1, sizeof(COUNT0_STR));
+				strlcpy(info.vec[0],
+						COUNT0_STR,
+						sizeof(COUNT0_STR));
+				i = 1;
+				info.nb_vec_lines = 1;
+			}
+		}
+
+		/* don't copy NumKey-line */
+		if (strstr(info.one_line_text, NK_STR))
+			break;
+
 		info.vec[i] = calloc(1, size + 5);
 		if (info.vec[i] == NULL)
 			goto error_exit;
Signature · 1 line
2.23.0
#11 lore raw

PATCH 10/12 examples/fips: supported IV, PT and CT init for TDES ECB mode

In reply to [email protected]

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/main.c | 66 +++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 16 deletions(-)
examples/fips_validation/main.c +50 -16
index 1d621f60a..3eda0f554 100644
@@ -1064,6 +1064,7 @@ fips_mct_tdes_test(void)
 	uint8_t prev_in[TDES_BLOCK_SIZE] = {0};
 	uint32_t i, j, k;
 	int ret;
+	int test_mode = info.interim_info.tdes_data.test_mode;
 
 	for (i = 0; i < TDES_EXTERN_ITER; i++) {
 		if (i != 0)
@@ -1090,25 +1091,50 @@ fips_mct_tdes_test(void)
 				memcpy(prev_out, val.val, TDES_BLOCK_SIZE);
 
 				if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-					memcpy(vec.pt.val, vec.iv.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.iv.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.pt.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.pt.val, vec.iv.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.iv.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
+
 				} else {
-					memcpy(vec.iv.val, vec.ct.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.ct.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.iv.val, vec.ct.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
 				}
 				continue;
 			}
 
 			if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.pt.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, val.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.pt.val, prev_out,
+						   TDES_BLOCK_SIZE);
+				}
 			} else {
-				memcpy(vec.iv.val, vec.ct.val, TDES_BLOCK_SIZE);
-				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, vec.ct.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				}
 			}
 
 			if (j == TDES_INTERN_ITER - 1)
@@ -1167,11 +1193,19 @@ fips_mct_tdes_test(void)
 					val_key.val[k] : (val_key.val[k] ^ 0x1);
 
 		if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-			memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-			memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.pt.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
+				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			}
 		} else {
-			memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
-			memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			}
 		}
 	}
 
Signature · 1 line
2.23.0
#12 lore raw

PATCH 11/12 examples/fips: algorithm definition by folder if it's not in file

In reply to [email protected]

From: Michael Shamis <[email protected]>

In order to find algorithm used the folder name if it is not defined within the file.

---
 examples/fips_validation/fips_validation.c | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
examples/fips_validation/fips_validation.c +42 -0
index ba513672e..fcc0c985d 100644
@@ -248,6 +248,48 @@ fips_test_parse_header(void)
 		fprintf(info.fp_wr, "%s\n", info.vec[i]);
 	}
 
+	/* use folder name if algorithm is not found yet*/
+	if (info.algo == FIPS_TEST_ALGO_MAX) {
+		if (strstr(info.file_name, "AESVS")) {
+			info.algo = FIPS_TEST_ALGO_AES;
+			ret = parse_test_aes_init();
+			if (ret < 0)
+				return ret;
+		} else if (strstr(info.file_name, "GCM")) {
+			info.algo = FIPS_TEST_ALGO_AES_GCM;
+			ret = parse_test_gcm_init();
+			if (ret < 0)
+				return ret;
+		} else if (strstr(info.file_name, "CMAC")) {
+			info.algo = FIPS_TEST_ALGO_AES_CMAC;
+			ret = parse_test_cmac_init();
+			if (ret < 0)
+				return ret;
+		} else if (strstr(info.file_name, "CCM")) {
+			info.algo = FIPS_TEST_ALGO_AES_CCM;
+			ret = parse_test_ccm_init();
+			if (ret < 0)
+				return ret;
+		} else if (strstr(info.file_name, "HMAC")) {
+			info.algo = FIPS_TEST_ALGO_HMAC;
+			ret = parse_test_hmac_init();
+			if (ret < 0)
+				return ret;
+		} else if (strstr(info.file_name, "TDES")) {
+			info.algo = FIPS_TEST_ALGO_TDES;
+			ret = parse_test_tdes_init();
+			if (ret < 0)
+				return ret;
+		} else if (strstr(info.file_name, "SHA-")) {
+			if (info.algo != FIPS_TEST_ALGO_HMAC) {
+				info.algo = FIPS_TEST_ALGO_SHA;
+				ret = parse_test_sha_init();
+				if (ret < 0)
+					return ret;
+			}
+		}
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.23.0
#13 lore raw

PATCH 12/12 examples/fips: erroneous overwrite of PLAINTEXT after DECRYPT

In reply to [email protected]

From: Michael Shamis <[email protected]>

fix erroneous overwrite of PLAINTEXT-line after [DECRYPT] tag

---
 examples/fips_validation/fips_validation.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
examples/fips_validation/fips_validation.c +7 -4
index fcc0c985d..4d0f240b8 100644
@@ -401,10 +401,13 @@ fips_test_parse_one_case(void)
 	}
 
 	if (is_interim) {
-		for (i = 0; i < info.nb_vec_lines; i++)
-			fprintf(info.fp_wr, "%s\n", info.vec[i]);
-		fprintf(info.fp_wr, "\n");
-		return 1;
+		if (!(strstr(info.vec[0], "DECRYPT") &&
+			  info.nb_vec_lines > 1)) {
+			for (i = 0; i < info.nb_vec_lines; i++)
+				fprintf(info.fp_wr, "%s\n", info.vec[i]);
+			fprintf(info.fp_wr, "\n");
+			return 1;
+		}
 	}
 
 	for (i = 0; i < info.nb_vec_lines; i++) {
Signature · 1 line
2.23.0
#14 lore raw
In reply to [email protected]

Hi Michael,

Please try to improve descriptions and patch titles as per the suggestions given below. There are many patches which are fixes. Are the eligible for backport to stable branches? The support which is getting added, is it eligible for documentation update for the application.

-Akhil

Quoted 6 lines

Added support for ECB mode in TDES and AES.
Fixed some bugs in TDES and AES-GCM.

Michael Shamis (12):
examples/fips: added support for SHA algorithm in FIPS tests

examples/fips_validation: support SHA

Quoted 1 line

examples/fips: added support for TDES ECB mode in FIPS tests

examples/fips_validation: support TDES ECB

Quoted 1 line

examples/fips: added support AES ECB mode in FIPS tests

examples/fips_validation: support AES ECB

Quoted 1 line

examples/fips: fix bad return code in fips_test_parse_header()

examples/fips_validation: fix bad return value
Can be a separate patch from this set. Also send to stable.

Quoted 1 line

examples/fips: AES-GCM vectors will use aead structure

examples/fips_validation: use AEAD based structs for AES-GCM rather it is a fix and should be sent to stable and the title would be examples/fips_validation: fix structs used for AES-GCM

Quoted 1 line

examples/fips: set initial IV in AES-GCM if configured only salt value

examples/fips_validation: initialize IV for AES-GCM

Quoted 1 line

examples/fips: keep digest after crypto text

examples/fips_validation: move digest after cipher text

Quoted 1 line

examples/fips: AES-GCM decryption vectors fix

examples/fips_validation: fix AES-GCM decryption vector Add fixes line and cc stable. Can be a separate patchset for fixes.

Quoted 1 line

examples/fips: fix KEY and PT output prints for TDES mode

Does not have a patch description and title does not look to justify the patch.

Quoted 1 line

examples/fips: supported IV, PT and CT init for TDES ECB mode

Again there is no patch description and title is pretty long. Try to make it short.

Quoted 1 line

examples/fips: algorithm definition by folder if it's not in file

examples/fips_validation: improve algo parsing logic update description text to elaborate the need for this logic

Quoted 1 line

examples/fips: erroneous overwrite of PLAINTEXT after DECRYPT

examples/fips_validation: fix plain text overwrite send to stable and add fixes line.

Quoted 11 lines
 examples/fips_validation/fips_validation.c    |  92 ++++++--
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_gcm.c     |  39 +++-
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 204 +++++++++++++++---
 6 files changed, 301 insertions(+), 49 deletions(-)

--
2.23.0

#15 lore raw

Hi Akhil,

I send 2 patch sets: one for new functionality support and another one for fixes. One patch was sent separately from both of the sets according to your requirement:

Quoted 2 lines
Quoted 1 line

examples/fips: fix bad return code in fips_test_parse_header()

examples/fips_validation: fix bad return value Can be a separate patch from this set. Also send to stable.

Please instruct me how to send the patches to stable.

Thanks,
Michael

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Wednesday, September 4, 2019 1:14 PM
To: Michael Shamis <[email protected]>; [email protected]
Cc: [email protected]; Liron Himi <[email protected]>
Subject: [EXT] RE: [dpdk-dev] [PATCH 00/12] FIPS improvements

External Email

----------------------------------------------------------------------
Hi Michael,

Please try to improve descriptions and patch titles as per the suggestions given below. There are many patches which are fixes. Are the eligible for backport to stable branches? The support which is getting added, is it eligible for documentation update for the application.

-Akhil

Quoted 6 lines

Added support for ECB mode in TDES and AES.
Fixed some bugs in TDES and AES-GCM.

Michael Shamis (12):
examples/fips: added support for SHA algorithm in FIPS tests

examples/fips_validation: support SHA

Quoted 1 line

examples/fips: added support for TDES ECB mode in FIPS tests

examples/fips_validation: support TDES ECB

Quoted 1 line

examples/fips: added support AES ECB mode in FIPS tests

examples/fips_validation: support AES ECB

Quoted 1 line

examples/fips: fix bad return code in fips_test_parse_header()

examples/fips_validation: fix bad return value Can be a separate patch from this set. Also send to stable.

Quoted 1 line

examples/fips: AES-GCM vectors will use aead structure

examples/fips_validation: use AEAD based structs for AES-GCM rather it is a fix and should be sent to stable and the title would be examples/fips_validation: fix structs used for AES-GCM

Quoted 2 lines

examples/fips: set initial IV in AES-GCM if configured only salt
value

examples/fips_validation: initialize IV for AES-GCM

Quoted 1 line

examples/fips: keep digest after crypto text

examples/fips_validation: move digest after cipher text

Quoted 1 line

examples/fips: AES-GCM decryption vectors fix

examples/fips_validation: fix AES-GCM decryption vector Add fixes line and cc stable. Can be a separate patchset for fixes.

Quoted 1 line

examples/fips: fix KEY and PT output prints for TDES mode

Does not have a patch description and title does not look to justify the patch.

Quoted 1 line

examples/fips: supported IV, PT and CT init for TDES ECB mode

Again there is no patch description and title is pretty long. Try to make it short.

Quoted 1 line

examples/fips: algorithm definition by folder if it's not in file

examples/fips_validation: improve algo parsing logic update description text to elaborate the need for this logic

Quoted 1 line

examples/fips: erroneous overwrite of PLAINTEXT after DECRYPT

examples/fips_validation: fix plain text overwrite send to stable and add fixes line.

Quoted 11 lines
 examples/fips_validation/fips_validation.c    |  92 ++++++--
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_gcm.c     |  39 +++-
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 204 +++++++++++++++---
 6 files changed, 301 insertions(+), 49 deletions(-)

--
2.23.0

#16 lore raw
Quoted 7 lines

Hi Akhil,

I send 2 patch sets: one for new functionality support and another one for fixes. One patch was sent separately from both of the sets according to your requirement:

Ok will have a look.
Thanks.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

examples/fips: fix bad return code in fips_test_parse_header()

examples/fips_validation: fix bad return value Can be a separate patch from

this set. Also send to stable.

Please instruct me how to send the patches to stable.

You just need to cc [email protected] and add this in the commit message as well below the fixes line. You can check the git log for reference for the fixes.

I will do this when I will apply the patch.
You can take care of this in future.

Thanks,
Akhil

Quoted 84 lines

Thanks,
Michael

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Wednesday, September 4, 2019 1:14 PM
To: Michael Shamis <[email protected]>; [email protected]
Cc: [email protected]; Liron Himi <[email protected]>
Subject: [EXT] RE: [dpdk-dev] [PATCH 00/12] FIPS improvements

External Email

----------------------------------------------------------------------
Hi Michael,

Please try to improve descriptions and patch titles as per the suggestions given below.
There are many patches which are fixes. Are the eligible for backport to stable branches?
The support which is getting added, is it eligible for documentation update for the application.

-Akhil

Quoted 6 lines

Added support for ECB mode in TDES and AES.
Fixed some bugs in TDES and AES-GCM.

Michael Shamis (12):
examples/fips: added support for SHA algorithm in FIPS tests

examples/fips_validation: support SHA

Quoted 1 line

examples/fips: added support for TDES ECB mode in FIPS tests

examples/fips_validation: support TDES ECB

Quoted 1 line

examples/fips: added support AES ECB mode in FIPS tests

examples/fips_validation: support AES ECB

Quoted 1 line

examples/fips: fix bad return code in fips_test_parse_header()

examples/fips_validation: fix bad return value Can be a separate patch from this set. Also send to stable.

Quoted 1 line

examples/fips: AES-GCM vectors will use aead structure

examples/fips_validation: use AEAD based structs for AES-GCM rather it is a fix and should be sent to stable and the title would be examples/fips_validation: fix structs used for AES-GCM

Quoted 2 lines

examples/fips: set initial IV in AES-GCM if configured only salt
value

examples/fips_validation: initialize IV for AES-GCM

Quoted 1 line

examples/fips: keep digest after crypto text

examples/fips_validation: move digest after cipher text

Quoted 1 line

examples/fips: AES-GCM decryption vectors fix

examples/fips_validation: fix AES-GCM decryption vector Add fixes line and cc stable. Can be a separate patchset for fixes.

Quoted 1 line

examples/fips: fix KEY and PT output prints for TDES mode

Does not have a patch description and title does not look to justify the patch.

Quoted 1 line

examples/fips: supported IV, PT and CT init for TDES ECB mode

Again there is no patch description and title is pretty long. Try to make it short.

Quoted 1 line

examples/fips: algorithm definition by folder if it's not in file

examples/fips_validation: improve algo parsing logic update description text to elaborate the need for this logic

Quoted 1 line

examples/fips: erroneous overwrite of PLAINTEXT after DECRYPT

examples/fips_validation: fix plain text overwrite send to stable and add fixes line.

Quoted 11 lines
 examples/fips_validation/fips_validation.c    |  92 ++++++--
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_gcm.c     |  39 +++-
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 204 +++++++++++++++---
 6 files changed, 301 insertions(+), 49 deletions(-)

--
2.23.0

#17 lore raw

v2 cover Support ECB for AES and TDES

In reply to [email protected]

From: Michael Shamis <[email protected]>

Michael Shamis (3):
examples/fips_validation: added support for TDES ECB examples/fips_validation: added support AES ECB examples/fips_validation: separated init for TDES ECB and CBC

 examples/fips_validation/fips_validation.c    |   1 +
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 189 +++++++++++++++---
 5 files changed, 179 insertions(+), 26 deletions(-)
Signature · 1 line
2.23.0
#18 lore raw

PATCH v2 1/3 examples/fips_validation: added support for TDES ECB

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/fips_validation.c    |  1 +
 examples/fips_validation/fips_validation.h    |  7 +++++
 .../fips_validation/fips_validation_tdes.c    |  7 +++++
 examples/fips_validation/main.c               | 27 ++++++++++++++++---
 4 files changed, 38 insertions(+), 4 deletions(-)
examples/fips_validation/fips_validation.c +1 -0
index 8d43b267e..07ffa62e9 100644
@@ -257,6 +257,7 @@ fips_test_init(const char *req_file_path, const char *rsp_file_path,
 
 	fips_test_clear();
 
+	strcpy(info.file_name, req_file_path);
 	info.algo = FIPS_TEST_ALGO_MAX;
 	if (parse_file_type(req_file_path) < 0) {
 		RTE_LOG(ERR, USER1, "File %s type not supported\n",
examples/fips_validation/fips_validation.h +7 -0
index b604db9ec..d487fb005 100644
@@ -105,6 +105,11 @@ enum fips_tdes_test_types {
 	TDES_MMT /* Multi block Message Test */
 };
 
+enum fips_tdes_test_mode {
+	TDES_MODE_CBC = 0,
+	TDES_MODE_ECB
+};
+
 enum fips_ccm_test_types {
 	CCM_VADT	= 1, /* Variable Associated Data Test */
 	CCM_VPT,		 /* Variable Payload Test */
@@ -130,6 +135,7 @@ struct hmac_interim_data {
 
 struct tdes_interim_data {
 	enum fips_tdes_test_types test_type;
+	enum fips_tdes_test_mode test_mode;
 	uint32_t nb_keys;
 };
 
@@ -156,6 +162,7 @@ struct fips_test_interim_info {
 	char *vec[MAX_LINE_PER_VECTOR];
 	uint32_t nb_vec_lines;
 	char device_name[MAX_STRING_SIZE];
+	char file_name[MAX_STRING_SIZE];
 
 	union {
 		struct aesavs_interim_data aes_data;
examples/fips_validation/fips_validation_tdes.c +7 -0
index 15ee434e1..d7f4d58b0 100644
@@ -12,6 +12,7 @@
 
 #define NEW_LINE_STR	"#"
 #define TEST_TYPE_KEY	" for CBC"
+#define TEST_TYPE_ECB_KEY	" for ECB"
 #define TEST_CBCI_KEY	" for CBCI"
 
 #define ENC_STR		"[ENCRYPT]"
@@ -250,6 +251,12 @@ parse_test_tdes_init(void)
 			if (strstr(line, test_types[j].desc)) {
 				info.interim_info.tdes_data.test_type =
 						test_types[j].type;
+				if (strstr(line, TEST_TYPE_ECB_KEY))
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_ECB;
+				else
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_CBC;
 				break;
 			}
 	}
examples/fips_validation/main.c +23 -4
index 813534068..7a379bc99 100644
@@ -689,16 +689,24 @@ prepare_tdes_xform(struct rte_crypto_sym_xform *xform)
 
 	xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
-	cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (info.interim_info.tdes_data.test_mode == TDES_MODE_CBC)
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	else
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_ECB;
 	cipher_xform->op = (info.op == FIPS_TEST_ENC_AUTH_GEN) ?
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT :
 			RTE_CRYPTO_CIPHER_OP_DECRYPT;
 	cipher_xform->key.data = vec.cipher_auth.key.val;
 	cipher_xform->key.length = vec.cipher_auth.key.len;
-	cipher_xform->iv.length = vec.iv.len;
-	cipher_xform->iv.offset = IV_OFF;
 
-	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (cipher_xform->algo == RTE_CRYPTO_CIPHER_3DES_CBC) {
+		cipher_xform->iv.length = vec.iv.len;
+		cipher_xform->iv.offset = IV_OFF;
+	} else {
+		cipher_xform->iv.length = 0;
+		cipher_xform->iv.offset = 0;
+	}
+	cap_idx.algo.cipher = cipher_xform->algo;
 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
 	cap = rte_cryptodev_sym_capability_get(env.dev_id, &cap_idx);
@@ -1387,6 +1395,17 @@ init_test_ops(void)
 			test_ops.test = fips_generic_test;
 		break;
 	default:
+		if (strstr(info.file_name, "TECB") ||
+				strstr(info.file_name, "TCBC")) {
+			info.algo = FIPS_TEST_ALGO_TDES;
+			test_ops.prepare_op = prepare_cipher_op;
+			test_ops.prepare_xform	= prepare_tdes_xform;
+			if (info.interim_info.tdes_data.test_type == TDES_MCT)
+				test_ops.test = fips_mct_tdes_test;
+			else
+				test_ops.test = fips_generic_test;
+			break;
+		}
 		return -1;
 	}
 
Signature · 1 line
2.23.0
#19 lore raw

PATCH v2 2/3 examples/fips_validation: added support AES ECB

In reply to [email protected]

From: Michael Shamis <[email protected]>

---
 .../fips_validation/fips_validation_aes.c     |  1 +
 examples/fips_validation/main.c               | 96 +++++++++++++++++--
 2 files changed, 91 insertions(+), 6 deletions(-)
examples/fips_validation/fips_validation_aes.c +1 -0
index 8cbc158eb..010a82627 100644
@@ -44,6 +44,7 @@ struct aes_test_algo {
 	enum rte_crypto_cipher_algorithm algo;
 } const algo_con[] = {
 		{"CBC", RTE_CRYPTO_CIPHER_AES_CBC},
+		{"ECB", RTE_CRYPTO_CIPHER_AES_ECB},
 };
 
 static int
examples/fips_validation/main.c +90 -6

125 lines not on this page · raw message

Signature · 1 line
2.23.0
#20 lore raw

PATCH v2 3/3 examples/fips_validation: separated init for TDES ECB and CBC

In reply to [email protected]

From: Michael Shamis <[email protected]>

TDES: IV, PT and CT are initiated according to ECB or CBC cipher mode now

---
 examples/fips_validation/main.c | 66 +++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 16 deletions(-)
examples/fips_validation/main.c +50 -16
index c83763b13..f8694ef96 100644
@@ -1053,6 +1053,7 @@ fips_mct_tdes_test(void)
 	uint8_t prev_in[TDES_BLOCK_SIZE] = {0};
 	uint32_t i, j, k;
 	int ret;
+	int test_mode = info.interim_info.tdes_data.test_mode;
 
 	for (i = 0; i < TDES_EXTERN_ITER; i++) {
 		if (i != 0)
@@ -1079,25 +1080,50 @@ fips_mct_tdes_test(void)
 				memcpy(prev_out, val.val, TDES_BLOCK_SIZE);
 
 				if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-					memcpy(vec.pt.val, vec.iv.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.iv.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.pt.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.pt.val, vec.iv.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.iv.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
+
 				} else {
-					memcpy(vec.iv.val, vec.ct.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.ct.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.iv.val, vec.ct.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
 				}
 				continue;
 			}
 
 			if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.pt.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, val.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.pt.val, prev_out,
+						   TDES_BLOCK_SIZE);
+				}
 			} else {
-				memcpy(vec.iv.val, vec.ct.val, TDES_BLOCK_SIZE);
-				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, vec.ct.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				}
 			}
 
 			if (j == TDES_INTERN_ITER - 1)
@@ -1156,11 +1182,19 @@ fips_mct_tdes_test(void)
 					val_key.val[k] : (val_key.val[k] ^ 0x1);
 
 		if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-			memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-			memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.pt.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
+				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			}
 		} else {
-			memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
-			memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			}
 		}
 	}
 
Signature · 1 line
2.23.0
#21 lore raw

v3 cover support ECB for AES and TDES

In reply to [email protected]

From: Michael Shamis <[email protected]>

Michael Shamis (3):
examples/fips_validation: add TDES ECB support
examples/fips_validation: add AES ECB support
examples/fips_validation: separate ECB and CBC

 examples/fips_validation/fips_validation.c    |   1 +
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 189 +++++++++++++++---
 5 files changed, 179 insertions(+), 26 deletions(-)
Signature · 1 line
2.23.0
#22 lore raw

PATCH v3 1/3 examples/fips_validation: add TDES ECB support

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/fips_validation.c    |  1 +
 examples/fips_validation/fips_validation.h    |  7 +++++
 .../fips_validation/fips_validation_tdes.c    |  7 +++++
 examples/fips_validation/main.c               | 27 ++++++++++++++++---
 4 files changed, 38 insertions(+), 4 deletions(-)
examples/fips_validation/fips_validation.c +1 -0
index 8d43b267e..07ffa62e9 100644
@@ -257,6 +257,7 @@ fips_test_init(const char *req_file_path, const char *rsp_file_path,
 
 	fips_test_clear();
 
+	strcpy(info.file_name, req_file_path);
 	info.algo = FIPS_TEST_ALGO_MAX;
 	if (parse_file_type(req_file_path) < 0) {
 		RTE_LOG(ERR, USER1, "File %s type not supported\n",
examples/fips_validation/fips_validation.h +7 -0
index b604db9ec..d487fb005 100644
@@ -105,6 +105,11 @@ enum fips_tdes_test_types {
 	TDES_MMT /* Multi block Message Test */
 };
 
+enum fips_tdes_test_mode {
+	TDES_MODE_CBC = 0,
+	TDES_MODE_ECB
+};
+
 enum fips_ccm_test_types {
 	CCM_VADT	= 1, /* Variable Associated Data Test */
 	CCM_VPT,		 /* Variable Payload Test */
@@ -130,6 +135,7 @@ struct hmac_interim_data {
 
 struct tdes_interim_data {
 	enum fips_tdes_test_types test_type;
+	enum fips_tdes_test_mode test_mode;
 	uint32_t nb_keys;
 };
 
@@ -156,6 +162,7 @@ struct fips_test_interim_info {
 	char *vec[MAX_LINE_PER_VECTOR];
 	uint32_t nb_vec_lines;
 	char device_name[MAX_STRING_SIZE];
+	char file_name[MAX_STRING_SIZE];
 
 	union {
 		struct aesavs_interim_data aes_data;
examples/fips_validation/fips_validation_tdes.c +7 -0
index 2b262c9a0..5b6737643 100644
@@ -12,6 +12,7 @@
 
 #define NEW_LINE_STR	"#"
 #define TEST_TYPE_KEY	" for CBC"
+#define TEST_TYPE_ECB_KEY	" for ECB"
 #define TEST_CBCI_KEY	" for CBCI"
 
 #define ENC_STR		"[ENCRYPT]"
@@ -252,6 +253,12 @@ parse_test_tdes_init(void)
 			if (strstr(line, test_types[j].desc)) {
 				info.interim_info.tdes_data.test_type =
 						test_types[j].type;
+				if (strstr(line, TEST_TYPE_ECB_KEY))
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_ECB;
+				else
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_CBC;
 				break;
 			}
 	}
examples/fips_validation/main.c +23 -4
index 813534068..7a379bc99 100644
@@ -689,16 +689,24 @@ prepare_tdes_xform(struct rte_crypto_sym_xform *xform)
 
 	xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
-	cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (info.interim_info.tdes_data.test_mode == TDES_MODE_CBC)
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	else
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_ECB;
 	cipher_xform->op = (info.op == FIPS_TEST_ENC_AUTH_GEN) ?
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT :
 			RTE_CRYPTO_CIPHER_OP_DECRYPT;
 	cipher_xform->key.data = vec.cipher_auth.key.val;
 	cipher_xform->key.length = vec.cipher_auth.key.len;
-	cipher_xform->iv.length = vec.iv.len;
-	cipher_xform->iv.offset = IV_OFF;
 
-	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (cipher_xform->algo == RTE_CRYPTO_CIPHER_3DES_CBC) {
+		cipher_xform->iv.length = vec.iv.len;
+		cipher_xform->iv.offset = IV_OFF;
+	} else {
+		cipher_xform->iv.length = 0;
+		cipher_xform->iv.offset = 0;
+	}
+	cap_idx.algo.cipher = cipher_xform->algo;
 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
 	cap = rte_cryptodev_sym_capability_get(env.dev_id, &cap_idx);
@@ -1387,6 +1395,17 @@ init_test_ops(void)
 			test_ops.test = fips_generic_test;
 		break;
 	default:
+		if (strstr(info.file_name, "TECB") ||
+				strstr(info.file_name, "TCBC")) {
+			info.algo = FIPS_TEST_ALGO_TDES;
+			test_ops.prepare_op = prepare_cipher_op;
+			test_ops.prepare_xform	= prepare_tdes_xform;
+			if (info.interim_info.tdes_data.test_type == TDES_MCT)
+				test_ops.test = fips_mct_tdes_test;
+			else
+				test_ops.test = fips_generic_test;
+			break;
+		}
 		return -1;
 	}
 
Signature · 1 line
2.23.0
#23 lore raw

PATCH v3 2/3 examples/fips_validation: add AES ECB support

In reply to [email protected]

From: Michael Shamis <[email protected]>

---
 .../fips_validation/fips_validation_aes.c     |  1 +
 examples/fips_validation/main.c               | 96 +++++++++++++++++--
 2 files changed, 91 insertions(+), 6 deletions(-)
examples/fips_validation/fips_validation_aes.c +1 -0
index 8cbc158eb..010a82627 100644
@@ -44,6 +44,7 @@ struct aes_test_algo {
 	enum rte_crypto_cipher_algorithm algo;
 } const algo_con[] = {
 		{"CBC", RTE_CRYPTO_CIPHER_AES_CBC},
+		{"ECB", RTE_CRYPTO_CIPHER_AES_ECB},
 };
 
 static int
examples/fips_validation/main.c +90 -6

125 lines not on this page · raw message

Signature · 1 line
2.23.0
Reviewed-by on v3 2/3
#24 lore raw

Re: [dpdk-dev] [PATCH v3 2/3] examples/fips_validation: add AES ECB support

Subject: [PATCH v3 2/3] examples/fips_validation: add AES ECB support

From: Michael Shamis <[email protected]>

---
 .../fips_validation/fips_validation_aes.c     |  1 +
 examples/fips_validation/main.c               | 96 +++++++++++++++++--
 2 files changed, 91 insertions(+), 6 deletions(-)
#25 lore raw

PATCH v3 3/3 examples/fips_validation: separate ECB and CBC

In reply to [email protected]

From: Michael Shamis <[email protected]>

Separate initialization of IV, PT and CT according to TDES ECB and CBC crypto modes

---
 examples/fips_validation/main.c | 66 +++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 16 deletions(-)
examples/fips_validation/main.c +50 -16
index c83763b13..f8694ef96 100644
@@ -1053,6 +1053,7 @@ fips_mct_tdes_test(void)
 	uint8_t prev_in[TDES_BLOCK_SIZE] = {0};
 	uint32_t i, j, k;
 	int ret;
+	int test_mode = info.interim_info.tdes_data.test_mode;
 
 	for (i = 0; i < TDES_EXTERN_ITER; i++) {
 		if (i != 0)
@@ -1079,25 +1080,50 @@ fips_mct_tdes_test(void)
 				memcpy(prev_out, val.val, TDES_BLOCK_SIZE);
 
 				if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-					memcpy(vec.pt.val, vec.iv.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.iv.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.pt.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.pt.val, vec.iv.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.iv.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
+
 				} else {
-					memcpy(vec.iv.val, vec.ct.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.ct.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.iv.val, vec.ct.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
 				}
 				continue;
 			}
 
 			if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.pt.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, val.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.pt.val, prev_out,
+						   TDES_BLOCK_SIZE);
+				}
 			} else {
-				memcpy(vec.iv.val, vec.ct.val, TDES_BLOCK_SIZE);
-				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, vec.ct.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				}
 			}
 
 			if (j == TDES_INTERN_ITER - 1)
@@ -1156,11 +1182,19 @@ fips_mct_tdes_test(void)
 					val_key.val[k] : (val_key.val[k] ^ 0x1);
 
 		if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-			memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-			memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.pt.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
+				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			}
 		} else {
-			memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
-			memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			}
 		}
 	}
 
Signature · 1 line
2.23.0
#26 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] support ECB for AES and TDES

In reply to [email protected]

Please specify change log

Quoted 24 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, October 1, 2019 4:03 PM
To: Akhil Goyal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 0/3] support ECB for AES and TDES

From: Michael Shamis <[email protected]>

Michael Shamis (3):
examples/fips_validation: add TDES ECB support
examples/fips_validation: add AES ECB support
examples/fips_validation: separate ECB and CBC

 examples/fips_validation/fips_validation.c    |   1 +
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 189 +++++++++++++++---
 5 files changed, 179 insertions(+), 26 deletions(-)

--
2.23.0

#27 lore raw

v3 cover support ECB for AES and TDES

In reply to [email protected]

From: Michael Shamis <[email protected]>

v3:
Changed patch names to comply DPDK contributing
requirements
v2:
fips_validation-separation-between-HMAC-SHA.patch
has been moved to fix patch

Michael Shamis (3):
examples/fips_validation: add TDES ECB support
examples/fips_validation: add AES ECB support
examples/fips_validation: separate ECB and CBC

 examples/fips_validation/fips_validation.c    |   1 +
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 189 +++++++++++++++---
 5 files changed, 179 insertions(+), 26 deletions(-)
Signature · 1 line
2.23.0
#28 lore raw

PATCH v3 1/3 examples/fips_validation: add TDES ECB support

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/fips_validation.c    |  1 +
 examples/fips_validation/fips_validation.h    |  7 +++++
 .../fips_validation/fips_validation_tdes.c    |  7 +++++
 examples/fips_validation/main.c               | 27 ++++++++++++++++---
 4 files changed, 38 insertions(+), 4 deletions(-)
examples/fips_validation/fips_validation.c +1 -0
index 8d43b267e..07ffa62e9 100644
@@ -257,6 +257,7 @@ fips_test_init(const char *req_file_path, const char *rsp_file_path,
 
 	fips_test_clear();
 
+	strcpy(info.file_name, req_file_path);
 	info.algo = FIPS_TEST_ALGO_MAX;
 	if (parse_file_type(req_file_path) < 0) {
 		RTE_LOG(ERR, USER1, "File %s type not supported\n",
examples/fips_validation/fips_validation.h +7 -0
index b604db9ec..d487fb005 100644
@@ -105,6 +105,11 @@ enum fips_tdes_test_types {
 	TDES_MMT /* Multi block Message Test */
 };
 
+enum fips_tdes_test_mode {
+	TDES_MODE_CBC = 0,
+	TDES_MODE_ECB
+};
+
 enum fips_ccm_test_types {
 	CCM_VADT	= 1, /* Variable Associated Data Test */
 	CCM_VPT,		 /* Variable Payload Test */
@@ -130,6 +135,7 @@ struct hmac_interim_data {
 
 struct tdes_interim_data {
 	enum fips_tdes_test_types test_type;
+	enum fips_tdes_test_mode test_mode;
 	uint32_t nb_keys;
 };
 
@@ -156,6 +162,7 @@ struct fips_test_interim_info {
 	char *vec[MAX_LINE_PER_VECTOR];
 	uint32_t nb_vec_lines;
 	char device_name[MAX_STRING_SIZE];
+	char file_name[MAX_STRING_SIZE];
 
 	union {
 		struct aesavs_interim_data aes_data;
examples/fips_validation/fips_validation_tdes.c +7 -0
index 2b262c9a0..5b6737643 100644
@@ -12,6 +12,7 @@
 
 #define NEW_LINE_STR	"#"
 #define TEST_TYPE_KEY	" for CBC"
+#define TEST_TYPE_ECB_KEY	" for ECB"
 #define TEST_CBCI_KEY	" for CBCI"
 
 #define ENC_STR		"[ENCRYPT]"
@@ -252,6 +253,12 @@ parse_test_tdes_init(void)
 			if (strstr(line, test_types[j].desc)) {
 				info.interim_info.tdes_data.test_type =
 						test_types[j].type;
+				if (strstr(line, TEST_TYPE_ECB_KEY))
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_ECB;
+				else
+					info.interim_info.tdes_data.test_mode =
+						TDES_MODE_CBC;
 				break;
 			}
 	}
examples/fips_validation/main.c +23 -4
index 813534068..7a379bc99 100644
@@ -689,16 +689,24 @@ prepare_tdes_xform(struct rte_crypto_sym_xform *xform)
 
 	xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
-	cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (info.interim_info.tdes_data.test_mode == TDES_MODE_CBC)
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;
+	else
+		cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_ECB;
 	cipher_xform->op = (info.op == FIPS_TEST_ENC_AUTH_GEN) ?
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT :
 			RTE_CRYPTO_CIPHER_OP_DECRYPT;
 	cipher_xform->key.data = vec.cipher_auth.key.val;
 	cipher_xform->key.length = vec.cipher_auth.key.len;
-	cipher_xform->iv.length = vec.iv.len;
-	cipher_xform->iv.offset = IV_OFF;
 
-	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_3DES_CBC;
+	if (cipher_xform->algo == RTE_CRYPTO_CIPHER_3DES_CBC) {
+		cipher_xform->iv.length = vec.iv.len;
+		cipher_xform->iv.offset = IV_OFF;
+	} else {
+		cipher_xform->iv.length = 0;
+		cipher_xform->iv.offset = 0;
+	}
+	cap_idx.algo.cipher = cipher_xform->algo;
 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 
 	cap = rte_cryptodev_sym_capability_get(env.dev_id, &cap_idx);
@@ -1387,6 +1395,17 @@ init_test_ops(void)
 			test_ops.test = fips_generic_test;
 		break;
 	default:
+		if (strstr(info.file_name, "TECB") ||
+				strstr(info.file_name, "TCBC")) {
+			info.algo = FIPS_TEST_ALGO_TDES;
+			test_ops.prepare_op = prepare_cipher_op;
+			test_ops.prepare_xform	= prepare_tdes_xform;
+			if (info.interim_info.tdes_data.test_type == TDES_MCT)
+				test_ops.test = fips_mct_tdes_test;
+			else
+				test_ops.test = fips_generic_test;
+			break;
+		}
 		return -1;
 	}
 
Signature · 1 line
2.23.0
Reviewed-by on v3 1/3
#29 lore raw

Re: [dpdk-dev] [PATCH v3 1/3] examples/fips_validation: add TDES ECB support

Subject: [PATCH v3 1/3] examples/fips_validation: add TDES ECB support

From: Michael Shamis <[email protected]>

---
 examples/fips_validation/fips_validation.c    |  1 +
 examples/fips_validation/fips_validation.h    |  7 +++++
 .../fips_validation/fips_validation_tdes.c    |  7 +++++
 examples/fips_validation/main.c               | 27 ++++++++++++++++---
 4 files changed, 38 insertions(+), 4 deletions(-)
#30 lore raw

PATCH v3 2/3 examples/fips_validation: add AES ECB support

In reply to [email protected]

From: Michael Shamis <[email protected]>

---
 .../fips_validation/fips_validation_aes.c     |  1 +
 examples/fips_validation/main.c               | 96 +++++++++++++++++--
 2 files changed, 91 insertions(+), 6 deletions(-)
examples/fips_validation/fips_validation_aes.c +1 -0
index 8cbc158eb..010a82627 100644
@@ -44,6 +44,7 @@ struct aes_test_algo {
 	enum rte_crypto_cipher_algorithm algo;
 } const algo_con[] = {
 		{"CBC", RTE_CRYPTO_CIPHER_AES_CBC},
+		{"ECB", RTE_CRYPTO_CIPHER_AES_ECB},
 };
 
 static int
examples/fips_validation/main.c +90 -6

125 lines not on this page · raw message

Signature · 1 line
2.23.0
#31 lore raw

PATCH v3 3/3 examples/fips_validation: separate ECB and CBC

In reply to [email protected]

From: Michael Shamis <[email protected]>

Separate initialization of IV, PT and CT according to TDES ECB and CBC crypto modes

---
 examples/fips_validation/main.c | 66 +++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 16 deletions(-)
examples/fips_validation/main.c +50 -16
index c83763b13..f8694ef96 100644
@@ -1053,6 +1053,7 @@ fips_mct_tdes_test(void)
 	uint8_t prev_in[TDES_BLOCK_SIZE] = {0};
 	uint32_t i, j, k;
 	int ret;
+	int test_mode = info.interim_info.tdes_data.test_mode;
 
 	for (i = 0; i < TDES_EXTERN_ITER; i++) {
 		if (i != 0)
@@ -1079,25 +1080,50 @@ fips_mct_tdes_test(void)
 				memcpy(prev_out, val.val, TDES_BLOCK_SIZE);
 
 				if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-					memcpy(vec.pt.val, vec.iv.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.iv.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.pt.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.pt.val, vec.iv.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.iv.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
+
 				} else {
-					memcpy(vec.iv.val, vec.ct.val,
-							TDES_BLOCK_SIZE);
-					memcpy(vec.ct.val, val.val,
-							TDES_BLOCK_SIZE);
+					if (test_mode == TDES_MODE_ECB) {
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					} else {
+						memcpy(vec.iv.val, vec.ct.val,
+							   TDES_BLOCK_SIZE);
+						memcpy(vec.ct.val, val.val,
+							   TDES_BLOCK_SIZE);
+					}
 				}
 				continue;
 			}
 
 			if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.pt.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, val.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.pt.val, prev_out,
+						   TDES_BLOCK_SIZE);
+				}
 			} else {
-				memcpy(vec.iv.val, vec.ct.val, TDES_BLOCK_SIZE);
-				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+				if (test_mode == TDES_MODE_ECB) {
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				} else {
+					memcpy(vec.iv.val, vec.ct.val,
+						   TDES_BLOCK_SIZE);
+					memcpy(vec.ct.val, val.val,
+						   TDES_BLOCK_SIZE);
+				}
 			}
 
 			if (j == TDES_INTERN_ITER - 1)
@@ -1156,11 +1182,19 @@ fips_mct_tdes_test(void)
 					val_key.val[k] : (val_key.val[k] ^ 0x1);
 
 		if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
-			memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
-			memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.pt.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
+				memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+			}
 		} else {
-			memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
-			memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			if (test_mode == TDES_MODE_ECB) {
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			} else {
+				memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
+				memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+			}
 		}
 	}
 
Signature · 1 line
2.23.0
Reviewed-by on v3 3/3
#32 lore raw

Re: [dpdk-dev] [PATCH v3 3/3] examples/fips_validation: separate ECB and CBC

Subject: [PATCH v3 3/3] examples/fips_validation: separate ECB and CBC

From: Michael Shamis <[email protected]>

Separate initialization of IV, PT and CT according to TDES ECB and CBC crypto modes

---
 examples/fips_validation/main.c | 66 +++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 16 deletions(-)
#33 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] support ECB for AES and TDES

In reply to [email protected]

Hi Marko,

Could you please review this series.

Regards,
Akhil

Quoted 31 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, October 1, 2019 4:53 PM
To: Akhil Goyal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 0/3] support ECB for AES and TDES

From: Michael Shamis <[email protected]>

v3:
Changed patch names to comply DPDK contributing
requirements
v2:
fips_validation-separation-between-HMAC-SHA.patch
has been moved to fix patch

Michael Shamis (3):
examples/fips_validation: add TDES ECB support
examples/fips_validation: add AES ECB support
examples/fips_validation: separate ECB and CBC

 examples/fips_validation/fips_validation.c    |   1 +
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 189 +++++++++++++++---
 5 files changed, 179 insertions(+), 26 deletions(-)

--
2.23.0

#34 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] support ECB for AES and TDES

Hi Marko,

A kind reminder.
We are approaching RC1 date. Could you please review this series?

Regards,
Akhil

Quoted 45 lines

-----Original Message-----
From: Akhil Goyal
Sent: Friday, October 4, 2019 4:04 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v3 0/3] support ECB for AES and TDES

Hi Marko,

Could you please review this series.

Regards,
Akhil

Quoted 31 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, October 1, 2019 4:53 PM
To: Akhil Goyal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 0/3] support ECB for AES and TDES

From: Michael Shamis <[email protected]>

v3:
Changed patch names to comply DPDK contributing
requirements
v2:
fips_validation-separation-between-HMAC-SHA.patch
has been moved to fix patch

Michael Shamis (3):
examples/fips_validation: add TDES ECB support
examples/fips_validation: add AES ECB support
examples/fips_validation: separate ECB and CBC

 examples/fips_validation/fips_validation.c    |   1 +
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 189 +++++++++++++++---
 5 files changed, 179 insertions(+), 26 deletions(-)

--
2.23.0

Applied
#35 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] support ECB for AES and TDES

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, October 1, 2019 4:53 PM
To: Akhil Goyal <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v3 0/3] support ECB for AES and TDES

From: Michael Shamis <[email protected]>

v3:
Changed patch names to comply DPDK contributing
requirements
v2:
fips_validation-separation-between-HMAC-SHA.patch
has been moved to fix patch

Michael Shamis (3):
examples/fips_validation: add TDES ECB support
examples/fips_validation: add AES ECB support
examples/fips_validation: separate ECB and CBC

 examples/fips_validation/fips_validation.c    |   1 +
 examples/fips_validation/fips_validation.h    |   7 +
 .../fips_validation/fips_validation_aes.c     |   1 +
 .../fips_validation/fips_validation_tdes.c    |   7 +
 examples/fips_validation/main.c               | 189 +++++++++++++++---
 5 files changed, 179 insertions(+), 26 deletions(-)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

--
2.23.0

Applied to dpdk-next-crypto

Thanks.