[3/5] crypto/octeontx: fix output field for RSA verify

Message ID 20211129095159.16376-4-rbalu@marvell.com (mailing list archive)
State Rejected, archived
Delegated to: akhil goyal
Series cryptodev: fix inconsistency in RSA op usage |


Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ramkumar Balu Nov. 29, 2021, 9:51 a.m. UTC
  From: Ramkumar <rbalu@marvell.com>

During RSA sign verification, the OCTEONTX PMD returns the decrypted
plaintext in 'sign' field of rte_crypto_rsa_op_param. The 'sign' field
is actually used to pass input to the operation. This PMD overwrites
the 'sign' field buffer. This is non-compliance to lib cryptodev.

This patch fixes the PMD to use 'cipher' field to return the decrypted
plaintext during RSA verify operation.

Fixes: e9a356e2fc71 ("crypto/octeontx: add asymmetric enqueue/dequeue ops")
Cc: stable@dpdk.org

Signed-off-by: Ramkumar <rbalu@marvell.com>
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)


diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index 9e8fd495cf..07ce079d87 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -788,18 +788,20 @@  otx_cpt_asym_rsa_op(struct rte_crypto_op *cop, struct cpt_request_info *req,
 		if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE)
-			rsa->sign.length = rsa_ctx->n.length;
+			rsa->cipher.length = rsa_ctx->n.length;
 		else {
 			/* Get length of decrypted output */
-			rsa->sign.length = rte_cpu_to_be_16
+			rsa->cipher.length = rte_cpu_to_be_16
 					(*((uint16_t *)req->rptr));
 			/* Offset data pointer by length fields */
 			req->rptr += 2;
-		memcpy(rsa->sign.data, req->rptr, rsa->sign.length);
-		if (memcmp(rsa->sign.data, rsa->message.data,
+		if (rsa->cipher.data != NULL)
+			memcpy(rsa->cipher.data, req->rptr, rsa->cipher.length);
+		if (memcmp(req->rptr, rsa->message.data,
 			   rsa->message.length)) {
 			CPT_LOG_DP_ERR("RSA verification failed");
 			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;