[3/3] test/crypto: fix RSA decrypt op validation

Message ID 20250620081921.2145-3-gmuthukrishn@marvell.com (mailing list archive)
State Accepted
Delegated to: akhil goyal
Headers
Series [1/3] crypto/openssl: include private exponent in RSA session |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/loongarch-compilation success Compilation OK RETEST #2
ci/loongarch-unit-testing success Unit Testing PASS RETEST #2
ci/iol-marvell-Functional success Functional Testing PASS RETEST #1
ci/iol-broadcom-Performance success Performance Testing PASS RETEST #1
ci/iol-intel-Functional success Functional Testing PASS RETEST #1
ci/iol-unit-amd64-testing success Testing PASS RETEST #1
ci/iol-abi-testing success Testing PASS RETEST #1
ci/iol-unit-arm64-testing success Testing PASS RETEST #1
ci/iol-compile-amd64-testing warning Testing issues RETEST #1
ci/iol-compile-arm64-testing success Testing PASS RETEST #1
ci/iol-sample-apps-testing success Testing PASS RETEST #1

Commit Message

Gowrishankar Muthukrishnan June 20, 2025, 8:19 a.m. UTC
Following RSA encrypt op, same plaintext buffer is used as output
buffer for decrypt op, hence comparing plaintext buffer against
same buffer pointer in crypto op always succeed irrespective of
whether decrypt op succeeds or not. This patch fixes this issue
with a local buffer for crypto op.

Fixes: 5ae36995f10f ("test/crypto: move RSA enqueue/dequeue into functions")
Cc: stable@dpdk.org

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_cryptodev_asym.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
  

Comments

Akhil Goyal June 24, 2025, 1:55 p.m. UTC | #1
Recheck-request: rebase=main, iol-unit-amd64-testing
  
Akhil Goyal June 25, 2025, 11:48 a.m. UTC | #2
> Subject: [PATCH 3/3] test/crypto: fix RSA decrypt op validation
> 
> Following RSA encrypt op, same plaintext buffer is used as output
> buffer for decrypt op, hence comparing plaintext buffer against
> same buffer pointer in crypto op always succeed irrespective of
> whether decrypt op succeeds or not. This patch fixes this issue
> with a local buffer for crypto op.
> 
> Fixes: 5ae36995f10f ("test/crypto: move RSA enqueue/dequeue into functions")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Series Applied to dpdk-next-crypto
Thanks.
  

Patch

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index a5f3eae41d..557eaf2706 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -175,7 +175,10 @@  queue_ops_rsa_enc_dec(void *sess)
 	struct rte_crypto_op *op, *result_op;
 	struct rte_crypto_asym_op *asym_op;
 	uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
-	int ret, status = TEST_SUCCESS;
+	uint8_t msg_buf[TEST_DATA_SIZE] = {0};
+	int ret, status;
+
+	memcpy(msg_buf, rsaplaintext.data, rsaplaintext.len);
 
 	/* Set up crypto op data structure */
 	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
@@ -190,7 +193,7 @@  queue_ops_rsa_enc_dec(void *sess)
 	/* 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.data = msg_buf;
 	asym_op->rsa.cipher.data = cipher_buf;
 	asym_op->rsa.cipher.length = RTE_DIM(rsa_n);
 	asym_op->rsa.message.length = rsaplaintext.len;
@@ -225,6 +228,7 @@  queue_ops_rsa_enc_dec(void *sess)
 	asym_op = result_op->asym;
 	asym_op->rsa.message.length = RTE_DIM(rsa_n);
 	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
+	memset(asym_op->rsa.message.data, 0, asym_op->rsa.message.length);
 
 	/* Process crypto operation */
 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
@@ -241,11 +245,20 @@  queue_ops_rsa_enc_dec(void *sess)
 		status = TEST_FAILED;
 		goto error_exit;
 	}
-	status = TEST_SUCCESS;
+
+	if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+		RTE_LOG(ERR, USER1, "Expected crypto op to succeed\n");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
 	ret = rsa_verify(&rsaplaintext, result_op);
-	if (ret)
+	if (ret) {
 		status = TEST_FAILED;
+		goto error_exit;
+	}
 
+	status = TEST_SUCCESS;
 error_exit:
 
 	rte_crypto_op_free(op);