From: Sucharitha Sarananaga <ssarananaga@marvell.com>
To: <dev@dpdk.org>
Cc: <anoobj@marvell.com>, <gakhil@marvell.com>, <kai.ji@intel.com>,
"Sucharitha Sarananaga" <ssarananaga@marvell.com>
Subject: [PATCH 2/2] app/test-crypto-perf: fix other asym ops execution failure
Date: Thu, 21 Aug 2025 05:24:40 +0000 [thread overview]
Message-ID: <20250821052440.3213146-3-ssarananaga@marvell.com> (raw)
In-Reply-To: <20250821052440.3213146-1-ssarananaga@marvell.com>
This patch addresses an issue where execution operations were failing
despite the optype parameter being correctly configured. The failure
occurring because it is executing rsa optype params check instead of
configured optype and removed copying of sign data into temporary buffer.
Fixes: e131b8e643fd ("app/crypto-perf: add RSA test vectors")
Signed-off-by: Sucharitha Sarananaga <ssarananaga@marvell.com>
---
app/test-crypto-perf/cperf_ops.c | 4 +-
app/test-crypto-perf/cperf_options_parsing.c | 156 ++++++++++---------
2 files changed, 81 insertions(+), 79 deletions(-)
diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index 20fba60426..49ee1ae49c 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -69,9 +69,7 @@ cperf_set_ops_asym_rsa(struct rte_crypto_op **ops,
asym_op->rsa.message.data = crypto_buf;
asym_op->rsa.message.length = options->rsa_data->n.length;
} else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
- memcpy(crypto_buf, options->rsa_data->sign.data,
- options->rsa_data->sign.length);
- asym_op->rsa.sign.data = crypto_buf;
+ asym_op->rsa.sign.data = options->rsa_data->sign.data;
asym_op->rsa.sign.length = options->rsa_data->sign.length;
asym_op->rsa.message.data = rsa_plaintext.data;
asym_op->rsa.message.length = rsa_plaintext.len;
diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index 0c7c57ce42..dc36dc0f2d 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -1358,6 +1358,40 @@ is_valid_chained_op(struct cperf_options *options)
return false;
}
+static int
+cperf_rsa_options_check(struct cperf_options *options)
+{
+ if (options->rsa_keytype != UINT8_MAX) {
+ switch (options->rsa_keytype) {
+ case RTE_RSA_KEY_TYPE_QT:
+ if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_SIGN &&
+ options->asym_op_type != RTE_CRYPTO_ASYM_OP_DECRYPT) {
+ RTE_LOG(ERR, USER1, "QT private key to be used in sign and decrypt op\n");
+ return -EINVAL;
+ }
+ options->rsa_data = &rsa_qt_perf_data[0];
+ break;
+ case RTE_RSA_KEY_TYPE_EXP:
+ if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_ENCRYPT &&
+ options->asym_op_type != RTE_CRYPTO_ASYM_OP_VERIFY) {
+ RTE_LOG(ERR, USER1, "Exponent private key to be used in encrypt and verify op\n");
+ return -EINVAL;
+ }
+ options->rsa_data = &rsa_exp_perf_data[0];
+ break;
+ default:
+ RTE_LOG(ERR, USER1, "Invalid RSA key type specified\n");
+ return -EINVAL;
+ }
+ } else {
+ if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_ENCRYPT) {
+ RTE_LOG(ERR, USER1, "Public key to be used in encrypt op\n");
+ return -EINVAL;
+ }
+ }
+ return 0;
+}
+
int
cperf_options_check(struct cperf_options *options)
{
@@ -1522,95 +1556,65 @@ cperf_options_check(struct cperf_options *options)
}
}
- if (options->rsa_keytype != UINT8_MAX) {
- if (options->op_type != CPERF_ASYM_RSA) {
- RTE_LOG(ERR, USER1, "Option rsa-priv-keytype should be used only with "
- " optype: rsa.\n");
- return -EINVAL;
- }
-
- switch (options->rsa_keytype) {
- case RTE_RSA_KEY_TYPE_QT:
- if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_SIGN &&
- options->asym_op_type != RTE_CRYPTO_ASYM_OP_DECRYPT) {
- RTE_LOG(ERR, USER1, "QT private key to be used in sign and decrypt op\n");
- return -EINVAL;
- }
- options->rsa_data = &rsa_qt_perf_data[0];
- break;
- case RTE_RSA_KEY_TYPE_EXP:
- if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_ENCRYPT &&
- options->asym_op_type != RTE_CRYPTO_ASYM_OP_VERIFY) {
- RTE_LOG(ERR, USER1, "Exponent private key to be used in encrypt and verify op\n");
- return -EINVAL;
- }
- options->rsa_data = &rsa_exp_perf_data[0];
- break;
- default:
- RTE_LOG(ERR, USER1, "Invalid RSA key type specified\n");
- return -EINVAL;
- }
- } else {
- if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_ENCRYPT) {
- RTE_LOG(ERR, USER1, "Public key to be used in encrypt op\n");
- return -EINVAL;
- }
- }
- if (options->rsa_modlen) {
- if (options->op_type != CPERF_ASYM_RSA) {
- RTE_LOG(ERR, USER1, "Option rsa-modlen should be used only with "
- " optype: rsa.\n");
+ if (options->op_type == CPERF_ASYM_RSA) {
+ if (cperf_rsa_options_check(options) < 0) {
+ RTE_LOG(ERR, USER1, "Invalid RSA options\n");
return -EINVAL;
}
- if (options->rsa_keytype == RTE_RSA_KEY_TYPE_QT) {
- for (i = 0; i < (int)RTE_DIM(rsa_qt_perf_data); i++) {
- modlen = rsa_qt_perf_data[i].n.length * 8;
- if (options->rsa_modlen == modlen) {
- options->rsa_data =
- (struct cperf_rsa_test_data *)&rsa_qt_perf_data[i];
- break;
+ if (options->rsa_modlen) {
+ if (options->rsa_keytype == RTE_RSA_KEY_TYPE_QT) {
+ for (i = 0; i < (int)RTE_DIM(rsa_qt_perf_data); i++) {
+ modlen = rsa_qt_perf_data[i].n.length * 8;
+ if (options->rsa_modlen == modlen) {
+ options->rsa_data =
+ (struct cperf_rsa_test_data *)
+ &rsa_qt_perf_data[i];
+ break;
+ }
}
- }
- if (i == (int)RTE_DIM(rsa_qt_perf_data)) {
- RTE_LOG(ERR, USER1,
- "Option rsa_modlen: %d is not supported for QT private key\n",
- options->rsa_modlen);
+ if (i == (int)RTE_DIM(rsa_qt_perf_data)) {
+ RTE_LOG(ERR, USER1,
+ "Option rsa_modlen: %d is not supported for QT private key\n",
+ options->rsa_modlen);
return -EINVAL;
- }
- } else if (options->rsa_keytype == RTE_RSA_KEY_TYPE_EXP) {
- for (i = 0; i < (int)RTE_DIM(rsa_exp_perf_data); i++) {
- modlen = rsa_exp_perf_data[i].n.length * 8;
- if (options->rsa_modlen == modlen) {
- options->rsa_data =
- (struct cperf_rsa_test_data *)&rsa_exp_perf_data[i];
- break;
}
- }
+ } else if (options->rsa_keytype == RTE_RSA_KEY_TYPE_EXP) {
+ for (i = 0; i < (int)RTE_DIM(rsa_exp_perf_data); i++) {
+ modlen = rsa_exp_perf_data[i].n.length * 8;
+ if (options->rsa_modlen == modlen) {
+ options->rsa_data =
+ (struct cperf_rsa_test_data *)
+ &rsa_exp_perf_data[i];
+ break;
+ }
+ }
- if (i == (int)RTE_DIM(rsa_exp_perf_data)) {
- RTE_LOG(ERR, USER1,
- "Option rsa_modlen: %d is not supported for exponent private key\n",
- options->rsa_modlen);
+ if (i == (int)RTE_DIM(rsa_exp_perf_data)) {
+ RTE_LOG(ERR, USER1,
+ "Option rsa_modlen: %d is not supported for exponent private key\n",
+ options->rsa_modlen);
return -EINVAL;
- }
- } else {
- for (i = 0; i < (int)RTE_DIM(rsa_pub_perf_data); i++) {
- modlen = rsa_pub_perf_data[i].n.length * 8;
- if (options->rsa_modlen == modlen) {
- options->rsa_data =
- (struct cperf_rsa_test_data *)&rsa_pub_perf_data[i];
- break;
}
- }
+ } else {
+ for (i = 0; i < (int)RTE_DIM(rsa_pub_perf_data); i++) {
+ modlen = rsa_pub_perf_data[i].n.length * 8;
+ if (options->rsa_modlen == modlen) {
+ options->rsa_data =
+ (struct cperf_rsa_test_data *)
+ &rsa_pub_perf_data[i];
+ break;
+ }
+ }
- if (i == (int)RTE_DIM(rsa_pub_perf_data)) {
- RTE_LOG(ERR, USER1,
- "Option rsa_modlen: %d is not supported for public key\n",
- options->rsa_modlen);
+ if (i == (int)RTE_DIM(rsa_pub_perf_data)) {
+ RTE_LOG(ERR, USER1,
+ "Option rsa_modlen: %d is not supported for public key\n",
+ options->rsa_modlen);
return -EINVAL;
+ }
}
}
}
--
2.49.0
prev parent reply other threads:[~2025-08-21 5:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 5:24 [PATCH 0/2] app/test-crypto-perf: RSA modlen validation and asym ops fix Sucharitha Sarananaga
2025-08-21 5:24 ` [PATCH 1/2] app/test-crypto-perf: validate rsa modlen Sucharitha Sarananaga
2025-08-21 5:24 ` Sucharitha Sarananaga [this message]
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=20250821052440.3213146-3-ssarananaga@marvell.com \
--to=ssarananaga@marvell.com \
--cc=anoobj@marvell.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=kai.ji@intel.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).