DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT
@ 2019-07-11 13:22 Ayuj Verma
  2019-07-11 13:22 ` [dpdk-dev] [PATCH v1 1/2] test/crypto: move rsa enqueue/dequeue into separate functions Ayuj Verma
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ayuj Verma @ 2019-07-11 13:22 UTC (permalink / raw)
  To: akhil.goyal
  Cc: arkadiuszx.kusztal, fiona.trahe, shallyv, ssahu, kkotamarthy,
	anoobj, dev, Ayuj Verma

This patch series add new RSA CRT key based test cases,
improve code organization and also rebase it to latest changes.
It covers following changes:

* Add crt key based rsa sign/verify, enc/decrypt test cases
* Move common code of enqueue/dequeue into separate function
* Configure device with ff_disable set

Ayuj Verma (2):
  test/crypto: move rsa enqueue/dequeue into separate functions
  test/crypto: add tests for RSA key type CRT

 app/test/test_cryptodev_asym.c             | 460 +++++++++++++++++------------
 app/test/test_cryptodev_rsa_test_vectors.h |  93 ++++++
 2 files changed, 363 insertions(+), 190 deletions(-)

-- 
1.8.3.1


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

* [dpdk-dev] [PATCH v1 1/2] test/crypto: move rsa enqueue/dequeue into separate functions
  2019-07-11 13:22 [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT Ayuj Verma
@ 2019-07-11 13:22 ` Ayuj Verma
  2019-07-11 13:22 ` [dpdk-dev] [PATCH v1 2/2] test/crypto: add tests for RSA key type CRT Ayuj Verma
  2019-07-12 13:15 ` [dpdk-dev] [PATCH v1 0/2] " Kusztal, ArkadiuszX
  2 siblings, 0 replies; 7+ messages in thread
From: Ayuj Verma @ 2019-07-11 13:22 UTC (permalink / raw)
  To: akhil.goyal
  Cc: arkadiuszx.kusztal, fiona.trahe, shallyv, ssahu, kkotamarthy,
	anoobj, dev, Ayuj Verma

Move common code of enqueue/dequeue into separate functions.

