DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/test: fix rsa tests in qat suite
@ 2024-03-08  8:17 Arkadiusz Kusztal
  2024-03-08  8:23 ` [EXTERNAL] " Akhil Goyal
  2024-03-13  9:13 ` [PATCH v2] " Arkadiusz Kusztal
  0 siblings, 2 replies; 8+ messages in thread
From: Arkadiusz Kusztal @ 2024-03-08  8:17 UTC (permalink / raw)
  To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal, stable

This commit fixes incorrectly set keys in the
QAT testsuite for the RSA algorithm.

Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
Cc: stable@dpdk.org

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
 app/test/test_cryptodev_asym.c | 74 +++++++++++++++++++++---------------------
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 17daf734e8..241f9c30a0 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -3292,9 +3292,6 @@ modular_multiplicative_inverse(const void *test_data)
 	arg.qt.coef.data = coef; \
 	arg.qt.coef.length = vector->coef.len
 
-typedef void (*rsa_key_init_t)(struct rte_crypto_asym_xform *,
-	const struct rsa_test_data_2 *);
-
 static int
 RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
 {
@@ -3335,41 +3332,14 @@ RSA_Decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
 	return 0;
 }
 
-static void
-RSA_key_init_Exp(struct rte_crypto_asym_xform *xform,
-		const struct rsa_test_data_2 *vector)
-{
-	SET_RSA_PARAM(xform->rsa, vector, n);
-	SET_RSA_PARAM(xform->rsa, vector, e);
-	SET_RSA_PARAM(xform->rsa, vector, d);
-	xform->rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
-}
-
-static void
-RSA_key_init_CRT(struct rte_crypto_asym_xform *xform,
-		const struct rsa_test_data_2 *vector)
-{
-	SET_RSA_PARAM(xform->rsa, vector, n);
-	SET_RSA_PARAM(xform->rsa, vector, e);
-	SET_RSA_PARAM_QT(xform->rsa, vector, p);
-	SET_RSA_PARAM_QT(xform->rsa, vector, q);
-	SET_RSA_PARAM_QT(xform->rsa, vector, dP);
-	SET_RSA_PARAM_QT(xform->rsa, vector, dQ);
-	SET_RSA_PARAM_QT(xform->rsa, vector, qInv);
-	xform->rsa.key_type = RTE_RSA_KEY_TYPE_QT;
-}
-
 static int
-RSA_Init_Session(const struct rsa_test_data_2 *vector,
-	rsa_key_init_t key_init)
+RSA_Init_Session(struct rte_crypto_asym_xform *xform)
 {
 	const uint8_t dev_id = params->valid_devs[0];
 	struct rte_cryptodev_info dev_info;
-	struct rte_crypto_asym_xform xform = { };
 	int ret = 0;
 
-	key_init(&xform, vector);
-	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
+	xform->xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
 
 	rte_cryptodev_info_get(dev_id, &dev_info);
 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
@@ -3377,7 +3347,7 @@ RSA_Init_Session(const struct rsa_test_data_2 *vector,
 			"Device doesn't support decrypt op with quintuple key type. Test skipped\n");
 		return TEST_SKIPPED;
 	}
