From: Kai Ji <kai.ji@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, Kai Ji <kai.ji@intel.com>
Subject: [dpdk-dev v1] crypto/qat: Enable OpenSSL legacy provider in session
Date: Tue, 12 Jul 2022 01:08:22 +0800 [thread overview]
Message-ID: <20220711170822.60795-1-kai.ji@intel.com> (raw)
Some cryptographic algorithms such as MD and DES are now considered legacy
and not enabled by default in OpenSSL 3.0. Load up lagacy provider as MD5
DES are needed in QAT session pre-computes and secure session creation.
Fixes: 3227bc7138f5 ("crypto/qat: use intel-ipsec-mb for partial hash and AES")
Signed-off-by: Kai Ji <kai.ji@intel.com>
---
drivers/crypto/qat/qat_sym_session.c | 53 ++++++++++++++++++++--------
1 file changed, 39 insertions(+), 14 deletions(-)
diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
index b30396487e..42164cc6c6 100644
--- a/drivers/crypto/qat/qat_sym_session.c
+++ b/drivers/crypto/qat/qat_sym_session.c
@@ -30,6 +30,35 @@
#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
#include <openssl/provider.h>
+
+static OSSL_PROVIDER * legacy_lib;
+static OSSL_PROVIDER *default_lib;
+
+/* Some cryptographic algorithms such as MD and DES are now considered legacy
+ * and not enabled by default in OpenSSL 3.0. Load up lagacy provider as MD5
+ * DES are needed in QAT pre-computes and secure session creation.
+ */
+static int ossl_legacy_provider_load(void)
+{
+ /* Load Multiple providers into the default (NULL) library context */
+ legacy_lib = OSSL_PROVIDER_load(NULL, "legacy");
+ if (legacy_lib == NULL)
+ return -EINVAL;
+
+ default_lib = OSSL_PROVIDER_load(NULL, "default");
+ if (default_lib == NULL) {
+ OSSL_PROVIDER_unload(legacy_lib);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static void ossl_legacy_provider_unload(void)
+{
+ OSSL_PROVIDER_unload(legacy_lib);
+ OSSL_PROVIDER_unload(default_lib);
+}
#endif
extern int qat_ipsec_mb_lib;
@@ -485,19 +514,8 @@ qat_sym_session_configure(struct rte_cryptodev *dev,
}
#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
- OSSL_PROVIDER *legacy;
- OSSL_PROVIDER *deflt;
-
- /* Load Multiple providers into the default (NULL) library context */
- legacy = OSSL_PROVIDER_load(NULL, "legacy");
- if (legacy == NULL)
+ if (ossl_legacy_provider_load())
return -EINVAL;
-
- deflt = OSSL_PROVIDER_load(NULL, "default");
- if (deflt == NULL) {
- OSSL_PROVIDER_unload(legacy);
- return -EINVAL;
- }
#endif
ret = qat_sym_session_set_parameters(dev, xform, sess_private_data);
if (ret != 0) {
@@ -513,8 +531,7 @@ qat_sym_session_configure(struct rte_cryptodev *dev,
sess_private_data);
# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
- OSSL_PROVIDER_unload(legacy);
- OSSL_PROVIDER_unload(deflt);
+ ossl_legacy_provider_unload();
# endif
return 0;
}
@@ -2606,6 +2623,10 @@ qat_security_session_create(void *dev,
return -ENOMEM;
}
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+ if (ossl_legacy_provider_load())
+ return -EINVAL;
+#endif
ret = qat_sec_session_set_docsis_parameters(cdev, conf,
sess_private_data);
if (ret != 0) {
@@ -2639,6 +2660,10 @@ qat_security_session_destroy(void *dev __rte_unused,
set_sec_session_private_data(sess, NULL);
rte_mempool_put(sess_mp, sess_priv);
}
+
+# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+ ossl_legacy_provider_unload();
+# endif
return 0;
}
#endif
--
2.17.1
next reply other threads:[~2022-07-11 17:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 17:08 Kai Ji [this message]
2022-07-19 9:48 ` Zhang, Roy Fan
2022-08-26 12:07 ` 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=20220711170822.60795-1-kai.ji@intel.com \
--to=kai.ji@intel.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
/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).