Signed-off-by: Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>
Signed-off-by: Ayuj Verma <ayverma@marvell.com>
Signed-off-by: Shally Verma <shallyv@marvell.com>
---
 app/test/test_cryptodev_asym.c | 413 ++++++++++++++++++++---------------------
 1 file changed, 199 insertions(+), 214 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index fc92d3d..e3f78a3 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -67,6 +67,180 @@ struct test_cases_array {
 static struct crypto_testsuite_params testsuite_params = { NULL };
 
 static int
+queue_ops_rsa_sign_verify(struct rte_cryptodev_asym_session *sess)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_op *op, *result_op;
+	struct rte_crypto_asym_op *asym_op;
+	uint8_t output_buf[TEST_DATA_SIZE];
+	int status = TEST_SUCCESS;
+
+	/* Set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
+			"operation struct\n");
+		return TEST_FAILED;
+	}
+
+	asym_op = op->asym;
+
+	/* Compute sign on the test vector */
+	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
+
+	asym_op->rsa.message.data = rsaplaintext.data;
+	asym_op->rsa.message.length = rsaplaintext.len;
+	asym_op->rsa.sign.data = output_buf;
+	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT1;
+
+	debug_hexdump(stdout, "message", asym_op->rsa.message.data,
+		      asym_op->rsa.message.length);
+
+	/* Attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		RTE_LOG(ERR, USER1, "Error sending packet for sign\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		RTE_LOG(ERR, USER1, "Failed to process sign op\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
+		      asym_op->rsa.sign.length);
+	asym_op = result_op->asym;
+
+	/* Verify sign */
+	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
+	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT1;
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		RTE_LOG(ERR, USER1, "Error sending packet for verify\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		RTE_LOG(ERR, USER1, "Failed to process verify op\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	status = TEST_SUCCESS;
+	if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+		RTE_LOG(ERR, USER1, "Failed to process sign-verify op\n");
+		status = TEST_FAILED;
+	}
+
+error_exit:
+
+	rte_crypto_op_free(op);
+
+	return status;
+}
+
+static int
+queue_ops_rsa_enc_dec(struct rte_cryptodev_asym_session *sess)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_op *op, *result_op;
+	struct rte_crypto_asym_op *asym_op;
+	int ret, status = TEST_SUCCESS;
+
+	/* Set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
+			"operation struct\n");
+		return TEST_FAILED;
+	}
+
+	asym_op = op->asym;
+
+	/* Compute encryption on the test vector */
+	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
+
+	asym_op->rsa.message.data = rsaplaintext.data;
+	asym_op->rsa.message.length = rsaplaintext.len;
+	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT2;
+
+	debug_hexdump(stdout, "message", asym_op->rsa.message.data,
+		      asym_op->rsa.message.length);
+
+	/* Attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		RTE_LOG(ERR, USER1, "Failed to process encryption op\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	debug_hexdump(stdout, "encrypted message", asym_op->rsa.message.data,
+		      asym_op->rsa.message.length);
+
+	/* Use the resulted output as decryption Input vector*/
+	asym_op = result_op->asym;
+	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
+	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT2;
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		RTE_LOG(ERR, USER1, "Error sending packet for decryption\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		RTE_LOG(ERR, USER1, "Failed to process decryption op\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	status = TEST_SUCCESS;
+	ret = rsa_verify(&rsaplaintext, result_op);
+	if (ret)
+		status = TEST_FAILED;
+
+error_exit:
+
+	rte_crypto_op_free(op);
+
+	return status;
+}
+static int
 test_cryptodev_asym_ver(union test_case_structure *data_tc,
 						struct rte_crypto_op *result_op)
 {
@@ -339,143 +513,45 @@ struct test_cases_array {
 test_rsa_sign_verify(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct rte_mempool *op_mpool = ts_params->op_mpool;
 	struct rte_mempool *sess_mpool = ts_params->session_mpool;
 	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_cryptodev_asym_session *sess;
 	struct rte_cryptodev_info dev_info;
-	struct rte_crypto_asym_op *asym_op = NULL;
-	struct rte_crypto_op *op = NULL, *result_op = NULL;
-	struct rte_cryptodev_asym_session *sess = NULL;
 	int status = TEST_SUCCESS;
-	uint8_t output_buf[TEST_DATA_SIZE] = {0};
-	uint8_t input_buf[TEST_DATA_SIZE] = {0};
 
-	/* test case supports op with exponent key only,
+	/* Test case supports op with exponent key only,
 	 * Check in PMD feature flag for RSA exponent key type support.
 	 */
 	rte_cryptodev_info_get(dev_id, &dev_info);
 	if (!(dev_info.feature_flags &
 				RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
-		RTE_LOG(INFO, USER1,
-				"Device doesn't support sign op with "
-				"exponent key type. Test Skipped\n");
+		RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
+			"exponent key type. Test Skipped\n");
 		return -ENOTSUP;
 	}
 
 	sess = rte_cryptodev_asym_session_create(sess_mpool);
 
 	if (!sess) {
-		RTE_LOG(ERR, USER1, "line %u "
-				"FAILED: %s", __LINE__,
-				"Session creation failed");
-		status = TEST_FAILED;
-		goto error_exit;
+		RTE_LOG(ERR, USER1, "Session creation failed for "
+			"sign_verify\n");
+		return TEST_FAILED;
 	}
 
 	if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
 				sess_mpool) < 0) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "unabled to config sym session");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-
-	/* set up crypto op data structure */
-	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
-	if (!op) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__,
-				"Failed to allocate asymmetric crypto "
-				"operation struct");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-
-	asym_op = op->asym;
-	/* Compute sign on the test vector */
-	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
-
-	memcpy(input_buf, &rsaplaintext.data,
-			rsaplaintext.len);
-	asym_op->rsa.message.data = input_buf;
-	asym_op->rsa.message.length = rsaplaintext.len;
-	asym_op->rsa.sign.data = output_buf;
-	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT1;
-
-	debug_hexdump(stdout, "message", asym_op->rsa.message.data,
-			asym_op->rsa.message.length);
-
-	/* attach asymmetric crypto session to crypto operations */
-	rte_crypto_op_attach_asym_session(op, sess);
-
-	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
-
-	/* Process crypto operation */
-	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Error sending packet for operation");
+		RTE_LOG(ERR, USER1, "Unable to config asym session for "
+			"sign_verify\n");
 		status = TEST_FAILED;
 		goto error_exit;
 	}
 