-	ret = rte_cryptodev_asym_session_create(dev_id, &xform,
+	ret = rte_cryptodev_asym_session_create(dev_id, xform,
 		params->session_mpool, &self->sess);
 	if (ret < 0) {
 		RTE_LOG(ERR, USER1,
@@ -3392,7 +3362,13 @@ KAT_RSA_Encrypt(const void *data)
 {
 	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
+	struct rte_crypto_asym_xform xform = { };
+
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+	int ret = RSA_Init_Session(&xform);
 
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
@@ -3412,8 +3388,17 @@ KAT_RSA_Encrypt_CRT(const void *data)
 {
 	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
+	struct rte_crypto_asym_xform xform = { };
 
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM_QT(xform.rsa, vector, p);
+	SET_RSA_PARAM_QT(xform.rsa, vector, q);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
+	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
+	int ret = RSA_Init_Session(&xform);
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
@@ -3432,7 +3417,13 @@ KAT_RSA_Decrypt(const void *data)
 {
 	uint8_t message[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
+	struct rte_crypto_asym_xform xform = { };
+
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+	int ret = RSA_Init_Session(&xform);
 
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
@@ -3452,8 +3443,17 @@ KAT_RSA_Decrypt_CRT(const void *data)
 {
 	uint8_t message[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
+	struct rte_crypto_asym_xform xform = { };
 
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM_QT(xform.rsa, vector, p);
+	SET_RSA_PARAM_QT(xform.rsa, vector, q);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
+	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
+	int ret = RSA_Init_Session(&xform);
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
-- 
2.13.6


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

* RE: [EXTERNAL] [PATCH] app/test: fix rsa tests in qat suite
  2024-03-08  8:17 [PATCH] app/test: fix rsa tests in qat suite Arkadiusz Kusztal
@ 2024-03-08  8:23 ` Akhil Goyal
  2024-03-13  9:13 ` [PATCH v2] " Arkadiusz Kusztal
  1 sibling, 0 replies; 8+ messages in thread
From: Akhil Goyal @ 2024-03-08  8:23 UTC (permalink / raw)
  To: Arkadiusz Kusztal, dev; +Cc: ciara.power, stable

> This commit fixes incorrectly set keys in the
> QAT testsuite for the RSA algorithm.
> 
> Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
>  app/test/test_cryptodev_asym.c | 74 +++++++++++++++++++++-------------------
> --
>  1 file changed, 37 insertions(+), 37 deletions(-)
> 
> diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
> index 17daf734e8..241f9c30a0 100644
> --- a/app/test/test_cryptodev_asym.c
> +++ b/app/test/test_cryptodev_asym.c
> @@ -3292,9 +3292,6 @@ modular_multiplicative_inverse(const void *test_data)
>  	arg.qt.coef.data = coef; \
>  	arg.qt.coef.length = vector->coef.len
> 
> -typedef void (*rsa_key_init_t)(struct rte_crypto_asym_xform *,
> -	const struct rsa_test_data_2 *);
> -
>  static int
>  RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
>  {
> @@ -3335,41 +3332,14 @@ RSA_Decrypt(const struct rsa_test_data_2 *vector,
> uint8_t *plaintext,
>  	return 0;
>  }
> 
> -static void
> -RSA_key_init_Exp(struct rte_crypto_asym_xform *xform,
> -		const struct rsa_test_data_2 *vector)
> -{
> -	SET_RSA_PARAM(xform->rsa, vector, n);
> -	SET_RSA_PARAM(xform->rsa, vector, e);
> -	SET_RSA_PARAM(xform->rsa, vector, d);
> -	xform->rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
> -}
> -
> -static void
> -RSA_key_init_CRT(struct rte_crypto_asym_xform *xform,
> -		const struct rsa_test_data_2 *vector)
> -{
> -	SET_RSA_PARAM(xform->rsa, vector, n);
> -	SET_RSA_PARAM(xform->rsa, vector, e);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, p);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, q);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, dP);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, dQ);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, qInv);
> -	xform->rsa.key_type = RTE_RSA_KEY_TYPE_QT;
> -}
> -
>  static int
> -RSA_Init_Session(const struct rsa_test_data_2 *vector,
> -	rsa_key_init_t key_init)
> +RSA_Init_Session(struct rte_crypto_asym_xform *xform)
>  {
>  	const uint8_t dev_id = params->valid_devs[0];
>  	struct rte_cryptodev_info dev_info;
> -	struct rte_crypto_asym_xform xform = { };
>  	int ret = 0;
> 
> -	key_init(&xform, vector);
> -	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
> +	xform->xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
> 
>  	rte_cryptodev_info_get(dev_id, &dev_info);
>  	if (!(dev_info.feature_flags &
> RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
> @@ -3377,7 +3347,7 @@ RSA_Init_Session(const struct rsa_test_data_2
> *vector,
>  			"Device doesn't support decrypt op with quintuple key
> type. Test skipped\n");
>  		return TEST_SKIPPED;
>  	}
> -	ret = rte_cryptodev_asym_session_create(dev_id, &xform,
> +	ret = rte_cryptodev_asym_session_create(dev_id, xform,
>  		params->session_mpool, &self->sess);
>  	if (ret < 0) {
>  		RTE_LOG(ERR, USER1,
> @@ -3392,7 +3362,13 @@ KAT_RSA_Encrypt(const void *data)
>  {
>  	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
> +	struct rte_crypto_asym_xform xform = { };
> +
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM(xform.rsa, vector, d);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
> +	int ret = RSA_Init_Session(&xform);

Please fix camel casing of functions as well.
This got missed in the original commit.

> 
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
> @@ -3412,8 +3388,17 @@ KAT_RSA_Encrypt_CRT(const void *data)
>  {
>  	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
> +	struct rte_crypto_asym_xform xform = { };
> 
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, p);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, q);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
> +	int ret = RSA_Init_Session(&xform);
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
>  		return ret;
> @@ -3432,7 +3417,13 @@ KAT_RSA_Decrypt(const void *data)
>  {
>  	uint8_t message[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
> +	struct rte_crypto_asym_xform xform = { };
> +
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM(xform.rsa, vector, d);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
> +	int ret = RSA_Init_Session(&xform);
> 
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
> @@ -3452,8 +3443,17 @@ KAT_RSA_Decrypt_CRT(const void *data)
>  {
>  	uint8_t message[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
> +	struct rte_crypto_asym_xform xform = { };
> 
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, p);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, q);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
> +	int ret = RSA_Init_Session(&xform);
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
>  		return ret;
> --
> 2.13.6


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

* [PATCH v2] app/test: fix rsa tests in qat suite
  2024-03-08  8:17 [PATCH] app/test: fix rsa tests in qat suite Arkadiusz Kusztal
  2024-03-08  8:23 ` [EXTERNAL] " Akhil Goyal
@ 2024-03-13  9:13 ` Arkadiusz Kusztal
  2024-03-13 10:02   ` [EXTERNAL] " Akhil Goyal
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Arkadiusz Kusztal @ 2024-03-13  9:13 UTC (permalink / raw)
  To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal, stable

This commit fixes incorrectly set keys in the
QAT testsuite for the RSA algorithm.

Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
Cc: stable@dpdk.org

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
v2:
- removed camel case

 app/test/test_cryptodev_asym.c             | 102 ++++++++++++++---------------
 app/test/test_cryptodev_rsa_test_vectors.h |   2 +-
 2 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 17daf734e8..2c745a7f7c 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -3292,11 +3292,8 @@ modular_multiplicative_inverse(const void *test_data)
 	arg.qt.coef.data = coef; \
 	arg.qt.coef.length = vector->coef.len
 
-typedef void (*rsa_key_init_t)(struct rte_crypto_asym_xform *,
-	const struct rsa_test_data_2 *);
-
 static int
-RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
+rsa_encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
 {
 	self->result_op = NULL;
 	/* Compute encryption on the test vector */
@@ -3314,7 +3311,7 @@ RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
 }
 
 static int
-RSA_Decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
+rsa_decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
 		const int use_op)
 {
 	uint8_t cipher[TEST_DATA_SIZE] = { 0 };
@@ -3335,41 +3332,14 @@ RSA_Decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
 	return 0;
 }
 
-static void
-RSA_key_init_Exp(struct rte_crypto_asym_xform *xform,
-		const struct rsa_test_data_2 *vector)
-{
-	SET_RSA_PARAM(xform->rsa, vector, n);
-	SET_RSA_PARAM(xform->rsa, vector, e);
-	SET_RSA_PARAM(xform->rsa, vector, d);
-	xform->rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
-}
-
-static void
-RSA_key_init_CRT(struct rte_crypto_asym_xform *xform,
-		const struct rsa_test_data_2 *vector)
-{
-	SET_RSA_PARAM(xform->rsa, vector, n);
-	SET_RSA_PARAM(xform->rsa, vector, e);
-	SET_RSA_PARAM_QT(xform->rsa, vector, p);
-	SET_RSA_PARAM_QT(xform->rsa, vector, q);
-	SET_RSA_PARAM_QT(xform->rsa, vector, dP);
-	SET_RSA_PARAM_QT(xform->rsa, vector, dQ);
-	SET_RSA_PARAM_QT(xform->rsa, vector, qInv);
-	xform->rsa.key_type = RTE_RSA_KEY_TYPE_QT;
-}
-
 static int
-RSA_Init_Session(const struct rsa_test_data_2 *vector,
-	rsa_key_init_t key_init)
+rsa_init_session(struct rte_crypto_asym_xform *xform)
 {
 	const uint8_t dev_id = params->valid_devs[0];
 	struct rte_cryptodev_info dev_info;
-	struct rte_crypto_asym_xform xform = { };
 	int ret = 0;
 
-	key_init(&xform, vector);
-	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
+	xform->xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
 
 	rte_cryptodev_info_get(dev_id, &dev_info);
 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
@@ -3377,7 +3347,7 @@ RSA_Init_Session(const struct rsa_test_data_2 *vector,
 			"Device doesn't support decrypt op with quintuple key type. Test skipped\n");
 		return TEST_SKIPPED;
 	}
-	ret = rte_cryptodev_asym_session_create(dev_id, &xform,
+	ret = rte_cryptodev_asym_session_create(dev_id, xform,
 		params->session_mpool, &self->sess);
 	if (ret < 0) {
 		RTE_LOG(ERR, USER1,
@@ -3388,17 +3358,23 @@ RSA_Init_Session(const struct rsa_test_data_2 *vector,
 }
 
 static int
-KAT_RSA_Encrypt(const void *data)
+kat_rsa_encrypt(const void *data)
 {
 	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
+	struct rte_crypto_asym_xform xform = { };
+
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+	int ret = rsa_init_session(&xform);
 
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Encrypt(vector, cipher_buf),
+	TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
 		self->result_op->asym->rsa.cipher.data,
@@ -3408,17 +3384,26 @@ KAT_RSA_Encrypt(const void *data)
 }
 
 static int
-KAT_RSA_Encrypt_CRT(const void *data)
+kat_rsa_encrypt_crt(const void *data)
 {
 	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
+	struct rte_crypto_asym_xform xform = { };
 
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM_QT(xform.rsa, vector, p);
+	SET_RSA_PARAM_QT(xform.rsa, vector, q);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
+	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
+	int ret = rsa_init_session(&xform);
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Encrypt(vector, cipher_buf),
+	TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
 		self->result_op->asym->rsa.cipher.data,
@@ -3428,17 +3413,23 @@ KAT_RSA_Encrypt_CRT(const void *data)
 }
 
 static int
-KAT_RSA_Decrypt(const void *data)
+kat_rsa_decrypt(const void *data)
 {
 	uint8_t message[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
+	struct rte_crypto_asym_xform xform = { };
+
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+	int ret = rsa_init_session(&xform);
 
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Decrypt(vector, message, 0),
+	TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
 		self->result_op->asym->rsa.message.data,
@@ -3448,17 +3439,26 @@ KAT_RSA_Decrypt(const void *data)
 }
 
 static int
-KAT_RSA_Decrypt_CRT(const void *data)
+kat_rsa_decrypt_crt(const void *data)
 {
 	uint8_t message[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
+	struct rte_crypto_asym_xform xform = { };
 
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM_QT(xform.rsa, vector, p);
+	SET_RSA_PARAM_QT(xform.rsa, vector, q);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
+	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
+	int ret = rsa_init_session(&xform);
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Decrypt(vector, message, 0),
+	TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
 		self->result_op->asym->rsa.message.data,
@@ -3535,20 +3535,20 @@ static struct unit_test_suite cryptodev_qat_asym_testsuite  = {
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Encryption (n=128, pt=20, e=3) EXP, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Encrypt, &RSA_vector_128_20_3_None),
+			kat_rsa_encrypt, &rsa_vector_128_20_3_none),
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Decryption (n=128, pt=20, e=3) EXP, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Decrypt, &RSA_vector_128_20_3_None),
+			kat_rsa_decrypt, &rsa_vector_128_20_3_none),
 		/* RSA CRT */
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Encryption (n=128, pt=20, e=3) CRT, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Encrypt_CRT, &RSA_vector_128_20_3_None),
+			kat_rsa_encrypt_crt, &rsa_vector_128_20_3_none),
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Decryption (n=128, pt=20, e=3) CRT, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Decrypt_CRT, &RSA_vector_128_20_3_None),
+			kat_rsa_decrypt_crt, &rsa_vector_128_20_3_none),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
diff --git a/app/test/test_cryptodev_rsa_test_vectors.h b/app/test/test_cryptodev_rsa_test_vectors.h
index b4982014a2..89981f13f0 100644
--- a/app/test/test_cryptodev_rsa_test_vectors.h
+++ b/app/test/test_cryptodev_rsa_test_vectors.h
@@ -72,7 +72,7 @@ struct rsa_test_data_2 {
 };
 
 static const struct
-rsa_test_data_2 RSA_vector_128_20_3_None = {
+rsa_test_data_2 rsa_vector_128_20_3_none = {
 	.description =
 		"RSA Encryption Decryption (n=128, pt=20, e=3) EXP, QT",
 	.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
-- 
2.13.6


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

* RE: [EXTERNAL] [PATCH v2] app/test: fix rsa tests in qat suite
  2024-03-13  9:13 ` [PATCH v2] " Arkadiusz Kusztal
@ 2024-03-13 10:02   ` Akhil Goyal
  2024-03-13 16:02   ` Power, Ciara
  2024-03-21  8:35   ` [PATCH v3] " Arkadiusz Kusztal
  2 siblings, 0 replies; 8+ messages in thread
From: Akhil Goyal @ 2024-03-13 10:02 UTC (permalink / raw)
  To: Arkadiusz Kusztal, dev; +Cc: ciara.power, stable

> This commit fixes incorrectly set keys in the
> QAT testsuite for the RSA algorithm.
> 
> Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
> v2:
> - removed camel case

Removing camel case should be a separate patch
Or update the patch title description appropriately.

> 
>  app/test/test_cryptodev_asym.c             | 102 ++++++++++++++---------------
>  app/test/test_cryptodev_rsa_test_vectors.h |   2 +-
>  2 files changed, 52 insertions(+), 52 deletions(-)
> 
> diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
> index 17daf734e8..2c745a7f7c 100644
> --- a/app/test/test_cryptodev_asym.c
> +++ b/app/test/test_cryptodev_asym.c
> @@ -3292,11 +3292,8 @@ modular_multiplicative_inverse(const void
> *test_data)
>  	arg.qt.coef.data = coef; \
>  	arg.qt.coef.length = vector->coef.len
> 
> -typedef void (*rsa_key_init_t)(struct rte_crypto_asym_xform *,
> -	const struct rsa_test_data_2 *);
> -
>  static int
> -RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
> +rsa_encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
>  {
>  	self->result_op = NULL;
>  	/* Compute encryption on the test vector */
> @@ -3314,7 +3311,7 @@ RSA_Encrypt(const struct rsa_test_data_2 *vector,
> uint8_t *cipher_buf)
>  }
> 
>  static int
> -RSA_Decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
> +rsa_decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
>  		const int use_op)
>  {
>  	uint8_t cipher[TEST_DATA_SIZE] = { 0 };
> @@ -3335,41 +3332,14 @@ RSA_Decrypt(const struct rsa_test_data_2 *vector,
> uint8_t *plaintext,
>  	return 0;
>  }
> 
> -static void
> -RSA_key_init_Exp(struct rte_crypto_asym_xform *xform,
> -		const struct rsa_test_data_2 *vector)
> -{
> -	SET_RSA_PARAM(xform->rsa, vector, n);
> -	SET_RSA_PARAM(xform->rsa, vector, e);
> -	SET_RSA_PARAM(xform->rsa, vector, d);
> -	xform->rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
> -}
> -
> -static void
> -RSA_key_init_CRT(struct rte_crypto_asym_xform *xform,
> -		const struct rsa_test_data_2 *vector)
> -{
> -	SET_RSA_PARAM(xform->rsa, vector, n);
> -	SET_RSA_PARAM(xform->rsa, vector, e);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, p);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, q);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, dP);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, dQ);
> -	SET_RSA_PARAM_QT(xform->rsa, vector, qInv);
> -	xform->rsa.key_type = RTE_RSA_KEY_TYPE_QT;
> -}
> -
>  static int
> -RSA_Init_Session(const struct rsa_test_data_2 *vector,
> -	rsa_key_init_t key_init)
> +rsa_init_session(struct rte_crypto_asym_xform *xform)
>  {
>  	const uint8_t dev_id = params->valid_devs[0];
>  	struct rte_cryptodev_info dev_info;
> -	struct rte_crypto_asym_xform xform = { };
>  	int ret = 0;
> 
> -	key_init(&xform, vector);
> -	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
> +	xform->xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
> 
>  	rte_cryptodev_info_get(dev_id, &dev_info);
>  	if (!(dev_info.feature_flags &
> RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
> @@ -3377,7 +3347,7 @@ RSA_Init_Session(const struct rsa_test_data_2
> *vector,
>  			"Device doesn't support decrypt op with quintuple key
> type. Test skipped\n");
>  		return TEST_SKIPPED;
>  	}
> -	ret = rte_cryptodev_asym_session_create(dev_id, &xform,
> +	ret = rte_cryptodev_asym_session_create(dev_id, xform,
>  		params->session_mpool, &self->sess);
>  	if (ret < 0) {
>  		RTE_LOG(ERR, USER1,
> @@ -3388,17 +3358,23 @@ RSA_Init_Session(const struct rsa_test_data_2
> *vector,
>  }
> 
>  static int
> -KAT_RSA_Encrypt(const void *data)
> +kat_rsa_encrypt(const void *data)
>  {
>  	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
> +	struct rte_crypto_asym_xform xform = { };
> +
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM(xform.rsa, vector, d);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
> +	int ret = rsa_init_session(&xform);
> 
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
>  		return ret;
>  	}
> -	TEST_ASSERT_SUCCESS(RSA_Encrypt(vector, cipher_buf),
> +	TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
>  		"RSA: Failed to encrypt");
>  	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
>  		self->result_op->asym->rsa.cipher.data,
> @@ -3408,17 +3384,26 @@ KAT_RSA_Encrypt(const void *data)
>  }
> 
>  static int
> -KAT_RSA_Encrypt_CRT(const void *data)
> +kat_rsa_encrypt_crt(const void *data)
>  {
>  	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
> +	struct rte_crypto_asym_xform xform = { };
> 
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, p);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, q);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
> +	int ret = rsa_init_session(&xform);
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
>  		return ret;
>  	}
> -	TEST_ASSERT_SUCCESS(RSA_Encrypt(vector, cipher_buf),
> +	TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
>  		"RSA: Failed to encrypt");
>  	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
>  		self->result_op->asym->rsa.cipher.data,
> @@ -3428,17 +3413,23 @@ KAT_RSA_Encrypt_CRT(const void *data)
>  }
> 
>  static int
> -KAT_RSA_Decrypt(const void *data)
> +kat_rsa_decrypt(const void *data)
>  {
>  	uint8_t message[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
> +	struct rte_crypto_asym_xform xform = { };
> +
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM(xform.rsa, vector, d);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
> +	int ret = rsa_init_session(&xform);
> 
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
>  		return ret;
>  	}
> -	TEST_ASSERT_SUCCESS(RSA_Decrypt(vector, message, 0),
> +	TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
>  		"RSA: Failed to encrypt");
>  	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
>  		self->result_op->asym->rsa.message.data,
> @@ -3448,17 +3439,26 @@ KAT_RSA_Decrypt(const void *data)
>  }
> 
>  static int
> -KAT_RSA_Decrypt_CRT(const void *data)
> +kat_rsa_decrypt_crt(const void *data)
>  {
>  	uint8_t message[TEST_DATA_SIZE] = {0};
>  	const struct rsa_test_data_2 *vector = data;
> -	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
> +	struct rte_crypto_asym_xform xform = { };
> 
> +	SET_RSA_PARAM(xform.rsa, vector, n);
> +	SET_RSA_PARAM(xform.rsa, vector, e);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, p);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, q);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
> +	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
> +	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
> +	int ret = rsa_init_session(&xform);
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
>  		return ret;
>  	}
> -	TEST_ASSERT_SUCCESS(RSA_Decrypt(vector, message, 0),
> +	TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
>  		"RSA: Failed to encrypt");
>  	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
>  		self->result_op->asym->rsa.message.data,
> @@ -3535,20 +3535,20 @@ static struct unit_test_suite
> cryptodev_qat_asym_testsuite  = {
>  		TEST_CASE_NAMED_WITH_DATA(
>  			"RSA Encryption (n=128, pt=20, e=3) EXP, Padding:
> NONE",
>  			ut_setup_asym, ut_teardown_asym,
> -			KAT_RSA_Encrypt, &RSA_vector_128_20_3_None),
> +			kat_rsa_encrypt, &rsa_vector_128_20_3_none),
>  		TEST_CASE_NAMED_WITH_DATA(
>  			"RSA Decryption (n=128, pt=20, e=3) EXP, Padding:
> NONE",
>  			ut_setup_asym, ut_teardown_asym,
> -			KAT_RSA_Decrypt, &RSA_vector_128_20_3_None),
> +			kat_rsa_decrypt, &rsa_vector_128_20_3_none),
>  		/* RSA CRT */
>  		TEST_CASE_NAMED_WITH_DATA(
>  			"RSA Encryption (n=128, pt=20, e=3) CRT, Padding:
> NONE",
>  			ut_setup_asym, ut_teardown_asym,
> -			KAT_RSA_Encrypt_CRT, &RSA_vector_128_20_3_None),
> +			kat_rsa_encrypt_crt, &rsa_vector_128_20_3_none),
>  		TEST_CASE_NAMED_WITH_DATA(
>  			"RSA Decryption (n=128, pt=20, e=3) CRT, Padding:
> NONE",
>  			ut_setup_asym, ut_teardown_asym,
> -			KAT_RSA_Decrypt_CRT, &RSA_vector_128_20_3_None),
> +			kat_rsa_decrypt_crt, &rsa_vector_128_20_3_none),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> diff --git a/app/test/test_cryptodev_rsa_test_vectors.h
> b/app/test/test_cryptodev_rsa_test_vectors.h
> index b4982014a2..89981f13f0 100644
> --- a/app/test/test_cryptodev_rsa_test_vectors.h
> +++ b/app/test/test_cryptodev_rsa_test_vectors.h
> @@ -72,7 +72,7 @@ struct rsa_test_data_2 {
>  };
> 
>  static const struct
> -rsa_test_data_2 RSA_vector_128_20_3_None = {
> +rsa_test_data_2 rsa_vector_128_20_3_none = {
>  	.description =
>  		"RSA Encryption Decryption (n=128, pt=20, e=3) EXP, QT",
>  	.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
> --
> 2.13.6


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

* RE: [PATCH v2] app/test: fix rsa tests in qat suite
  2024-03-13  9:13 ` [PATCH v2] " Arkadiusz Kusztal
  2024-03-13 10:02   ` [EXTERNAL] " Akhil Goyal
@ 2024-03-13 16:02   ` Power, Ciara
  2024-03-21  8:35   ` [PATCH v3] " Arkadiusz Kusztal
  2 siblings, 0 replies; 8+ messages in thread
From: Power, Ciara @ 2024-03-13 16:02 UTC (permalink / raw)
  To: Kusztal, ArkadiuszX, dev; +Cc: gakhil, stable



> -----Original Message-----
> From: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Sent: Wednesday, March 13, 2024 9:14 AM
> To: dev@dpdk.org
> Cc: gakhil@marvell.com; Power, Ciara <ciara.power@intel.com>; Kusztal,
> ArkadiuszX <arkadiuszx.kusztal@intel.com>; stable@dpdk.org
> Subject: [PATCH v2] app/test: fix rsa tests in qat suite
> 
> This commit fixes incorrectly set keys in the QAT testsuite for the RSA algorithm.
> 
> Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
> v2:
> - removed camel case
> 
Acked-by: Ciara Power <ciara.power@intel.com>

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

* [PATCH v3] app/test: fix rsa tests in qat suite
  2024-03-13  9:13 ` [PATCH v2] " Arkadiusz Kusztal
  2024-03-13 10:02   ` [EXTERNAL] " Akhil Goyal
  2024-03-13 16:02   ` Power, Ciara
@ 2024-03-21  8:35   ` Arkadiusz Kusztal
  2024-03-21  8:36     ` Power, Ciara
  2024-05-30  9:06     ` [EXTERNAL] " Akhil Goyal
  2 siblings, 2 replies; 8+ messages in thread
From: Arkadiusz Kusztal @ 2024-03-21  8:35 UTC (permalink / raw)
  To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal, stable

This commit fixes following issues in the QAT testsuite for
the RSA algorithm:

1) Incorrectly set keys in the internal functions are now
set in the calling function.
2) Camel case functions were changed to the snake case.

Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
Cc: stable@dpdk.org

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
v2:
- removed camel case
v3:
- changed commit description

 app/test/test_cryptodev_asym.c             | 102 ++++++++++++++---------------
 app/test/test_cryptodev_rsa_test_vectors.h |   2 +-
 2 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 17daf734e8..2c745a7f7c 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -3292,11 +3292,8 @@ modular_multiplicative_inverse(const void *test_data)
 	arg.qt.coef.data = coef; \
 	arg.qt.coef.length = vector->coef.len
 
-typedef void (*rsa_key_init_t)(struct rte_crypto_asym_xform *,
-	const struct rsa_test_data_2 *);
-
 static int
-RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
+rsa_encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
 {
 	self->result_op = NULL;
 	/* Compute encryption on the test vector */
@@ -3314,7 +3311,7 @@ RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf)
 }
 
 static int
-RSA_Decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
+rsa_decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
 		const int use_op)
 {
 	uint8_t cipher[TEST_DATA_SIZE] = { 0 };
@@ -3335,41 +3332,14 @@ RSA_Decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext,
 	return 0;
 }
 
-static void
-RSA_key_init_Exp(struct rte_crypto_asym_xform *xform,
-		const struct rsa_test_data_2 *vector)
-{
-	SET_RSA_PARAM(xform->rsa, vector, n);
-	SET_RSA_PARAM(xform->rsa, vector, e);
-	SET_RSA_PARAM(xform->rsa, vector, d);
-	xform->rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
-}
-
-static void
-RSA_key_init_CRT(struct rte_crypto_asym_xform *xform,
-		const struct rsa_test_data_2 *vector)
-{
-	SET_RSA_PARAM(xform->rsa, vector, n);
-	SET_RSA_PARAM(xform->rsa, vector, e);
-	SET_RSA_PARAM_QT(xform->rsa, vector, p);
-	SET_RSA_PARAM_QT(xform->rsa, vector, q);
-	SET_RSA_PARAM_QT(xform->rsa, vector, dP);
-	SET_RSA_PARAM_QT(xform->rsa, vector, dQ);
-	SET_RSA_PARAM_QT(xform->rsa, vector, qInv);
-	xform->rsa.key_type = RTE_RSA_KEY_TYPE_QT;
-}
-
 static int
-RSA_Init_Session(const struct rsa_test_data_2 *vector,
-	rsa_key_init_t key_init)
+rsa_init_session(struct rte_crypto_asym_xform *xform)
 {
 	const uint8_t dev_id = params->valid_devs[0];
 	struct rte_cryptodev_info dev_info;
-	struct rte_crypto_asym_xform xform = { };
 	int ret = 0;
 
-	key_init(&xform, vector);
-	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
+	xform->xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
 
 	rte_cryptodev_info_get(dev_id, &dev_info);
 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
@@ -3377,7 +3347,7 @@ RSA_Init_Session(const struct rsa_test_data_2 *vector,
 			"Device doesn't support decrypt op with quintuple key type. Test skipped\n");
 		return TEST_SKIPPED;
 	}
-	ret = rte_cryptodev_asym_session_create(dev_id, &xform,
+	ret = rte_cryptodev_asym_session_create(dev_id, xform,
 		params->session_mpool, &self->sess);
 	if (ret < 0) {
 		RTE_LOG(ERR, USER1,
@@ -3388,17 +3358,23 @@ RSA_Init_Session(const struct rsa_test_data_2 *vector,
 }
 
 static int
-KAT_RSA_Encrypt(const void *data)
+kat_rsa_encrypt(const void *data)
 {
 	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
+	struct rte_crypto_asym_xform xform = { };
+
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+	int ret = rsa_init_session(&xform);
 
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Encrypt(vector, cipher_buf),
+	TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
 		self->result_op->asym->rsa.cipher.data,
@@ -3408,17 +3384,26 @@ KAT_RSA_Encrypt(const void *data)
 }
 
 static int
-KAT_RSA_Encrypt_CRT(const void *data)
+kat_rsa_encrypt_crt(const void *data)
 {
 	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
+	struct rte_crypto_asym_xform xform = { };
 
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM_QT(xform.rsa, vector, p);
+	SET_RSA_PARAM_QT(xform.rsa, vector, q);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
+	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
+	int ret = rsa_init_session(&xform);
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Encrypt(vector, cipher_buf),
+	TEST_ASSERT_SUCCESS(rsa_encrypt(vector, cipher_buf),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->cipher.data,
 		self->result_op->asym->rsa.cipher.data,
@@ -3428,17 +3413,23 @@ KAT_RSA_Encrypt_CRT(const void *data)
 }
 
 static int
-KAT_RSA_Decrypt(const void *data)
+kat_rsa_decrypt(const void *data)
 {
 	uint8_t message[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_Exp);
+	struct rte_crypto_asym_xform xform = { };
+
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM(xform.rsa, vector, d);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+	int ret = rsa_init_session(&xform);
 
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Decrypt(vector, message, 0),
+	TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
 		self->result_op->asym->rsa.message.data,
@@ -3448,17 +3439,26 @@ KAT_RSA_Decrypt(const void *data)
 }
 
 static int
-KAT_RSA_Decrypt_CRT(const void *data)
+kat_rsa_decrypt_crt(const void *data)
 {
 	uint8_t message[TEST_DATA_SIZE] = {0};
 	const struct rsa_test_data_2 *vector = data;
-	int ret = RSA_Init_Session(vector, RSA_key_init_CRT);
+	struct rte_crypto_asym_xform xform = { };
 
+	SET_RSA_PARAM(xform.rsa, vector, n);
+	SET_RSA_PARAM(xform.rsa, vector, e);
+	SET_RSA_PARAM_QT(xform.rsa, vector, p);
+	SET_RSA_PARAM_QT(xform.rsa, vector, q);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dP);
+	SET_RSA_PARAM_QT(xform.rsa, vector, dQ);
+	SET_RSA_PARAM_QT(xform.rsa, vector, qInv);
+	xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT;
+	int ret = rsa_init_session(&xform);
 	if (ret) {
 		RTE_LOG(ERR, USER1, "Failed to init session for RSA\n");
 		return ret;
 	}
-	TEST_ASSERT_SUCCESS(RSA_Decrypt(vector, message, 0),
+	TEST_ASSERT_SUCCESS(rsa_decrypt(vector, message, 0),
 		"RSA: Failed to encrypt");
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->message.data,
 		self->result_op->asym->rsa.message.data,
@@ -3535,20 +3535,20 @@ static struct unit_test_suite cryptodev_qat_asym_testsuite  = {
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Encryption (n=128, pt=20, e=3) EXP, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Encrypt, &RSA_vector_128_20_3_None),
+			kat_rsa_encrypt, &rsa_vector_128_20_3_none),
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Decryption (n=128, pt=20, e=3) EXP, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Decrypt, &RSA_vector_128_20_3_None),
+			kat_rsa_decrypt, &rsa_vector_128_20_3_none),
 		/* RSA CRT */
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Encryption (n=128, pt=20, e=3) CRT, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Encrypt_CRT, &RSA_vector_128_20_3_None),
+			kat_rsa_encrypt_crt, &rsa_vector_128_20_3_none),
 		TEST_CASE_NAMED_WITH_DATA(
 			"RSA Decryption (n=128, pt=20, e=3) CRT, Padding: NONE",
 			ut_setup_asym, ut_teardown_asym,
-			KAT_RSA_Decrypt_CRT, &RSA_vector_128_20_3_None),
+			kat_rsa_decrypt_crt, &rsa_vector_128_20_3_none),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
diff --git a/app/test/test_cryptodev_rsa_test_vectors.h b/app/test/test_cryptodev_rsa_test_vectors.h
index b4982014a2..89981f13f0 100644
--- a/app/test/test_cryptodev_rsa_test_vectors.h
+++ b/app/test/test_cryptodev_rsa_test_vectors.h
@@ -72,7 +72,7 @@ struct rsa_test_data_2 {
 };
 
 static const struct
-rsa_test_data_2 RSA_vector_128_20_3_None = {
+rsa_test_data_2 rsa_vector_128_20_3_none = {
 	.description =
 		"RSA Encryption Decryption (n=128, pt=20, e=3) EXP, QT",
 	.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
-- 
2.13.6


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

* RE: [PATCH v3] app/test: fix rsa tests in qat suite
  2024-03-21  8:35   ` [PATCH v3] " Arkadiusz Kusztal
@ 2024-03-21  8:36     ` Power, Ciara
  2024-05-30  9:06     ` [EXTERNAL] " Akhil Goyal
  1 sibling, 0 replies; 8+ messages in thread
From: Power, Ciara @ 2024-03-21  8:36 UTC (permalink / raw)
  To: Kusztal, ArkadiuszX, dev; +Cc: gakhil, stable



> -----Original Message-----
> From: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Sent: Thursday, March 21, 2024 8:35 AM
> To: dev@dpdk.org
> Cc: gakhil@marvell.com; Power, Ciara <ciara.power@intel.com>; Kusztal,
> ArkadiuszX <arkadiuszx.kusztal@intel.com>; stable@dpdk.org
> Subject: [PATCH v3] app/test: fix rsa tests in qat suite
> 
> This commit fixes following issues in the QAT testsuite for the RSA algorithm:
> 
> 1) Incorrectly set keys in the internal functions are now set in the calling
> function.
> 2) Camel case functions were changed to the snake case.
> 
> Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
> v2:
> - removed camel case
> v3:
> - changed commit description

Acked-by: Ciara Power <ciara.power@intel.com>

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

* RE: [EXTERNAL] [PATCH v3] app/test: fix rsa tests in qat suite
  2024-03-21  8:35   ` [PATCH v3] " Arkadiusz Kusztal
  2024-03-21  8:36     ` Power, Ciara
@ 2024-05-30  9:06     ` Akhil Goyal
  1 sibling, 0 replies; 8+ messages in thread
From: Akhil Goyal @ 2024-05-30  9:06 UTC (permalink / raw)
  To: Arkadiusz Kusztal, dev; +Cc: stable

> This commit fixes following issues in the QAT testsuite for
> the RSA algorithm:
> 
> 1) Incorrectly set keys in the internal functions are now
> set in the calling function.
> 2) Camel case functions were changed to the snake case.
> 
> Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
Applied to dpdk-next-crypto

Title changed as "test/crypto: fix RSA cases in QAT suite"

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

end of thread, other threads:[~2024-05-30  9:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08  8:17 [PATCH] app/test: fix rsa tests in qat suite Arkadiusz Kusztal
2024-03-08  8:23 ` [EXTERNAL] " Akhil Goyal
2024-03-13  9:13 ` [PATCH v2] " Arkadiusz Kusztal
2024-03-13 10:02   ` [EXTERNAL] " Akhil Goyal
2024-03-13 16:02   ` Power, Ciara
2024-03-21  8:35   ` [PATCH v3] " Arkadiusz Kusztal
2024-03-21  8:36     ` Power, Ciara
2024-05-30  9:06     ` [EXTERNAL] " 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).