DPDK patches and discussions
 help / color / mirror / Atom feed
From: <michaelsh@marvell.com>
To: <akhil.goyal@nxp.com>
Cc: <dev@dpdk.org>, <marko.kovacevic@intel.com>, <lironh@marvell.com>,
	<michaelsh@marvell.com>
Subject: [dpdk-dev] [PATCH v3 1/3] examples/fips_validation: add TDES ECB support
Date: Tue, 1 Oct 2019 14:22:53 +0300	[thread overview]
Message-ID: <20191001112255.30081-2-michaelsh@marvell.com> (raw)
In-Reply-To: <20191001112255.30081-1-michaelsh@marvell.com>

From: Michael Shamis <michaelsh@marvell.com>

Signed-off-by: Michael Shamis <michaelsh@marvell.com>
---
 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(-)

diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 8d43b267e..07ffa62e9 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -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",
diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h
index b604db9ec..d487fb005 100644
--- a/examples/fips_validation/fips_validation.h
+++ b/examples/fips_validation/fips_validation.h
@@ -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;
diff --git a/examples/fips_validation/fips_validation_tdes.c b/examples/fips_validation/fips_validation_tdes.c
index 2b262c9a0..5b6737643 100644
--- a/examples/fips_validation/fips_validation_tdes.c
+++ b/examples/fips_validation/fips_validation_tdes.c
@@ -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;
 			}
 	}
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 813534068..7a379bc99 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -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;
 	}
 
-- 
2.23.0


  reply	other threads:[~2019-10-01 11:04 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26  9:41 [dpdk-dev] [PATCH 00/12] FIPS improvements michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 01/12] examples/fips: added support for SHA algorithm in FIPS tests michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 02/12] examples/fips: added support for TDES ECB mode " michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 03/12] examples/fips: added support AES " michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 04/12] examples/fips: fix bad return code in fips_test_parse_header() michaelsh
2019-09-04  9:51   ` Akhil Goyal
2019-08-26  9:41 ` [dpdk-dev] [PATCH 05/12] examples/fips: AES-GCM vectors will use aead structure michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 06/12] examples/fips: set initial IV in AES-GCM if configured only salt value michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 07/12] examples/fips: keep digest after crypto text michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 08/12] examples/fips: AES-GCM decryption vectors fix michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 09/12] examples/fips: fix KEY and PT output prints for TDES mode michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 10/12] examples/fips: supported IV, PT and CT init for TDES ECB mode michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 11/12] examples/fips: algorithm definition by folder if it's not in file michaelsh
2019-08-26  9:41 ` [dpdk-dev] [PATCH 12/12] examples/fips: erroneous overwrite of PLAINTEXT after DECRYPT michaelsh
2019-09-04 10:14 ` [dpdk-dev] [PATCH 00/12] FIPS improvements Akhil Goyal
2019-09-15 10:47   ` Michael Shamis
2019-09-16  8:57     ` Akhil Goyal
2019-09-19 12:15 ` [dpdk-dev] [PATCH v2 0/3] Support ECB for AES and TDES michaelsh
2019-09-19 12:15   ` [dpdk-dev] [PATCH v2 1/3] examples/fips_validation: added support for TDES ECB michaelsh
2019-09-19 12:15   ` [dpdk-dev] [PATCH v2 2/3] examples/fips_validation: added support AES ECB michaelsh
2019-09-19 12:15   ` [dpdk-dev] [PATCH v2 3/3] examples/fips_validation: separated init for TDES ECB and CBC michaelsh
2019-10-01 10:32 ` [dpdk-dev] [PATCH v3 0/3] support ECB for AES and TDES michaelsh
2019-10-01 10:15   ` Akhil Goyal
2019-10-01 10:32   ` [dpdk-dev] [PATCH v3 1/3] examples/fips_validation: add TDES ECB support michaelsh
2019-10-01 10:32   ` [dpdk-dev] [PATCH v3 2/3] examples/fips_validation: add AES " michaelsh
2019-10-15 13:53     ` Kovacevic, Marko
2019-10-01 10:32   ` [dpdk-dev] [PATCH v3 3/3] examples/fips_validation: separate ECB and CBC michaelsh
2019-10-01 11:22 ` [dpdk-dev] [PATCH v3 0/3] support ECB for AES and TDES michaelsh
2019-10-01 11:22   ` michaelsh [this message]
2019-10-15 13:50     ` [dpdk-dev] [PATCH v3 1/3] examples/fips_validation: add TDES ECB support Kovacevic, Marko
2019-10-01 11:22   ` [dpdk-dev] [PATCH v3 2/3] examples/fips_validation: add AES " michaelsh
2019-10-01 11:22   ` [dpdk-dev] [PATCH v3 3/3] examples/fips_validation: separate ECB and CBC michaelsh
2019-10-15 13:54     ` Kovacevic, Marko
2019-10-04 10:33   ` [dpdk-dev] [PATCH v3 0/3] support ECB for AES and TDES Akhil Goyal
2019-10-15 13:40     ` Akhil Goyal
2019-10-15 14:03       ` Akhil Goyal

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20191001112255.30081-2-michaelsh@marvell.com \
    --to=michaelsh@marvell.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=lironh@marvell.com \
    --cc=marko.kovacevic@intel.com \
    /path/to/YOUR_REPLY

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

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