From: Sucharitha Sarananaga <ssarananaga@marvell.com>
To: <dev@dpdk.org>
Cc: <anoobj@marvell.com>, <gakhil@marvell.com>,
<ktejasree@marvell.com>, <adwivedi@marvell.com>,
Sucharitha Sarananaga <ssarananaga@marvell.com>
Subject: [PATCH] crypto/cnxk: refactor rsa verification
Date: Wed, 20 Aug 2025 17:52:18 +0000 [thread overview]
Message-ID: <20250820175218.2963352-1-ssarananaga@marvell.com> (raw)
This patch avoid copying the decrypted message into
the signature buffer, which is actually an input to the
verify operation. This prevents overwriting the input
buffer unnecessarily.
Fixes: 6661bedf1605 ("crypto/cnxk: add asymmetric datapath")
Signed-off-by: Sucharitha Sarananaga <ssarananaga@marvell.com>
---
drivers/crypto/cnxk/cnxk_ae.h | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index cd66f66e70..26a8f4544d 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -1583,20 +1583,18 @@ cnxk_ae_dequeue_rsa_op(struct rte_crypto_op *cop, uint8_t *rptr,
case RTE_CRYPTO_ASYM_OP_VERIFY:
if (rsa_ctx->padding.type == RTE_CRYPTO_RSA_PADDING_NONE) {
rsa->sign.length = rsa_ctx->n.length;
- memcpy(rsa->sign.data, rptr, rsa->sign.length);
+ if (memcmp(rptr, rsa->message.data, rsa->message.length))
+ cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
} else {
/* Get length of signed output */
rsa->sign.length =
rte_cpu_to_be_16(*((uint16_t *)rptr));
/*
* Offset output data pointer by length field
- * (2 bytes) and copy signed data.
+ * (2 bytes) and compare signed data.
*/
- memcpy(rsa->sign.data, rptr + 2, rsa->sign.length);
- }
- if (memcmp(rsa->sign.data, rsa->message.data,
- rsa->message.length)) {
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+ if (memcmp(rptr + 2, rsa->message.data, rsa->message.length))
+ cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
}
break;
default:
--
2.49.0
reply other threads:[~2025-08-20 17:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250820175218.2963352-1-ssarananaga@marvell.com \
--to=ssarananaga@marvell.com \
--cc=adwivedi@marvell.com \
--cc=anoobj@marvell.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=ktejasree@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).