public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps
@ 2026-03-23 15:08 Emma Finn
  2026-03-23 15:08 ` [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison Emma Finn
  2026-03-24  7:08 ` [EXTERNAL] [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps Rupesh Chiluka
  0 siblings, 2 replies; 6+ messages in thread
From: Emma Finn @ 2026-03-23 15:08 UTC (permalink / raw)
  To: Akhil Goyal, Fan Zhang, Kai Ji, Rupesh Chiluka; +Cc: dev, Emma Finn

Fix asym tests to return TEST_SKIPPED when session
creation returns -ENOTSUP. Add missing ECDH, ECDSA and ECPM
capabilities to GEN4 asym caps table. Reject unsupported RSA
padding and EC curves at session configure time with -ENOTSUP.

Bugzilla ID: 1903
Fixes: 064ef1b098d1 ("test/crypto: remove PMD-specific asym test suites")

Signed-off-by: Emma Finn <emma.finn@intel.com>
---
 app/test/test_cryptodev_asym.c               | 38 ++++++++++++++++----
 drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c | 13 +++++++
 drivers/crypto/qat/qat_asym.c                | 10 ++++++
 3 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 793cc5dce6..1515372a35 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -318,6 +318,9 @@ test_rsa_sign_verify(void)
 error_exit:
 	rte_cryptodev_asym_session_free(dev_id, sess);
 
+	if (status == TEST_SKIPPED)
+		return status;
+
 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
 	return status;
@@ -368,6 +371,9 @@ test_rsa_enc_dec(void)
 
 	rte_cryptodev_asym_session_free(dev_id, sess);
 
+	if (status == TEST_SKIPPED)
+		return status;
+
 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
 	return status;
@@ -414,6 +420,9 @@ test_rsa_sign_verify_crt(void)
 
 	rte_cryptodev_asym_session_free(dev_id, sess);
 
+	if (status == TEST_SKIPPED)
+		return status;
+
 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
 	return status;
@@ -460,6 +469,9 @@ test_rsa_enc_dec_crt(void)
 
 	rte_cryptodev_asym_session_free(dev_id, sess);
 
+	if (status == TEST_SKIPPED)
+		return status;
+
 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
 	return status;
@@ -1712,6 +1724,8 @@ test_ecdsa_sign_verify_all_curve(void)
 		status = test_ecdsa_sign_verify(curve_id);
 		if (status == TEST_SUCCESS) {
 			msg = "succeeded";
+		} else if (status == TEST_SKIPPED) {
+			msg = "skipped";
 		} else {
 			msg = "failed";
 			overall_status = status;
@@ -1901,6 +1915,8 @@ test_ecpm_all_curve(void)
 		status = test_ecpm(curve_id);
 		if (status == TEST_SUCCESS) {
 			msg = "succeeded";
+		} else if (status == TEST_SKIPPED) {
+			msg = "skipped";
 		} else {
 			msg = "failed";
 			overall_status = status;
@@ -1956,10 +1972,10 @@ test_ecdh_priv_key_generate(enum curve curve_id)
 	idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
 	capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
 	if (capa == NULL)
-		return -ENOTSUP;
+		return TEST_SKIPPED;
 
 	if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_PRIV_KEY_GENERATE)))
-		return -ENOTSUP;
+		return TEST_SKIPPED;
 
 	switch (curve_id) {
 	case SECP192R1:
@@ -2269,10 +2285,10 @@ test_ecdh_pub_key_verify(enum curve curve_id)
 	idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
 	capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
 	if (capa == NULL)
-		return -ENOTSUP;
+		return TEST_SKIPPED;
 
 	if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY)))
-		return -ENOTSUP;
+		return TEST_SKIPPED;
 
 	switch (curve_id) {
 	case SECP192R1:
@@ -2408,10 +2424,10 @@ test_ecdh_shared_secret(enum curve curve_id)
 	idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
 	capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
 	if (capa == NULL)
-		return -ENOTSUP;
+		return TEST_SKIPPED;
 
 	if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE)))
