From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: <dev@dpdk.org>, Akhil Goyal <gakhil@marvell.com>,
Fan Zhang <fanzhang.oss@gmail.com>,
Shally Verma <shallyv@marvell.com>,
Ayuj Verma <ayverma@marvell.com>,
Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>,
Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>
Cc: <anoobj@marvell.com>,
Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>,
<stable@dpdk.org>
Subject: [PATCH 2/3] test/crypto: fix RSA test vector as per RFC 8017
Date: Fri, 20 Jun 2025 13:49:17 +0530 [thread overview]
Message-ID: <20250620081921.2145-2-gmuthukrishn@marvell.com> (raw)
In-Reply-To: <20250620081921.2145-1-gmuthukrishn@marvell.com>
As per RFC 8017 (A.1.2), RSA private key should be represented
with both exponent and CRT forms of data for inter operability.
Fixes: a379799cbaaf ("test/crypto: add RSA key type CRT")
Cc: stable@dpdk.org
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
app/test/test_cryptodev_asym.c | 16 ++++++++---
app/test/test_cryptodev_rsa_test_vectors.h | 32 +++++-----------------
2 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index fcaf73aa1a..a5f3eae41d 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -260,6 +260,7 @@ test_rsa_sign_verify(void)
struct rte_mempool *sess_mpool = ts_params->session_mpool;
struct rte_cryptodev_asym_capability_idx idx;
uint8_t dev_id = ts_params->valid_devs[0];
+ struct rte_crypto_asym_xform xform;
void *sess = NULL;
struct rte_cryptodev_info dev_info;
int ret, status = TEST_SUCCESS;
@@ -280,7 +281,10 @@ test_rsa_sign_verify(void)
return TEST_SKIPPED;
}
- ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
+ memcpy(&xform, &rsa_xform, sizeof(rsa_xform));
+ xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+
+ ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
if (ret < 0) {
RTE_LOG(ERR, USER1, "Session creation failed for "
@@ -306,6 +310,7 @@ test_rsa_enc_dec(void)
struct rte_mempool *sess_mpool = ts_params->session_mpool;
struct rte_cryptodev_asym_capability_idx idx;
uint8_t dev_id = ts_params->valid_devs[0];
+ struct rte_crypto_asym_xform xform;
void *sess = NULL;
struct rte_cryptodev_info dev_info;
int ret, status = TEST_SUCCESS;
@@ -326,7 +331,10 @@ test_rsa_enc_dec(void)
return TEST_SKIPPED;
}
- ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
+ memcpy(&xform, &rsa_xform, sizeof(rsa_xform));
+ xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP;
+
+ ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
if (ret < 0) {
RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n");
@@ -371,7 +379,7 @@ test_rsa_sign_verify_crt(void)
return TEST_SKIPPED;
}
- ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform_crt, sess_mpool, &sess);
+ ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
if (ret < 0) {
RTE_LOG(ERR, USER1, "Session creation failed for "
@@ -417,7 +425,7 @@ test_rsa_enc_dec_crt(void)
return TEST_SKIPPED;
}
- ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform_crt, sess_mpool, &sess);
+ ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
if (ret < 0) {
RTE_LOG(ERR, USER1, "Session creation failed for "
diff --git a/app/test/test_cryptodev_rsa_test_vectors.h b/app/test/test_cryptodev_rsa_test_vectors.h
index 1b7b451387..9652b0d43a 100644
--- a/app/test/test_cryptodev_rsa_test_vectors.h
+++ b/app/test/test_cryptodev_rsa_test_vectors.h
@@ -340,7 +340,7 @@ uint8_t rsa_qInv[] = {
0x71, 0x94, 0xdd, 0xa0, 0xf5, 0x1e, 0x6d, 0xcc
};
-/** rsa xform using exponent key */
+/** rsa xform (of QT private key type by default) */
struct rte_crypto_asym_xform rsa_xform = {
.next = NULL,
.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
@@ -354,29 +354,6 @@ struct rte_crypto_asym_xform rsa_xform = {
.data = rsa_e,
.length = sizeof(rsa_e)
},
- .key_type = RTE_RSA_KEY_TYPE_EXP,
- .d = {
- .data = rsa_d,
- .length = sizeof(rsa_d)
- }
- }
-};
-
-/** rsa xform using quintuple key */
-struct rte_crypto_asym_xform rsa_xform_crt = {
- .next = NULL,
- .xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
- .rsa = {
- .padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5,
- .n = {
- .data = rsa_n,
- .length = sizeof(rsa_n)
- },
- .e = {
- .data = rsa_e,
- .length = sizeof(rsa_e)
- },
- .key_type = RTE_RSA_KEY_TYPE_QT,
.qt = {
.p = {
.data = rsa_p,
@@ -398,7 +375,12 @@ struct rte_crypto_asym_xform rsa_xform_crt = {
.data = rsa_qInv,
.length = sizeof(rsa_qInv)
},
- }
+ },
+ .d = {
+ .data = rsa_d,
+ .length = sizeof(rsa_d)
+ },
+ .key_type = RTE_RSA_KEY_TYPE_QT
}
};
--
2.25.1
next prev parent reply other threads:[~2025-06-20 8:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 8:19 [PATCH 1/3] crypto/openssl: include private exponent in RSA session Gowrishankar Muthukrishnan
2025-06-20 8:19 ` Gowrishankar Muthukrishnan [this message]
2025-06-20 8:19 ` [PATCH 3/3] test/crypto: fix RSA decrypt op validation Gowrishankar Muthukrishnan
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=20250620081921.2145-2-gmuthukrishn@marvell.com \
--to=gmuthukrishn@marvell.com \
--cc=anoobj@marvell.com \
--cc=arkadiuszx.kusztal@intel.com \
--cc=ayverma@marvell.com \
--cc=dev@dpdk.org \
--cc=fanzhang.oss@gmail.com \
--cc=gakhil@marvell.com \
--cc=kkotamarthy@marvell.com \
--cc=shallyv@marvell.com \
--cc=stable@dpdk.org \
/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).