[PATCH] test/crypto: add negative test for RSA verify op
Gowrishankar Muthukrishnan
gmuthukrishn at marvell.com
Fri Feb 21 18:09:05 CET 2025
Add negative test for RSA verify operation to check if incorrect
signature is validated.
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn at marvell.com>
---
app/test/test_cryptodev_asym.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 8977d9d3a5..9b5f3c545e 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -62,7 +62,7 @@ queue_ops_rsa_sign_verify(void *sess)
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;
+ int status;
/* Set up crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
@@ -129,12 +129,35 @@ queue_ops_rsa_sign_verify(void *sess)
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;
+ goto error_exit;
+ }
+
+ /* Negative test */
+ result_op->asym->rsa.sign.data[0] ^= 0xff;
+ if (rte_cryptodev_enqueue_burst(dev_id, 0, &result_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;
+ }
+
+ if (result_op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+ RTE_LOG(ERR, USER1, "Failed to process sign-verify op\n");
+ status = TEST_FAILED;
+ }
+
+ status = TEST_SUCCESS;
error_exit:
rte_crypto_op_free(op);
--
2.25.1
More information about the dev
mailing list