-		return -ENOTSUP;
+		return TEST_SKIPPED;
 
 	switch (curve_id) {
 	case SECP192R1:
@@ -2668,6 +2684,8 @@ test_ecdh_all_curve(void)
 		status = test_ecdh_priv_key_generate(curve_id);
 		if (status == TEST_SUCCESS) {
 			msg = "succeeded";
+		} else if (status == TEST_SKIPPED) {
+			msg = "skipped";
 		} else {
 			msg = "failed";
 			overall_status = status;
@@ -2700,6 +2718,8 @@ test_ecdh_all_curve(void)
 		status = test_ecdh_pub_key_verify(curve_id);
 		if (status == TEST_SUCCESS) {
 			msg = "succeeded";
+		} else if (status == TEST_SKIPPED) {
+			msg = "skipped";
 		} else {
 			msg = "failed";
 			overall_status = status;
@@ -2715,6 +2735,8 @@ test_ecdh_all_curve(void)
 		status = test_ecdh_shared_secret(curve_id);
 		if (status == TEST_SUCCESS) {
 			msg = "succeeded";
+		} else if (status == TEST_SKIPPED) {
+			msg = "skipped";
 		} else {
 			msg = "failed";
 			overall_status = status;
@@ -2752,6 +2774,8 @@ test_ecdh_qat_curves(void)
 		status = test_ecdh_pub_key_verify(curve_id);
 		if (status == TEST_SUCCESS) {
 			msg = "succeeded";
+		} else if (status == TEST_SKIPPED) {
+			msg = "skipped";
 		} else {
 			msg = "failed";
 			overall_status = status;
@@ -2764,6 +2788,8 @@ test_ecdh_qat_curves(void)
 		status = test_ecdh_shared_secret(curve_id);
 		if (status == TEST_SUCCESS) {
 			msg = "succeeded";
+		} else if (status == TEST_SKIPPED) {
+			msg = "skipped";
 		} else {
 			msg = "failed";
 			overall_status = status;
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
index 82c5a40501..52577f6907 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
@@ -144,6 +144,19 @@ static struct rte_cryptodev_capabilities qat_asym_crypto_caps_gen4[] = {
 		}
 		}
 	},
+	QAT_ASYM_CAP(ECDH,
+			((1 << RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE) |
+			(1 << RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE) |
+			(1 << RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY)),
+			64, 512, 64),
+	QAT_ASYM_CAP(ECDSA,
+			((1 << RTE_CRYPTO_ASYM_OP_SIGN) |
+			(1 << RTE_CRYPTO_ASYM_OP_VERIFY)),
+			64, 512, 64),
+	QAT_ASYM_CAP(ECPM,
+			((1 << RTE_CRYPTO_ASYM_OP_SIGN) |
+			(1 << RTE_CRYPTO_ASYM_OP_VERIFY)),
+			64, 512, 64),
 	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
 
diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 06f037cc14..beb5a27805 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -1483,6 +1483,12 @@ static int
 session_set_ec(struct qat_asym_session *qat_session,
 			struct rte_crypto_asym_xform *xform)
 {
+	/* Validate curve for EC operations using pick_curve (not SM2) */
+	if (xform->xform_type != RTE_CRYPTO_ASYM_XFORM_SM2) {
+		if (pick_curve(xform) < 0)
+			return -ENOTSUP;
+	}
+
 	uint8_t *pkey = xform->ec.pkey.data;
 	uint8_t *q_x = xform->ec.q.x.data;
 	uint8_t *q_y = xform->ec.q.y.data;
@@ -1545,6 +1551,10 @@ qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
 		ret = session_set_modinv(qat_session, xform);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_RSA: {
+		if (xform->rsa.padding.type != RTE_CRYPTO_RSA_PADDING_NONE) {
+			ret = -ENOTSUP;
+			return ret;
+		}
 		if (unlikely((xform->rsa.n.length < RSA_MODULUS_2048_BITS)
 				&& (crypto_qat->qat_dev->options.legacy_alg == 0))) {
 			ret = -ENOTSUP;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison
  2026-03-23 15:08 [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps Emma Finn
@ 2026-03-23 15:08 ` Emma Finn
  2026-03-24  7:08   ` [EXTERNAL] " Rupesh Chiluka
  2026-03-24  7:08 ` [EXTERNAL] [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps Rupesh Chiluka
  1 sibling, 1 reply; 6+ messages in thread
From: Emma Finn @ 2026-03-23 15:08 UTC (permalink / raw)
  To: Akhil Goyal, Fan Zhang, Kai Ji, Rupesh Chiluka; +Cc: dev, Emma Finn

QAT HW rounds the output buffer size up to the next supported size,
but result.length was set to alg_bytesize instead of n.length, causing
result comparisons to read past the end of the expected value.

Additionally, when a modulus has a leading zero padding byte, QAT HW
strips it from the result but we never strip it from the expected result,
so the compare fails. Fix verify_modexp() and verify_modinv() to skip
leading zero bytes in the result before comparison.

Fixes: 064ef1b098d1 ("test/crypto: remove PMD-specific asym test suites")

Signed-off-by: Emma Finn <emma.finn@intel.com>
---
 app/test/test_cryptodev_asym.c      |  8 ++++++++
 app/test/test_cryptodev_asym_util.h | 20 ++++++++++++++++----
 drivers/crypto/qat/qat_asym.c       |  7 +++----
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 1515372a35..07e5eb5842 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -3826,6 +3826,14 @@ modular_exponentiation(const void *test_data)
 	uint8_t result[TEST_DATA_SIZE] = { 0 };
 	struct rte_crypto_asym_xform xform = { };
 	const uint8_t dev_id = params->valid_devs[0];
+	const struct rte_cryptodev_asymmetric_xform_capability *cap;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+
+	cap_idx.type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+	cap = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
+	if (cap == NULL || rte_cryptodev_asym_xform_capability_check_modlen(
+			cap, vector->modulus.len))
+		return TEST_SKIPPED;
 
 	memcpy(input, vector->base.data, vector->base.len);
 	memcpy(exponent, vector->exponent.data, vector->exponent.len);
diff --git a/app/test/test_cryptodev_asym_util.h b/app/test/test_cryptodev_asym_util.h
index 07e6e831e8..16e4c0da6c 100644
--- a/app/test/test_cryptodev_asym_util.h
+++ b/app/test/test_cryptodev_asym_util.h
@@ -20,8 +20,14 @@ static inline int rsa_verify(struct rsa_test_data *rsa_param,
 static inline int verify_modinv(uint8_t *mod_inv,
 		struct rte_crypto_op *result_op)
 {
-	if (memcmp(mod_inv, result_op->asym->modinv.result.data,
-				result_op->asym->modinv.result.length))
+	const uint8_t *b = result_op->asym->modinv.result.data;
+	size_t b_len = result_op->asym->modinv.result.length;
+
+	while (b_len > 1 && b[0] == 0) {
+		b++;
+		b_len--;
+	}
+	if (memcmp(mod_inv, b, b_len))
 		return -1;
 	return 0;
 }
@@ -29,8 +35,14 @@ static inline int verify_modinv(uint8_t *mod_inv,
 static inline int verify_modexp(uint8_t *mod_exp,
 		struct rte_crypto_op *result_op)
 {
-	if (memcmp(mod_exp, result_op->asym->modex.result.data,
-				result_op->asym->modex.result.length))
+	const uint8_t *b = result_op->asym->modex.result.data;
+	size_t b_len = result_op->asym->modex.result.length;
+
+	while (b_len > 1 && b[0] == 0) {
+		b++;
+		b_len--;
+	}
+	if (memcmp(mod_exp, b, b_len))
 		return -1;
 	return 0;
 }
diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index beb5a27805..7a296cad6c 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -274,7 +274,7 @@ modexp_collect(struct rte_crypto_asym_op *asym_op,
 	rte_memcpy(modexp_result,
 		cookie->output_array[0] + alg_bytesize
 		- n.length, n.length);
-	asym_op->modex.result.length = alg_bytesize;
+	asym_op->modex.result.length = n.length;
 	HEXDUMP("ModExp result", cookie->output_array[0],
 			alg_bytesize);
 	return RTE_CRYPTO_OP_STATUS_SUCCESS;
@@ -332,11 +332,10 @@ modinv_collect(struct rte_crypto_asym_op *asym_op,
 		QAT_LOG(ERR, "Incorrect length of modinv modulus");
 		return RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 	}
-	rte_memcpy(modinv_result + (asym_op->modinv.result.length
-		- n.length),
+	rte_memcpy(modinv_result,
 		cookie->output_array[0] + alg_bytesize
 		- n.length, n.length);
-	asym_op->modinv.result.length = alg_bytesize;
+	asym_op->modinv.result.length = n.length;
 	HEXDUMP("ModInv result", cookie->output_array[0],
 			alg_bytesize);
 	return RTE_CRYPTO_OP_STATUS_SUCCESS;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [EXTERNAL] [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps
  2026-03-23 15:08 [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps Emma Finn
  2026-03-23 15:08 ` [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison Emma Finn
@ 2026-03-24  7:08 ` Rupesh Chiluka
  2026-03-24  9:29   ` Akhil Goyal
  1 sibling, 1 reply; 6+ messages in thread
From: Rupesh Chiluka @ 2026-03-24  7:08 UTC (permalink / raw)
  To: Emma Finn, Akhil Goyal, Fan Zhang, Kai Ji; +Cc: dev@dpdk.org

[-- Attachment #1: Type: text/plain, Size: 9809 bytes --]

Acked-by: Rupesh Chiluka <r<mailto:your.email@example.com>chiluka@marvell.com<mailto:chiluka@marvell.com>>
________________________________
From: Emma Finn <emma.finn@intel.com>
Sent: Monday, March 23, 2026 20:38
To: Akhil Goyal <gakhil@marvell.com>; Fan Zhang <fanzhang.oss@gmail.com>; Kai Ji <kai.ji@intel.com>; Rupesh Chiluka <rchiluka@marvell.com>
Cc: dev@dpdk.org <dev@dpdk.org>; Emma Finn <emma.finn@intel.com>
Subject: [EXTERNAL] [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps

Fix asym tests to return TEST_SKIPPED when session creation returns -ENOTSUP. Add missing ECDH, ECDSA and ECPM capabilities to GEN4 asym caps table. Reject unsupported RSA padding and EC curves at session configure time with -ENOTSUP. Bugzilla
ZjQcmQRYFpfptBannerStart
Prioritize security for external emails:
Confirm sender and content safety before clicking links or opening attachments
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/CRVmXkqW!te3Z1f8UYnW6tG-cGdxazuubvGPgl6yTU24HHC1z9RV5wPQjtl7qP0oEMSmeVZTwYYHqm4_Boxty5bBSBE8DJtAeSS0s7DY$>
Report Suspicious

ZjQcmQRYFpfptBannerEnd

Fix asym tests to return TEST_SKIPPED when session
creation returns -ENOTSUP. Add missing ECDH, ECDSA and ECPM
capabilities to GEN4 asym caps table. Reject unsupported RSA
padding and EC curves at session configure time with -ENOTSUP.

Bugzilla ID: 1903
Fixes: 064ef1b098d1 ("test/crypto: remove PMD-specific asym test suites")

Signed-off-by: Emma Finn <emma.finn@intel.com>
---
 app/test/test_cryptodev_asym.c               | 38 ++++++++++++++++----
 drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c | 13 +++++++
 drivers/crypto/qat/qat_asym.c                | 10 ++++++
 3 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 793cc5dce6..1515372a35 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -318,6 +318,9 @@ test_rsa_sign_verify(void)
 error_exit:
        rte_cryptodev_asym_session_free(dev_id, sess);

+       if (status == TEST_SKIPPED)
+               return status;
+
        TEST_ASSERT_EQUAL(status, 0, "Test failed");

        return status;
@@ -368,6 +371,9 @@ test_rsa_enc_dec(void)

        rte_cryptodev_asym_session_free(dev_id, sess);

+       if (status == TEST_SKIPPED)
+               return status;
+
        TEST_ASSERT_EQUAL(status, 0, "Test failed");

        return status;
@@ -414,6 +420,9 @@ test_rsa_sign_verify_crt(void)

        rte_cryptodev_asym_session_free(dev_id, sess);

+       if (status == TEST_SKIPPED)
+               return status;
+
        TEST_ASSERT_EQUAL(status, 0, "Test failed");

        return status;
@@ -460,6 +469,9 @@ test_rsa_enc_dec_crt(void)

        rte_cryptodev_asym_session_free(dev_id, sess);

+       if (status == TEST_SKIPPED)
+               return status;
+
        TEST_ASSERT_EQUAL(status, 0, "Test failed");

        return status;
@@ -1712,6 +1724,8 @@ test_ecdsa_sign_verify_all_curve(void)
                status = test_ecdsa_sign_verify(curve_id);
                if (status == TEST_SUCCESS) {
                        msg = "succeeded";
+               } else if (status == TEST_SKIPPED) {
+                       msg = "skipped";
                } else {
                        msg = "failed";
                        overall_status = status;
@@ -1901,6 +1915,8 @@ test_ecpm_all_curve(void)
                status = test_ecpm(curve_id);
                if (status == TEST_SUCCESS) {
                        msg = "succeeded";
+               } else if (status == TEST_SKIPPED) {
+                       msg = "skipped";
                } else {
                        msg = "failed";
                        overall_status = status;
@@ -1956,10 +1972,10 @@ test_ecdh_priv_key_generate(enum curve curve_id)
        idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
        capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
        if (capa == NULL)
-               return -ENOTSUP;
+               return TEST_SKIPPED;

        if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_PRIV_KEY_GENERATE)))
-               return -ENOTSUP;
+               return TEST_SKIPPED;

        switch (curve_id) {
        case SECP192R1:
@@ -2269,10 +2285,10 @@ test_ecdh_pub_key_verify(enum curve curve_id)
        idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
        capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
        if (capa == NULL)
-               return -ENOTSUP;
+               return TEST_SKIPPED;

        if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY)))
-               return -ENOTSUP;
+               return TEST_SKIPPED;

        switch (curve_id) {
        case SECP192R1:
@@ -2408,10 +2424,10 @@ test_ecdh_shared_secret(enum curve curve_id)
        idx.type = RTE_CRYPTO_ASYM_XFORM_ECDH;
        capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
        if (capa == NULL)
-               return -ENOTSUP;
+               return TEST_SKIPPED;

        if (!(capa->op_types & (1 <<  RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE)))
-               return -ENOTSUP;
+               return TEST_SKIPPED;

        switch (curve_id) {
        case SECP192R1:
@@ -2668,6 +2684,8 @@ test_ecdh_all_curve(void)
                status = test_ecdh_priv_key_generate(curve_id);
                if (status == TEST_SUCCESS) {
                        msg = "succeeded";
+               } else if (status == TEST_SKIPPED) {
+                       msg = "skipped";
                } else {
                        msg = "failed";
                        overall_status = status;
@@ -2700,6 +2718,8 @@ test_ecdh_all_curve(void)
                status = test_ecdh_pub_key_verify(curve_id);
                if (status == TEST_SUCCESS) {
                        msg = "succeeded";
+               } else if (status == TEST_SKIPPED) {
+                       msg = "skipped";
                } else {
                        msg = "failed";
                        overall_status = status;
@@ -2715,6 +2735,8 @@ test_ecdh_all_curve(void)
                status = test_ecdh_shared_secret(curve_id);
                if (status == TEST_SUCCESS) {
                        msg = "succeeded";
+               } else if (status == TEST_SKIPPED) {
+                       msg = "skipped";
                } else {
                        msg = "failed";
                        overall_status = status;
@@ -2752,6 +2774,8 @@ test_ecdh_qat_curves(void)
                status = test_ecdh_pub_key_verify(curve_id);
                if (status == TEST_SUCCESS) {
                        msg = "succeeded";
+               } else if (status == TEST_SKIPPED) {
+                       msg = "skipped";
                } else {
                        msg = "failed";
                        overall_status = status;
@@ -2764,6 +2788,8 @@ test_ecdh_qat_curves(void)
                status = test_ecdh_shared_secret(curve_id);
                if (status == TEST_SUCCESS) {
                        msg = "succeeded";
+               } else if (status == TEST_SKIPPED) {
+                       msg = "skipped";
                } else {
                        msg = "failed";
                        overall_status = status;
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
index 82c5a40501..52577f6907 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
@@ -144,6 +144,19 @@ static struct rte_cryptodev_capabilities qat_asym_crypto_caps_gen4[] = {
                }
                }
        },
+       QAT_ASYM_CAP(ECDH,
+                       ((1 << RTE_CRYPTO_ASYM_KE_PUB_KEY_GENERATE) |
+                       (1 << RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE) |
+                       (1 << RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY)),
+                       64, 512, 64),
+       QAT_ASYM_CAP(ECDSA,
+                       ((1 << RTE_CRYPTO_ASYM_OP_SIGN) |
+                       (1 << RTE_CRYPTO_ASYM_OP_VERIFY)),
+                       64, 512, 64),
+       QAT_ASYM_CAP(ECPM,
+                       ((1 << RTE_CRYPTO_ASYM_OP_SIGN) |
+                       (1 << RTE_CRYPTO_ASYM_OP_VERIFY)),
+                       64, 512, 64),
        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };

diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 06f037cc14..beb5a27805 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -1483,6 +1483,12 @@ static int
 session_set_ec(struct qat_asym_session *qat_session,
                        struct rte_crypto_asym_xform *xform)
 {
+       /* Validate curve for EC operations using pick_curve (not SM2) */
+       if (xform->xform_type != RTE_CRYPTO_ASYM_XFORM_SM2) {
+               if (pick_curve(xform) < 0)
+                       return -ENOTSUP;
+       }
+
        uint8_t *pkey = xform->ec.pkey.data;
        uint8_t *q_x = xform->ec.q.x.data;
        uint8_t *q_y = xform->ec.q.y.data;
@@ -1545,6 +1551,10 @@ qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
                ret = session_set_modinv(qat_session, xform);
                break;
        case RTE_CRYPTO_ASYM_XFORM_RSA: {
+               if (xform->rsa.padding.type != RTE_CRYPTO_RSA_PADDING_NONE) {
+                       ret = -ENOTSUP;
+                       return ret;
+               }
                if (unlikely((xform->rsa.n.length < RSA_MODULUS_2048_BITS)
                                && (crypto_qat->qat_dev->options.legacy_alg == 0))) {
                        ret = -ENOTSUP;
--
2.43.0



[-- Attachment #2: Type: text/html, Size: 12713 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [EXTERNAL] [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison
  2026-03-23 15:08 ` [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison Emma Finn
@ 2026-03-24  7:08   ` Rupesh Chiluka
  2026-03-24  9:29     ` Akhil Goyal
  0 siblings, 1 reply; 6+ messages in thread
From: Rupesh Chiluka @ 2026-03-24  7:08 UTC (permalink / raw)
  To: Emma Finn, Akhil Goyal, Fan Zhang, Kai Ji; +Cc: dev@dpdk.org

[-- Attachment #1: Type: text/plain, Size: 5768 bytes --]

Acked-by: Rupesh Chiluka <r<mailto:your.email@example.com>chiluka@marvell.com<mailto:chiluka@marvell.com>>
________________________________
From: Emma Finn <emma.finn@intel.com>
Sent: Monday, March 23, 2026 20:38
To: Akhil Goyal <gakhil@marvell.com>; Fan Zhang <fanzhang.oss@gmail.com>; Kai Ji <kai.ji@intel.com>; Rupesh Chiluka <rchiluka@marvell.com>
Cc: dev@dpdk.org <dev@dpdk.org>; Emma Finn <emma.finn@intel.com>
Subject: [EXTERNAL] [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison

QAT HW rounds the output buffer size up to the next supported size, but result. length was set to alg_bytesize instead of n. length, causing result comparisons to read past the end of the expected value. Additionally, when a modulus has a leading
ZjQcmQRYFpfptBannerStart
Prioritize security for external emails:
Confirm sender and content safety before clicking links or opening attachments
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/CRVmXkqW!te3Z1f8UYnW6tG-cGdxazuubvGPgl6yTU25nHC1z9RXK4YEidjaGpjsKME98FEQ50hB_lPsKuSS8cG6Y0i77JxgNu0tFoG0$>
Report Suspicious

ZjQcmQRYFpfptBannerEnd

QAT HW rounds the output buffer size up to the next supported size,
but result.length was set to alg_bytesize instead of n.length, causing
result comparisons to read past the end of the expected value.

Additionally, when a modulus has a leading zero padding byte, QAT HW
strips it from the result but we never strip it from the expected result,
so the compare fails. Fix verify_modexp() and verify_modinv() to skip
leading zero bytes in the result before comparison.

Fixes: 064ef1b098d1 ("test/crypto: remove PMD-specific asym test suites")

Signed-off-by: Emma Finn <emma.finn@intel.com>
---
 app/test/test_cryptodev_asym.c      |  8 ++++++++
 app/test/test_cryptodev_asym_util.h | 20 ++++++++++++++++----
 drivers/crypto/qat/qat_asym.c       |  7 +++----
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 1515372a35..07e5eb5842 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -3826,6 +3826,14 @@ modular_exponentiation(const void *test_data)
        uint8_t result[TEST_DATA_SIZE] = { 0 };
        struct rte_crypto_asym_xform xform = { };
        const uint8_t dev_id = params->valid_devs[0];
+       const struct rte_cryptodev_asymmetric_xform_capability *cap;
+       struct rte_cryptodev_asym_capability_idx cap_idx;
+
+       cap_idx.type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+       cap = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
+       if (cap == NULL || rte_cryptodev_asym_xform_capability_check_modlen(
+                       cap, vector->modulus.len))
+               return TEST_SKIPPED;

        memcpy(input, vector->base.data, vector->base.len);
        memcpy(exponent, vector->exponent.data, vector->exponent.len);
diff --git a/app/test/test_cryptodev_asym_util.h b/app/test/test_cryptodev_asym_util.h
index 07e6e831e8..16e4c0da6c 100644
--- a/app/test/test_cryptodev_asym_util.h
+++ b/app/test/test_cryptodev_asym_util.h
@@ -20,8 +20,14 @@ static inline int rsa_verify(struct rsa_test_data *rsa_param,
 static inline int verify_modinv(uint8_t *mod_inv,
                struct rte_crypto_op *result_op)
 {
-       if (memcmp(mod_inv, result_op->asym->modinv.result.data,
-                               result_op->asym->modinv.result.length))
+       const uint8_t *b = result_op->asym->modinv.result.data;
+       size_t b_len = result_op->asym->modinv.result.length;
+
+       while (b_len > 1 && b[0] == 0) {
+               b++;
+               b_len--;
+       }
+       if (memcmp(mod_inv, b, b_len))
                return -1;
        return 0;
 }
@@ -29,8 +35,14 @@ static inline int verify_modinv(uint8_t *mod_inv,
 static inline int verify_modexp(uint8_t *mod_exp,
                struct rte_crypto_op *result_op)
 {
-       if (memcmp(mod_exp, result_op->asym->modex.result.data,
-                               result_op->asym->modex.result.length))
+       const uint8_t *b = result_op->asym->modex.result.data;
+       size_t b_len = result_op->asym->modex.result.length;
+
+       while (b_len > 1 && b[0] == 0) {
+               b++;
+               b_len--;
+       }
+       if (memcmp(mod_exp, b, b_len))
                return -1;
        return 0;
 }
diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index beb5a27805..7a296cad6c 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -274,7 +274,7 @@ modexp_collect(struct rte_crypto_asym_op *asym_op,
        rte_memcpy(modexp_result,
                cookie->output_array[0] + alg_bytesize
                - n.length, n.length);
-       asym_op->modex.result.length = alg_bytesize;
+       asym_op->modex.result.length = n.length;
        HEXDUMP("ModExp result", cookie->output_array[0],
                        alg_bytesize);
        return RTE_CRYPTO_OP_STATUS_SUCCESS;
@@ -332,11 +332,10 @@ modinv_collect(struct rte_crypto_asym_op *asym_op,
                QAT_LOG(ERR, "Incorrect length of modinv modulus");
                return RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
        }
-       rte_memcpy(modinv_result + (asym_op->modinv.result.length
-               - n.length),
+       rte_memcpy(modinv_result,
                cookie->output_array[0] + alg_bytesize
                - n.length, n.length);
-       asym_op->modinv.result.length = alg_bytesize;
+       asym_op->modinv.result.length = n.length;
        HEXDUMP("ModInv result", cookie->output_array[0],
                        alg_bytesize);
        return RTE_CRYPTO_OP_STATUS_SUCCESS;
--
2.43.0



[-- Attachment #2: Type: text/html, Size: 9721 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [EXTERNAL] [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison
  2026-03-24  7:08   ` [EXTERNAL] " Rupesh Chiluka
@ 2026-03-24  9:29     ` Akhil Goyal
  0 siblings, 0 replies; 6+ messages in thread
From: Akhil Goyal @ 2026-03-24  9:29 UTC (permalink / raw)
  To: Rupesh Chiluka, Emma Finn, Fan Zhang, Kai Ji; +Cc: dev@dpdk.org

> QAT HW rounds the output buffer size up to the next supported size,
> but result.length was set to alg_bytesize instead of n.length, causing
> result comparisons to read past the end of the expected value.
> 
> Additionally, when a modulus has a leading zero padding byte, QAT HW
> strips it from the result but we never strip it from the expected result,
> so the compare fails. Fix verify_modexp() and verify_modinv() to skip
> leading zero bytes in the result before comparison.
> 
> Fixes: 064ef1b098d1 ("test/crypto: remove PMD-specific asym test suites")
> 
> Signed-off-by: Emma Finn <emma.finn@intel.com>
Applied to dpdk-next-crypto
Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [EXTERNAL] [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps
  2026-03-24  7:08 ` [EXTERNAL] [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps Rupesh Chiluka
@ 2026-03-24  9:29   ` Akhil Goyal
  0 siblings, 0 replies; 6+ messages in thread
From: Akhil Goyal @ 2026-03-24  9:29 UTC (permalink / raw)
  To: Rupesh Chiluka, Emma Finn, Fan Zhang, Kai Ji; +Cc: dev@dpdk.org

> Fix asym tests to return TEST_SKIPPED when session
> creation returns -ENOTSUP. Add missing ECDH, ECDSA and ECPM
> capabilities to GEN4 asym caps table. Reject unsupported RSA
> padding and EC curves at session configure time with -ENOTSUP.
> 
> Bugzilla ID: 1903
> Fixes: 064ef1b098d1 ("test/crypto: remove PMD-specific asym test suites")
> 
> Signed-off-by: Emma Finn <emma.finn@intel.com>
Applied to dpdk-next-crypto
Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-24  9:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 15:08 [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps Emma Finn
2026-03-23 15:08 ` [PATCH 2/2] crypto/qat: fix modexp and modinv result length and comparison Emma Finn
2026-03-24  7:08   ` [EXTERNAL] " Rupesh Chiluka
2026-03-24  9:29     ` Akhil Goyal
2026-03-24  7:08 ` [EXTERNAL] [PATCH 1/2] crypto/qat: fix asym session validation and gen4 EC caps Rupesh Chiluka
2026-03-24  9:29   ` Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox