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

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

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

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

During RSA sign verification, this 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: 6661bedf1605 ("crypto/cnxk: add asymmetric datapath")
Cc: stable@dpdk.org

Signed-off-by: Ramkumar <rbalu@marvell.com>
---
 drivers/crypto/cnxk/cnxk_ae.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
  

Patch

diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 6222171fe6..f4c6c92880 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -696,19 +696,22 @@  cnxk_ae_dequeue_rsa_op(struct rte_crypto_op *cop, uint8_t *rptr,
 		break;
 	case RTE_CRYPTO_ASYM_OP_VERIFY:
 		if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE) {
-			rsa->sign.length = rsa_ctx->n.length;
-			memcpy(rsa->sign.data, rptr, rsa->sign.length);
+			rsa->cipher.length = rsa_ctx->n.length;
 		} else {
 			/* Get length of signed output */
-			rsa->sign.length =
+			rsa->cipher.length =
 				rte_cpu_to_be_16(*((uint16_t *)rptr));
 			/*
 			 * Offset output data pointer by length field
-			 * (2 bytes) and copy signed data.
+			 * (2 bytes).
 			 */
-			memcpy(rsa->sign.data, rptr + 2, rsa->sign.length);
+			rptr += 2;
 		}
-		if (memcmp(rsa->sign.data, rsa->message.data,
+
+		if (rsa->cipher.data != NULL)
+			memcpy(rsa->cipher.data, rptr, rsa->cipher.length);
+
+		if (memcmp(rptr, rsa->message.data,
 			   rsa->message.length)) {
 			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
 		}