From: Kai Ji <kai.ji@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, thomas@monjalon.net, Kai Ji <kai.ji@intel.com>
Subject: [dpdk-dev v2] crypto/openssl: EVP_PKEY routine update in rsa op
Date: Tue, 5 Jul 2022 21:16:25 +0800 [thread overview]
Message-ID: <20220705131625.40665-1-kai.ji@intel.com> (raw)
In-Reply-To: <20220630103848.36515-1-kai.ji@intel.com>
EVP_PKEY function need to be called twice for rsa sign and verify
operations in 3.0 EVP API, original openssl 1.x routines are
untouched. The OPENSSL_API_COMPAT also removed as this branch code
will be executed when Openssl 3.0 lib is detected on the host.
Fixes: d7bd42f6db19 ("crypto/openssl: update RSA routine with 3.0 EVP API")
Signed-off-by: Kai Ji <kai.ji@intel.com>
---
drivers/crypto/openssl/rte_openssl_pmd.c | 32 ++++++++++++++------
drivers/crypto/openssl/rte_openssl_pmd_ops.c | 2 --
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 84bca86894..e01dacc98d 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1788,7 +1788,7 @@ process_openssl_dsa_sign_op_evp(struct rte_crypto_op *cop,
if (key_ctx == NULL
|| EVP_PKEY_fromdata_init(key_ctx) <= 0
|| EVP_PKEY_fromdata(key_ctx, &pkey,
- EVP_PKEY_PUBLIC_KEY, params) <= 0)
+ EVP_PKEY_KEYPAIR, params) <= 0)
goto err_dsa_sign;
dsa_ctx = EVP_PKEY_CTX_new(pkey, NULL);
@@ -2478,6 +2478,14 @@ process_openssl_rsa_op_evp(struct rte_crypto_op *cop,
if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
goto err_rsa;
+ if (EVP_PKEY_sign(rsa_ctx, NULL, &outlen,
+ op->rsa.message.data,
+ op->rsa.message.length) <= 0)
+ goto err_rsa;
+
+ if (outlen <= 0)
+ goto err_rsa;
+
if (EVP_PKEY_sign(rsa_ctx, op->rsa.sign.data, &outlen,
op->rsa.message.data,
op->rsa.message.length) <= 0)
@@ -2486,19 +2494,23 @@ process_openssl_rsa_op_evp(struct rte_crypto_op *cop,
break;
case RTE_CRYPTO_ASYM_OP_VERIFY:
- tmp = rte_malloc(NULL, op->rsa.sign.length, 0);
- if (tmp == NULL) {
- OPENSSL_LOG(ERR, "Memory allocation failed");
+ if (EVP_PKEY_verify_recover_init(rsa_ctx) <= 0)
goto err_rsa;
- }
- if (EVP_PKEY_verify_recover_init(rsa_ctx) <= 0) {
- rte_free(tmp);
+ if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
goto err_rsa;
- }
- if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0) {
- rte_free(tmp);
+ if (EVP_PKEY_verify_recover(rsa_ctx, NULL, &outlen,
+ op->rsa.sign.data,
+ op->rsa.sign.length) <= 0)
+ goto err_rsa;
+
+ if ((outlen <= 0) || (outlen != op->rsa.sign.length))
+ goto err_rsa;
+
+ tmp = OPENSSL_malloc(outlen);
+ if (tmp == NULL) {
+ OPENSSL_LOG(ERR, "Memory allocation failed");
goto err_rsa;
}
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 8d1f8e834a..3e24ef94f7 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -2,8 +2,6 @@
* Copyright(c) 2016-2017 Intel Corporation
*/
-#define OPENSSL_API_COMPAT 0x10100000L
-
#include <string.h>
#include <rte_common.h>
--
2.17.1
next prev parent reply other threads:[~2022-07-05 13:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 10:38 [dpdk-dev v1] " Kai Ji
2022-07-01 19:14 ` [EXT] " Akhil Goyal
2022-07-04 19:45 ` Thomas Monjalon
2022-07-05 10:43 ` Ji, Kai
2022-07-05 10:55 ` Thomas Monjalon
2022-07-05 13:16 ` Kai Ji [this message]
2022-07-05 16:33 ` [EXT] [dpdk-dev v2] " Akhil Goyal
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=20220705131625.40665-1-kai.ji@intel.com \
--to=kai.ji@intel.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=thomas@monjalon.net \
/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).