-	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
-		rte_pause();
-
-	if (result_op == NULL) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Failed to process asym crypto op");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-	debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
-			asym_op->rsa.sign.length);
-	asym_op = result_op->asym;
-
-	/* Verify sign */
-	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
-	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT2;
-
-	/* Process crypto operation */
-	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Error sending packet for operation");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-
-	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
-		rte_pause();
-
-	if (result_op == NULL) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Failed to process asym crypto op");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-	status = TEST_SUCCESS;
-	if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Failed to process asym crypto op");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
+	status = queue_ops_rsa_sign_verify(sess);
 
 error_exit:
 
-	if (sess) {
-		rte_cryptodev_asym_session_clear(dev_id, sess);
-		rte_cryptodev_asym_session_free(sess);
-	}
-
-	if (op)
-		rte_crypto_op_free(op);
+	rte_cryptodev_asym_session_clear(dev_id, sess);
+	rte_cryptodev_asym_session_free(sess);
 
 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -486,137 +562,44 @@ struct test_cases_array {
 test_rsa_enc_dec(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct rte_mempool *op_mpool = ts_params->op_mpool;
 	struct rte_mempool *sess_mpool = ts_params->session_mpool;
 	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_cryptodev_asym_session *sess;
 	struct rte_cryptodev_info dev_info;
-	struct rte_crypto_asym_op *asym_op = NULL;
-	struct rte_crypto_op *op = NULL, *result_op = NULL;
-	struct rte_cryptodev_asym_session *sess = NULL;
 	int status = TEST_SUCCESS;
-	uint8_t input_buf[TEST_DATA_SIZE] = {0};
 
-	/* test case supports op with exponent key only,
+	/* Test case supports op with exponent key only,
 	 * Check in PMD feature flag for RSA exponent key type support.
 	 */
 	rte_cryptodev_info_get(dev_id, &dev_info);
 	if (!(dev_info.feature_flags &
 				RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
-		RTE_LOG(INFO, USER1,
-				"Device doesn't support sign op with "
-				"exponent key type. Test Skipped\n");
+		RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
+			"exponent key type. Test skipped\n");
 		return -ENOTSUP;
 	}
 
 	sess = rte_cryptodev_asym_session_create(sess_mpool);
 
 	if (!sess) {
-		RTE_LOG(ERR, USER1, "line %u "
-				"FAILED: %s", __LINE__,
-				"Session creation failed");
-		status = TEST_FAILED;
-		goto error_exit;
+		RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n");
+		return TEST_FAILED;
 	}
 
 	if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
 				sess_mpool) < 0) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "unabled to config sym session");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-
-	/* set up crypto op data structure */
-	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
-	if (!op) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__,
-				"Failed to allocate asymmetric crypto "
-				"operation struct");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-
-	asym_op = op->asym;
-	/*Compute encryption on the test vector */
-	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
-
-	memcpy(input_buf, rsaplaintext.data,
-			rsaplaintext.len);
-	asym_op->rsa.message.data = input_buf;
-	asym_op->rsa.message.length = rsaplaintext.len;
-	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT2;
-
-	debug_hexdump(stdout, "message", asym_op->rsa.message.data,
-			asym_op->rsa.message.length);
-
-	/* attach asymmetric crypto session to crypto operations */
-	rte_crypto_op_attach_asym_session(op, sess);
-
-	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
-
-	/* Process crypto operation */
-	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Error sending packet for operation");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-
-	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
-		rte_pause();
-
-	if (result_op == NULL) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Failed to process asym crypto op");
+		RTE_LOG(ERR, USER1, "Unable to config asym session for "
+			"enc_dec\n");
 		status = TEST_FAILED;
 		goto error_exit;
 	}
-	debug_hexdump(stdout, "encrypted message", asym_op->rsa.message.data,
-			asym_op->rsa.message.length);
-	/* Use the resulted output as decryption Input vector*/
-	asym_op = result_op->asym;
-	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
-	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT1;
 
-	/* Process crypto operation */
-	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Error sending packet for operation");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-
-	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
-		rte_pause();
-
-	if (result_op == NULL) {
-		RTE_LOG(ERR, USER1,
-				"line %u FAILED: %s",
-				__LINE__, "Failed to process asym crypto op");
-		status = TEST_FAILED;
-		goto error_exit;
-	}
-	status = TEST_SUCCESS;
-	int ret = 0;
-	ret = rsa_verify(&rsaplaintext, result_op);
-	if (ret)
-		status = TEST_FAILED;
+	status = queue_ops_rsa_enc_dec(sess);
 
 error_exit:
 
