[PATCH] app/test-crypto-perf: validate rsa modlen

Sucharitha Sarananaga ssarananaga at marvell.com
Wed Aug 20 20:36:41 CEST 2025


Added a check to verify that user configured modlen supported
or not.

Signed-off-by: Sucharitha Sarananaga <ssarananaga at marvell.com>
---
 app/test-crypto-perf/cperf_options_parsing.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index 0e0dc4fd06..0c7c57ce42 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -1361,6 +1361,7 @@ is_valid_chained_op(struct cperf_options *options)
 int
 cperf_options_check(struct cperf_options *options)
 {
+	uint16_t modlen;
 	int i;
 
 	if (options->op_type == CPERF_CIPHER_ONLY ||
@@ -1557,8 +1558,6 @@ cperf_options_check(struct cperf_options *options)
 	}
 
 	if (options->rsa_modlen) {
-		uint16_t modlen = options->rsa_modlen / 8;
-
 		if (options->op_type != CPERF_ASYM_RSA) {
 			RTE_LOG(ERR, USER1, "Option rsa-modlen should be used only with "
 					" optype: rsa.\n");
@@ -1567,7 +1566,8 @@ cperf_options_check(struct cperf_options *options)
 
 		if (options->rsa_keytype == RTE_RSA_KEY_TYPE_QT) {
 			for (i = 0; i < (int)RTE_DIM(rsa_qt_perf_data); i++) {
-				if (rsa_qt_perf_data[i].n.length == modlen) {
+				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;
@@ -1582,7 +1582,8 @@ cperf_options_check(struct cperf_options *options)
 			}
 		} else if (options->rsa_keytype == RTE_RSA_KEY_TYPE_EXP) {
 			for (i = 0; i < (int)RTE_DIM(rsa_exp_perf_data); i++) {
-				if (rsa_exp_perf_data[i].n.length == modlen) {
+				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;
@@ -1597,7 +1598,8 @@ cperf_options_check(struct cperf_options *options)
 			}
 		} else {
 			for (i = 0; i < (int)RTE_DIM(rsa_pub_perf_data); i++) {
-				if (rsa_pub_perf_data[i].n.length == modlen) {
+				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;
-- 
2.49.0



More information about the dev mailing list