Acked-by: Kai Ji <[email protected]>

________________________________
From: Sun Yuechi <[email protected]>
Sent: Monday, October 26, 2026 14:16
To: Ji, Kai <[email protected]>; Akhil Goyal <[email protected]>; Gowrishankar 
Muthukrishnan <[email protected]>
Cc: [email protected] <[email protected]>; Sun Yuechi <[email protected]>; 
[email protected] <[email protected]>
Subject: [PATCH] crypto/openssl: fix SM2 encryption output length

SM2 encryption passed a zero output length to EVP_PKEY_encrypt(),
which OpenSSL 3.6.3 and later reject as "buffer too small".
Query the required length first, as the RSA path does.

Fixes: 3b7d638fb11f ("crypto/openssl: support asymmetric SM2")
Cc: [email protected]
Signed-off-by: Sun Yuechi <[email protected]>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c 
b/drivers/crypto/openssl/rte_openssl_pmd.c
index 1b33470c8f..8791186fec 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -2791,6 +2791,10 @@ process_openssl_sm2_op_evp(struct rte_crypto_op *cop,
                         if (!EVP_PKEY_CTX_set_params(cctx, eparams))
                                 goto err_sm2;

+                       if (!EVP_PKEY_encrypt(cctx, NULL, &output_len,
+                                       op->sm2.message.data, 
op->sm2.message.length))
+                               goto err_sm2;
+
                         if (!EVP_PKEY_encrypt(cctx, op->sm2.cipher.data, 
&output_len,
                                                                  
op->sm2.message.data,
                                                                  
op->sm2.message.length))
--
2.56.0

Reply via email to