From: Ramkumar <rb...@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: sta...@dpdk.org

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

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;
                }
-- 
2.17.1

Reply via email to