-	if (sess) {
-		rte_cryptodev_asym_session_clear(dev_id, sess);
-		rte_cryptodev_asym_session_free(sess);
-	}
-
-	if (op)
-		rte_crypto_op_free(op);
+	rte_cryptodev_asym_session_clear(dev_id, sess);
+	rte_cryptodev_asym_session_free(sess);
 
 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -698,6 +681,8 @@ struct test_cases_array {
 	/* configure device with num qp */
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
+	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY |
+			RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO;
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
 			&ts_params->conf),
 			"Failed to configure cryptodev %u with %u qps",
-- 
1.8.3.1


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

* [dpdk-dev] [PATCH v1 2/2] test/crypto: add tests for RSA key type CRT
  2019-07-11 13:22 [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT Ayuj Verma
  2019-07-11 13:22 ` [dpdk-dev] [PATCH v1 1/2] test/crypto: move rsa enqueue/dequeue into separate functions Ayuj Verma
@ 2019-07-11 13:22 ` Ayuj Verma
  2019-07-12 13:15 ` [dpdk-dev] [PATCH v1 0/2] " Kusztal, ArkadiuszX
  2 siblings, 0 replies; 7+ messages in thread
From: Ayuj Verma @ 2019-07-11 13:22 UTC (permalink / raw)
  To: akhil.goyal
  Cc: arkadiuszx.kusztal, fiona.trahe, shallyv, ssahu, kkotamarthy,
	anoobj, dev, Ayuj Verma

Added RSA sign/verify and enc/dec tests for RSA
key type CRT(quintuple) and associated test vectors.

Signed-off-by: Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>
Signed-off-by: Ayuj Verma <ayverma@marvell.com>
Signed-off-by: Shally Verma <shallyv@marvell.com>
---
 app/test/test_cryptodev_asym.c             | 97 ++++++++++++++++++++++++++++++
 app/test/test_cryptodev_rsa_test_vectors.h | 93 ++++++++++++++++++++++++++++
 2 files changed, 190 insertions(+)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index e3f78a3..4dee164 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -607,6 +607,101 @@ struct test_cases_array {
 }
 
 static int
+test_rsa_sign_verify_crt(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_cryptodev_asym_session *sess;
+	struct rte_cryptodev_info dev_info;
+	int status = TEST_SUCCESS;
+
+	/* Test case supports op with quintuple format key only,
+	 * Check im PMD feature flag for RSA quintuple key type support.
+	 */
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
+		RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
+			"quintuple key type. Test skipped\n");
+		return -ENOTSUP;
+	}
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+
+	if (!sess) {
+		RTE_LOG(ERR, USER1, "Session creation failed for "
+			"sign_verify_crt\n");
+		status = TEST_FAILED;
+		return status;
+	}
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
+				sess_mpool) < 0) {
+		RTE_LOG(ERR, USER1, "Unable to config asym session for "
+			"sign_verify_crt\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	status = queue_ops_rsa_sign_verify(sess);
+
+error_exit:
+
+	rte_cryptodev_asym_session_clear(dev_id, sess);
+	rte_cryptodev_asym_session_free(sess);
+
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	return status;
+}
+
+static int
+test_rsa_enc_dec_crt(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_cryptodev_asym_session *sess;
+	struct rte_cryptodev_info dev_info;
+	int status = TEST_SUCCESS;
+
+	/* Test case supports op with quintuple format key only,
+	 * Check in PMD feature flag for RSA quintuple key type support.
+	 */
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
+		RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
+			"quintuple key type. Test skipped\n");
+		return -ENOTSUP;
+	}
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+
+	if (!sess) {
+		RTE_LOG(ERR, USER1, "Session creation failed for "
+			"enc_dec_crt\n");
+		return TEST_FAILED;
+	}
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
+				sess_mpool) < 0) {
+		RTE_LOG(ERR, USER1, "Unable to config asym session for "
+			"enc_dec_crt\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	status = queue_ops_rsa_enc_dec(sess);
+
+error_exit:
+
+	rte_cryptodev_asym_session_clear(dev_id, sess);
+	rte_cryptodev_asym_session_free(sess);
+
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	return status;
+}
+
+static int
 testsuite_setup(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -1671,6 +1766,8 @@ static inline void print_asym_capa(
 		TEST_CASE_ST(ut_setup, ut_teardown, test_dh_keygenration),
 		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec),
 		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec_crt),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify_crt),
 		TEST_CASE_ST(ut_setup, ut_teardown, test_mod_inv),
 		TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp),
 		TEST_CASE_ST(ut_setup, ut_teardown, test_one_by_one),
diff --git a/app/test/test_cryptodev_rsa_test_vectors.h b/app/test/test_cryptodev_rsa_test_vectors.h
index 3f8c41a..0dc0375 100644
--- a/app/test/test_cryptodev_rsa_test_vectors.h
+++ b/app/test/test_cryptodev_rsa_test_vectors.h
@@ -64,6 +64,60 @@ struct rsa_test_data rsaplaintext = {
 
 uint8_t rsa_e[] = {0x01, 0x00, 0x01};
 
+uint8_t rsa_p[] = {
+	0xdc, 0xba, 0x00, 0x01, 0x57, 0x93, 0xe3, 0x05,
+	0xed, 0x61, 0x9a, 0xa3, 0xaf, 0x6a, 0xd3, 0x47,
+	0x8f, 0x2d, 0x1e, 0x7f, 0x4d, 0x60, 0xc8, 0x8d,
+	0x34, 0xb8, 0x17, 0x84, 0xbc, 0xd4, 0xe9, 0x79,
+	0x95, 0x75, 0x19, 0x37, 0xe0, 0xcc, 0xfe, 0x4c,
+	0x5d, 0x49, 0x53, 0x61, 0x29, 0xf1, 0xdc, 0x82,
+	0x03, 0x96, 0x7d, 0x95, 0x4f, 0xdd, 0x3c, 0x0a,
+	0x64, 0x8a, 0x43, 0x2f, 0x95, 0x4a, 0xed, 0xdd
+};
+
+uint8_t rsa_q[] = {
+	0xd0, 0x56, 0x7a, 0x0a, 0xd5, 0x95, 0xa4, 0x85,
+	0x53, 0x35, 0xa1, 0x48, 0x07, 0x6a, 0x7c, 0x08,
+	0xe0, 0xfd, 0x4b, 0x88, 0x77, 0xa6, 0x15, 0x23,
+	0x0f, 0xbf, 0x14, 0x46, 0x11, 0xee, 0x95, 0xc7,
+	0x5e, 0x77, 0x65, 0xa2, 0xb5, 0x50, 0xdf, 0x19,
+	0x07, 0xc7, 0x72, 0xdb, 0x29, 0xf6, 0x54, 0x86,
+	0xe1, 0xb3, 0x97, 0x0a, 0x28, 0x64, 0x3a, 0x38,
+	0xa6, 0x7d, 0x13, 0xc3, 0x79, 0xaa, 0x56, 0xd9
+};
+
+uint8_t rsa_dP[] = {
+	0xc5, 0x43, 0x0d, 0x82, 0x25, 0x8c, 0xab, 0x55,
+	0xbe, 0xc2, 0x7d, 0xfb, 0x4f, 0x68, 0x3f, 0x0e,
+	0x32, 0xec, 0xf5, 0xd6, 0x7b, 0x86, 0xc5, 0x75,
+	0x3c, 0xea, 0x51, 0x4a, 0x75, 0xa0, 0x2a, 0x50,
+	0x58, 0xbb, 0xe0, 0x1f, 0xca, 0x2e, 0x2a, 0x0e,
+	0x81, 0x48, 0x68, 0xd5, 0xeb, 0x30, 0x96, 0x0b,
+	0x33, 0xbd, 0xa8, 0xda, 0x6a, 0x17, 0xa3, 0xf2,
+	0xfd, 0xcb, 0x7b, 0x23, 0xe9, 0x5e, 0x9f, 0x99
+};
+uint8_t rsa_dQ[] = {
+	0xbe, 0xff, 0xf9, 0x05, 0x43, 0xc8, 0xdc, 0x3b,
+	0x0b, 0x0d, 0x28, 0xde, 0x73, 0x46, 0x11, 0x8e,
+	0xc6, 0x4e, 0x11, 0xd8, 0x7b, 0xf0, 0xfc, 0x81,
+	0xd7, 0x66, 0xd3, 0xbc, 0x65, 0xa6, 0x39, 0x14,
+	0xbd, 0xab, 0x72, 0xb7, 0x57, 0xc9, 0x5b, 0xaf,
+	0x83, 0xed, 0x3b, 0x84, 0x68, 0x15, 0x18, 0x6b,
+	0x4c, 0x32, 0xac, 0x6f, 0x38, 0x96, 0xa2, 0xb5,
+	0xdb, 0x14, 0xe2, 0x70, 0x9c, 0x73, 0x29, 0x09
+};
+
+uint8_t rsa_qInv[] = {
+	0x59, 0xbd, 0xb1, 0x37, 0xeb, 0x4e, 0xcf, 0x68,
+	0xe7, 0x85, 0x91, 0xbb, 0xc0, 0xdb, 0x8e, 0x41,
+	0x91, 0x4a, 0xc0, 0xb1, 0xc5, 0xe8, 0x91, 0xf6,
+	0xc7, 0x5a, 0x98, 0x1a, 0x8a, 0x0f, 0x45, 0xb2,
+	0x5b, 0xff, 0x7a, 0x2d, 0x98, 0x89, 0x55, 0xd9,
+	0xbf, 0x6e, 0xdd, 0x2d, 0xd4, 0xe8, 0x0a, 0xaa,
+	0xae, 0x2a, 0xc4, 0x16, 0xb5, 0xba, 0xe1, 0x69,
+	0x71, 0x94, 0xdd, 0xa0, 0xf5, 0x1e, 0x6d, 0xcc
+};
+
 /** rsa xform using exponent key */
 struct rte_crypto_asym_xform rsa_xform = {
 	.next = NULL,
@@ -85,4 +139,43 @@ struct rte_crypto_asym_xform rsa_xform = {
 	}
 };
 
+/** rsa xform using quintuple key */
+struct rte_crypto_asym_xform rsa_xform_crt = {
+	.next = NULL,
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
+	.rsa = {
+		.n = {
+			.data = rsa_n,
+			.length = sizeof(rsa_n)
+		},
+		.e = {
+			.data = rsa_e,
+			.length = sizeof(rsa_e)
+		},
+		.key_type = RTE_RSA_KET_TYPE_QT,
+		.qt = {
+			.p = {
+				.data = rsa_p,
+				.length = sizeof(rsa_p)
+			},
+			.q = {
+				.data = rsa_q,
+				.length = sizeof(rsa_q)
+			},
+			.dP = {
+				.data = rsa_dP,
+				.length = sizeof(rsa_dP)
+			},
+			.dQ = {
+				.data = rsa_dQ,
+				.length = sizeof(rsa_dQ)
+			},
+			.qInv = {
+				.data = rsa_qInv,
+				.length = sizeof(rsa_qInv)
+			},
+		}
+	}
+};
+
 #endif /* TEST_CRYPTODEV_RSA_TEST_VECTORS_H__ */
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT
  2019-07-11 13:22 [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT Ayuj Verma
  2019-07-11 13:22 ` [dpdk-dev] [PATCH v1 1/2] test/crypto: move rsa enqueue/dequeue into separate functions Ayuj Verma
  2019-07-11 13:22 ` [dpdk-dev] [PATCH v1 2/2] test/crypto: add tests for RSA key type CRT Ayuj Verma
@ 2019-07-12 13:15 ` Kusztal, ArkadiuszX
  2 siblings, 0 replies; 7+ messages in thread
From: Kusztal, ArkadiuszX @ 2019-07-12 13:15 UTC (permalink / raw)
  To: Ayuj Verma, akhil.goyal
  Cc: Trahe, Fiona, shallyv, ssahu, kkotamarthy, anoobj, dev, Zhang, Roy Fan

In future we could unify tests even more (i.e. passing padding type as a param, or even information if it is encryption or signature generation) like Fan once done with blockcipher.

> -----Original Message-----
> From: Ayuj Verma [mailto:ayverma@marvell.com]
> Sent: Thursday, July 11, 2019 3:23 PM
> To: akhil.goyal@nxp.com
> Cc: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>; shallyv@marvell.com; ssahu@marvell.com;
> kkotamarthy@marvell.com; anoobj@marvell.com; dev@dpdk.org; Ayuj
> Verma <ayverma@marvell.com>
> Subject: [PATCH v1 0/2] add tests for RSA key type CRT
> 
> This patch series add new RSA CRT key based test cases, improve code
> organization and also rebase it to latest changes.
> It covers following changes:
> 
> * Add crt key based rsa sign/verify, enc/decrypt test cases
> * Move common code of enqueue/dequeue into separate function
> * Configure device with ff_disable set
> 
> Ayuj Verma (2):
>   test/crypto: move rsa enqueue/dequeue into separate functions
>   test/crypto: add tests for RSA key type CRT
> 
>  app/test/test_cryptodev_asym.c             | 460 +++++++++++++++++------------
>  app/test/test_cryptodev_rsa_test_vectors.h |  93 ++++++
>  2 files changed, 363 insertions(+), 190 deletions(-)
> 
> --
> 1.8.3.1

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


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

* Re: [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT
  2019-07-16 12:04 Shally Verma
@ 2019-07-18 15:35 ` Akhil Goyal
  0 siblings, 0 replies; 7+ messages in thread
From: Akhil Goyal @ 2019-07-18 15:35 UTC (permalink / raw)
  To: Shally Verma, Kusztal, ArkadiuszX, Ayuj Verma
  Cc: Anoob Joseph, Trahe, Fiona, Sunila Sahu, dev,
	Kanaka Durga Kotamarthy, Zhang, Roy Fan





Sent from Workspace ONE Boxer
On 12-Jul-2019 6:45 PM, "Kusztal, ArkadiuszX" <arkadiuszx.kusztal@intel.com<mailto:arkadiuszx.kusztal@intel.com>> wrote:
>
> In future we could unify tests even more (i.e. passing padding type as a param, or even information if it is encryption or signature generation) like Fan once done with blockcipher.
>
> > -----Original Message-----
> > From: Ayuj Verma [mailto:ayverma@marvell.com]
> > Sent: Thursday, July 11, 2019 3:23 PM
> > To: akhil.goyal@nxp.com<mailto:akhil.goyal@nxp.com>
> > Cc: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com<mailto:arkadiuszx.kusztal@intel.com>>; Trahe, Fiona
> > <fiona.trahe@intel.com<mailto:fiona.trahe@intel.com>>; shallyv@marvell.com<mailto:shallyv@marvell.com>; ssahu@marvell.com<mailto:ssahu@marvell.com>;
> > kkotamarthy@marvell.com<mailto:kkotamarthy@marvell.com>; anoobj@marvell.com<mailto:anoobj@marvell.com>; dev@dpdk.org<mailto:dev@dpdk.org>; Ayuj
> > Verma <ayverma@marvell.com<mailto:ayverma@marvell.com>>
> > Subject: [PATCH v1 0/2] add tests for RSA key type CRT
> >
> > This patch series add new RSA CRT key based test cases, improve code
> > organization and also rebase it to latest changes.
> > It covers following changes:
> >
> > * Add crt key based rsa sign/verify, enc/decrypt test cases
> > * Move common code of enqueue/dequeue into separate function
> > * Configure device with ff_disable set
> >
> > Ayuj Verma (2):
> >   test/crypto: move rsa enqueue/dequeue into separate functions
> >   test/crypto: add tests for RSA key type CRT
> >
> >  app/test/test_cryptodev_asym.c             | 460 +++++++++++++++++------------
> >  app/test/test_cryptodev_rsa_test_vectors.h |  93 ++++++
> >  2 files changed, 363 insertions(+), 190 deletions(-)
> >
> > --
> > 1.8.3.1
>
> Series-acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com<mailto:arkadiuszx.kusztal@intel.com>>
>
Series-acked-by: Shally Verma <shallyv@marvell.com<mailto:shallyv@marvell.com>>

Applied to dpdk-next-crypto

Thanks.

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

* Re: [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT
@ 2019-07-16 12:04 Shally Verma
  2019-07-18 15:35 ` Akhil Goyal
  0 siblings, 1 reply; 7+ messages in thread
From: Shally Verma @ 2019-07-16 12:04 UTC (permalink / raw)
  To: Kusztal, ArkadiuszX, Ayuj Verma, akhil.goyal
  Cc: Anoob Joseph, Trahe, Fiona, Sunila Sahu, dev,
	Kanaka Durga Kotamarthy, Zhang, Roy Fan



Sent from Workspace ONE Boxer
On 12-Jul-2019 6:45 PM, "Kusztal, ArkadiuszX" <arkadiuszx.kusztal@intel.com> wrote:
>
> In future we could unify tests even more (i.e. passing padding type as a param, or even information if it is encryption or signature generation) like Fan once done with blockcipher.
>
> > -----Original Message-----
> > From: Ayuj Verma [mailto:ayverma@marvell.com]
> > Sent: Thursday, July 11, 2019 3:23 PM
> > To: akhil.goyal@nxp.com
> > Cc: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>; Trahe, Fiona
> > <fiona.trahe@intel.com>; shallyv@marvell.com; ssahu@marvell.com;
> > kkotamarthy@marvell.com; anoobj@marvell.com; dev@dpdk.org; Ayuj
> > Verma <ayverma@marvell.com>
> > Subject: [PATCH v1 0/2] add tests for RSA key type CRT
> >
> > This patch series add new RSA CRT key based test cases, improve code
> > organization and also rebase it to latest changes.
> > It covers following changes:
> >
> > * Add crt key based rsa sign/verify, enc/decrypt test cases
> > * Move common code of enqueue/dequeue into separate function
> > * Configure device with ff_disable set
> >
> > Ayuj Verma (2):
> >   test/crypto: move rsa enqueue/dequeue into separate functions
> >   test/crypto: add tests for RSA key type CRT
> >
> >  app/test/test_cryptodev_asym.c             | 460 +++++++++++++++++------------
> >  app/test/test_cryptodev_rsa_test_vectors.h |  93 ++++++
> >  2 files changed, 363 insertions(+), 190 deletions(-)
> >
> > --
> > 1.8.3.1
>
> Series-acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
>
Series-acked-by: Shally Verma <shallyv@marvell.com>


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

* Re: [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT
@ 2019-07-15 10:05 Shally Verma
  0 siblings, 0 replies; 7+ messages in thread
From: Shally Verma @ 2019-07-15 10:05 UTC (permalink / raw)
  To: Kusztal, ArkadiuszX, Ayuj Verma, akhil.goyal
  Cc: Anoob Joseph, Trahe, Fiona, Sunila Sahu, dev,
	Kanaka Durga Kotamarthy, Zhang, Roy Fan

Thanks Arek. Response inline.

Sent from Workspace ONE Boxer
On 12-Jul-2019 6:45 PM, "Kusztal, ArkadiuszX" <arkadiuszx.kusztal@intel.com> wrote:
>
> In future we could unify tests even more (i.e. passing padding type as a param, or even information if it is encryption or signature generation) like Fan once done with blockcipher.

I will take a look at that but isn't test suite preferable otherwise? Means keeping it less interactive in nature? Else command line args will be different combinations of padding type, modulus length, crt/non-crt, op type ..is it okay to make it this way?

Thanks
Shally

>
> > -----Original Message-----
> > From: Ayuj Verma [mailto:ayverma@marvell.com]
> > Sent: Thursday, July 11, 2019 3:23 PM
> > To: akhil.goyal@nxp.com
> > Cc: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>; Trahe, Fiona
> > <fiona.trahe@intel.com>; shallyv@marvell.com; ssahu@marvell.com;
> > kkotamarthy@marvell.com; anoobj@marvell.com; dev@dpdk.org; Ayuj
> > Verma <ayverma@marvell.com>
> > Subject: [PATCH v1 0/2] add tests for RSA key type CRT
> >
> > This patch series add new RSA CRT key based test cases, improve code
> > organization and also rebase it to latest changes.
> > It covers following changes:
> >
> > * Add crt key based rsa sign/verify, enc/decrypt test cases
> > * Move common code of enqueue/dequeue into separate function
> > * Configure device with ff_disable set
> >
> > Ayuj Verma (2):
> >   test/crypto: move rsa enqueue/dequeue into separate functions
> >   test/crypto: add tests for RSA key type CRT
> >
> >  app/test/test_cryptodev_asym.c             | 460 +++++++++++++++++------------
> >  app/test/test_cryptodev_rsa_test_vectors.h |  93 ++++++
> >  2 files changed, 363 insertions(+), 190 deletions(-)
> >
> > --
> > 1.8.3.1
>
> Series-acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
>


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

end of thread, other threads:[~2019-07-18 15:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 13:22 [dpdk-dev] [PATCH v1 0/2] add tests for RSA key type CRT Ayuj Verma
2019-07-11 13:22 ` [dpdk-dev] [PATCH v1 1/2] test/crypto: move rsa enqueue/dequeue into separate functions Ayuj Verma
2019-07-11 13:22 ` [dpdk-dev] [PATCH v1 2/2] test/crypto: add tests for RSA key type CRT Ayuj Verma
2019-07-12 13:15 ` [dpdk-dev] [PATCH v1 0/2] " Kusztal, ArkadiuszX
2019-07-15 10:05 Shally Verma
2019-07-16 12:04 Shally Verma
2019-07-18 15:35 ` 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).