Skip to contentSkip to conversation

crypto/openssl: openssl 3.0 support on asym crypto routine

PATCH New Kai Ji 4 participants 39 messages Apr 7, 2022 – Jun 21, 2022

Subsystems (3)
lore
Share & tools
lore

Kai Ji

author
#0 lore raw

PATCH 1/1 crypto/openssl: openssl 3.0 support on asym crypto routine

This patch update the asymmetric RSA and DH routine in crypto openssl pmd to adopt openssl 3.0 EVP library.

---
 drivers/crypto/openssl/compat.h              |  43 ++-
 drivers/crypto/openssl/openssl_pmd_private.h |  11 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 288 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 151 +++++++++-
 4 files changed, 489 insertions(+), 4 deletions(-)
drivers/crypto/openssl/compat.h +42 -1
index eecb7d3698..80b1493a5f 100644
@@ -104,8 +104,49 @@ get_dsa_priv_key(DSA *dsa, BIGNUM **priv_key)
 	*priv_key = dsa->priv_key;
 }
 
-#else
+#elif (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+static __rte_always_inline int
+set_dsa_params(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g)
+{
+	return !(DSA_set0_pqg(dsa, p, q, g));
+}
+
+static __rte_always_inline void
+set_dsa_priv_key(DSA *dsa, BIGNUM *priv_key)
+{
+	DSA_set0_key(dsa, NULL, priv_key);
+}
+
+static __rte_always_inline void
+set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
+{
+	DSA_SIG_set0(sign, r, s);
+}
+
+static __rte_always_inline void
+get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
+{
+	DSA_SIG_get0(sign, r, s);
+}
 
+static __rte_always_inline int
+set_dsa_keys(DSA *dsa, BIGNUM *pub, BIGNUM *priv)
+{
+	return !(DSA_set0_key(dsa, pub, priv));
+}
+
+static __rte_always_inline void
+set_dsa_pub_key(DSA *dsa, BIGNUM *pub_key)
+{
+	DSA_set0_key(dsa, pub_key, NULL);
+}
+
+static __rte_always_inline void
+get_dsa_priv_key(DSA *dsa, const BIGNUM **priv_key)
+{
+	DSA_get0_key(dsa, NULL, priv_key);
+}
+#else
 static __rte_always_inline int
 set_rsa_params(RSA *rsa, BIGNUM *p, BIGNUM *q)
 {
drivers/crypto/openssl/openssl_pmd_private.h +11 -0
index 86dc169aaf..aef12c3e21 100644
@@ -12,6 +12,11 @@
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
 
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#endif
+
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
 
@@ -157,6 +162,9 @@ struct openssl_asym_session {
 	union {
 		struct rsa {
 			RSA *rsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			EVP_PKEY_CTX * ctx;
+#endif
 		} r;
 		struct exp {
 			BIGNUM *exp;
@@ -170,6 +178,9 @@ struct openssl_asym_session {
 		struct dh {
 			DH *dh_key;
 			uint32_t key_op;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+#endif
 		} dh;
 		struct {
 			DSA *dsa;
drivers/crypto/openssl/rte_openssl_pmd.c +287 -1

344 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +149 -2

195 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#1 lore raw

v2 cover crypto/openssl: EVP api update for 3.0 lib

This patch set update openssl pmd deprecated APIs to EVP APIs where supported in openssl 3.0 lib.

Depends-on: series-22684 ("cryptodev: move dh type from xform to dh op")

Kai Ji (5):
drivers/crypto: suppress openssl deprecated api warning messages crypto/openssl: 3.0 EVP update on HMAC routine crypto/openssl: 3.0 EVP update on RSA routine crypto/openssl: 3.0 EVP update on DH routine crypto/openssl: 3.0 EVP update on DSA routine

 app/test/test_cryptodev_asym.c               |  91 ++-
 drivers/common/qat/meson.build               |   1 +
 drivers/crypto/ccp/meson.build               |   1 +
 drivers/crypto/openssl/compat.h              |  12 +
 drivers/crypto/openssl/openssl_pmd_private.h |  18 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 695 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 215 +++++-
 7 files changed, 1007 insertions(+), 26 deletions(-)
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v2 1/5 drivers/crypto: suppress openssl deprecated api warning messages

Enable openssl_api_compat cflag to suppress deprecated api warning messages in crypto pmd drivers: ccp, openssl and qat.

---
 drivers/common/qat/meson.build     | 1 +
 drivers/crypto/ccp/meson.build     | 1 +
 drivers/crypto/openssl/meson.build | 1 +
 3 files changed, 3 insertions(+)
drivers/common/qat/meson.build +1 -0
index b7027f3164..6c3e7275ef 100644
@@ -87,3 +87,4 @@ if qat_crypto
     ext_deps += libcrypto
     cflags += ['-DBUILD_QAT_SYM', '-DBUILD_QAT_ASYM']
 endif
+cflags += ['-DOPENSSL_API_COMPAT=0x10100000L']
drivers/crypto/ccp/meson.build +1 -0
index a4f3406009..fe89e17b14 100644
@@ -23,3 +23,4 @@ sources = files(
 )
 
 ext_deps += dep
+cflags += ['-DOPENSSL_API_COMPAT=0x10100000L']
drivers/crypto/openssl/meson.build +1 -0
index cd962da1d6..9a3dea2c04 100644
@@ -15,3 +15,4 @@ endif
 deps += 'bus_vdev'
 sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
 ext_deps += dep
+cflags += ['-DOPENSSL_API_COMPAT=0x10100000L']
Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v2 2/5 crypto/openssl: 3.0 EVP update on HMAC routine

In reply to Kai Ji

This patch update the symmetric HMAC routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 187 ++++++++++++++++++-
 2 files changed, 181 insertions(+), 10 deletions(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index b2054b3754..86dc169aaf 100644
@@ -134,8 +134,12 @@ struct openssl_session {
 				/**< pointer to EVP key */
 				const EVP_MD *evp_algo;
 				/**< pointer to EVP algorithm function */
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+				EVP_MAC_CTX * ctx;
+# else
 				HMAC_CTX *ctx;
 				/**< pointer to EVP context structure */
+# endif
 			} hmac;
 		};
 
drivers/crypto/openssl/rte_openssl_pmd.c +177 -10

289 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v2 3/5 crypto/openssl: 3.0 EVP update on RSA routine

In reply to Kai Ji

This patch updates asymmetric RSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   7 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 149 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 112 +++++++++++++-
 3 files changed, 267 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +7 -0
index 86dc169aaf..d603626fdf 100644
@@ -11,6 +11,10 @@
 #include <openssl/rsa.h>
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#endif
 
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
@@ -157,6 +161,9 @@ struct openssl_asym_session {
 	union {
 		struct rsa {
 			RSA *rsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			EVP_PKEY_CTX * ctx;
+#endif
 		} r;
 		struct exp {
 			BIGNUM *exp;
drivers/crypto/openssl/rte_openssl_pmd.c +149 -0

168 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +111 -1

138 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#8 lore raw

PATCH v2 4/5 crypto/openssl: 3.0 EVP update on DH routine

In reply to Kai Ji

This patch updates asymmetric DH routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 186 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  47 ++++-
 3 files changed, 235 insertions(+), 2 deletions(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index d603626fdf..8fdbc75511 100644
@@ -177,6 +177,10 @@ struct openssl_asym_session {
 		struct dh {
 			DH *dh_key;
 			uint32_t key_op;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+			OSSL_PARAM_BLD *param_bld_peer;
+#endif
 		} dh;
 		struct {
 			DSA *dsa;
drivers/crypto/openssl/rte_openssl_pmd.c +185 -1

213 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +46 -1

67 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#9 lore raw

PATCH v2 5/5 crypto/openssl: 3.0 EVP update on DSA routine

In reply to Kai Ji

This patch updates asymmetric DSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis. Divide the single combined dsa sign test to two indiviual dsa sign and dsa verfiy tests.

---
 app/test/test_cryptodev_asym.c               |  91 ++++++++--
 drivers/crypto/openssl/compat.h              |  12 ++
 drivers/crypto/openssl/meson.build           |   1 -
 drivers/crypto/openssl/openssl_pmd_private.h |   3 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 175 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  56 +++++-
 6 files changed, 323 insertions(+), 15 deletions(-)
app/test/test_cryptodev_asym.c +78 -13
index 573af2a537..f8597df246 100644
@@ -1639,7 +1639,7 @@ test_dh_keygenration(void)
 }
 
 static int
-test_dsa_sign(void)
+test_dsa_sign(struct rte_crypto_dsa_op_param *dsa_op)
 {
 	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
 	struct rte_mempool *op_mpool = ts_params->op_mpool;
@@ -1649,9 +1649,6 @@ test_dsa_sign(void)
 	struct rte_crypto_op *op = NULL, *result_op = NULL;
 	void *sess = NULL;
 	int status = TEST_SUCCESS;
-	uint8_t r[TEST_DH_MOD_LEN];
-	uint8_t s[TEST_DH_MOD_LEN];
-	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
 	int ret;
 
 	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
@@ -1673,6 +1670,7 @@ test_dsa_sign(void)
 		goto error_exit;
 	}
 	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
 
 	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
 			dsa_xform.dsa.p.length);
@@ -1686,13 +1684,6 @@ test_dsa_sign(void)
 	/* attach asymmetric crypto session to crypto operations */
 	rte_crypto_op_attach_asym_session(op, sess);
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
-	asym_op->dsa.message.data = dgst;
-	asym_op->dsa.message.length = sizeof(dgst);
-	asym_op->dsa.r.length = sizeof(r);
-	asym_op->dsa.r.data = r;
-	asym_op->dsa.s.length = sizeof(s);
-	asym_op->dsa.s.data = s;
-
 	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
 
 	/* Process crypto operation */
@@ -1716,12 +1707,72 @@ test_dsa_sign(void)
 	}
 
 	asym_op = result_op->asym;
+	dsa_op->r.length = asym_op->dsa.r.length;
+	dsa_op->s.length = asym_op->dsa.s.length;
+
+	debug_hexdump(stdout, "r:",
+			asym_op->dsa.r.data, asym_op->dsa.r.length);
+	debug_hexdump(stdout, "s:",
+			asym_op->dsa.s.data, asym_op->dsa.s.length);
+error_exit:
+	if (sess != NULL)
+		rte_cryptodev_asym_session_free(dev_id, sess);
+	if (op != NULL)
+		rte_crypto_op_free(op);
+	return status;
+}
+
+
+static int
+test_dsa_verify(struct rte_crypto_dsa_op_param *dsa_op)
+{
+	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	void *sess = NULL;
+	int status = TEST_SUCCESS;
+	int ret;
+
+	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
+	if (ret < 0) {
+		RTE_LOG(ERR, USER1,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
+
+	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
+			dsa_xform.dsa.p.length);
+	debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
+			dsa_xform.dsa.q.length);
+	debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
+			dsa_xform.dsa.g.length);
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
 
 	debug_hexdump(stdout, "r:",
 			asym_op->dsa.r.data, asym_op->dsa.r.length);
 	debug_hexdump(stdout, "s:",
 			asym_op->dsa.s.data, asym_op->dsa.s.length);
 
+	RTE_LOG(DEBUG, USER1, "Process ASYM verify operation");
 	/* Test PMD DSA sign verification using signer public key */
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
 
@@ -1767,8 +1818,22 @@ static int
 test_dsa(void)
 {
 	int status;
-	status = test_dsa_sign();
-	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+	uint8_t r[TEST_DH_MOD_LEN];
+	uint8_t s[TEST_DH_MOD_LEN];
+	struct rte_crypto_dsa_op_param dsa_op;
+	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
+
+	dsa_op.message.data = dgst;
+	dsa_op.message.length = sizeof(dgst);
+	dsa_op.r.data = r;
+	dsa_op.s.data = s;
+	dsa_op.r.length = sizeof(r);
+	dsa_op.s.length = sizeof(s);
+
+	status = test_dsa_sign(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA sign test failed");
+	status = test_dsa_verify(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA verify test failed");
 	return status;
 }
 
drivers/crypto/openssl/compat.h +12 -0
index eecb7d3698..9f9167c4f1 100644
@@ -104,6 +104,18 @@ get_dsa_priv_key(DSA *dsa, BIGNUM **priv_key)
 	*priv_key = dsa->priv_key;
 }
 
+#elif (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+static __rte_always_inline void
+set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
+{
+	DSA_SIG_set0(sign, r, s);
+}
+
+static __rte_always_inline void
+get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
+{
+	DSA_SIG_get0(sign, r, s);
+}
 #else
 
 static __rte_always_inline int
drivers/crypto/openssl/meson.build +0 -1
index 9a3dea2c04..cd962da1d6 100644
@@ -15,4 +15,3 @@ endif
 deps += 'bus_vdev'
 sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
 ext_deps += dep
-cflags += ['-DOPENSSL_API_COMPAT=0x10100000L']
drivers/crypto/openssl/openssl_pmd_private.h +3 -0
index 8fdbc75511..b0e5cd109b 100644
@@ -184,6 +184,9 @@ struct openssl_asym_session {
 		} dh;
 		struct {
 			DSA *dsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+#endif
 		} s;
 	} u;
 } __rte_cache_aligned;
drivers/crypto/openssl/rte_openssl_pmd.c +175 -0

199 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +55 -1

76 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

RE: [EXT] [dpdk-dev v2 1/5] drivers/crypto: suppress openssl deprecated api warning messages

In reply to Kai Ji

Hi Kai,

Quoted 4 lines

Enable openssl_api_compat cflag to suppress deprecated api warning messages in crypto pmd drivers: ccp, openssl and qat.

This patch may not be required if we use this
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

Quoted 37 lines
---
 drivers/common/qat/meson.build     | 1 +
 drivers/crypto/ccp/meson.build     | 1 +
 drivers/crypto/openssl/meson.build | 1 +
 3 files changed, 3 insertions(+)
drivers/common/qat/meson.build +1 -0
index b7027f3164..6c3e7275ef 100644
@@ -87,3 +87,4 @@ if qat_crypto
     ext_deps += libcrypto
     cflags += ['-DBUILD_QAT_SYM', '-DBUILD_QAT_ASYM']
 endif
+cflags += ['-DOPENSSL_API_COMPAT=0x10100000L']
drivers/crypto/ccp/meson.build +1 -0
index a4f3406009..fe89e17b14 100644
@@ -23,3 +23,4 @@ sources = files(
 )
 
 ext_deps += dep
+cflags += ['-DOPENSSL_API_COMPAT=0x10100000L']
drivers/crypto/openssl/meson.build +1 -1
index cd962da1d6..9a3dea2c04 100644
@@ -15,3 +15,4 @@ endif
 deps += 'bus_vdev'
 sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
 ext_deps += dep
+cflags += ['-DOPENSSL_API_COMPAT=0x10100000L']
--

2.17.1

#4 lore raw

Re: [EXT] [dpdk-dev v2 1/5] drivers/crypto: suppress openssl deprecated api warning messages

Quoted 8 lines · On Mon, 16 May 2022 19:21:01 +0000 Akhil Goyal <[email protected]> wrote:

Hi Kai,

Quoted 4 lines

Enable openssl_api_compat cflag to suppress deprecated api warning messages in crypto pmd drivers: ccp, openssl and qat.

This patch may not be required if we use this
http://patches.dpdk.org/project/dpdk/patch/[email protected]/

Just to be devil's advocate. Why should DPDK continue to support older and unsecure crypto algorithms? I would argue DPDK should deprecate the use of SNA256 and remove it in 22.11 release.

#5 lore raw

RE: [EXT] [dpdk-dev v2 1/5] drivers/crypto: suppress openssl deprecated api warning messages

Quoted 5 lines

Just to be devil's advocate. Why should DPDK continue to support older and unsecure crypto algorithms? I would argue DPDK should deprecate the use of SNA256
and remove it in 22.11 release.

AFAIK Openssl 1.1 is not outdated and there are customers which are still Not migrated to openssl 3.0. Hence cannot completely remove that.

author
#10 lore raw

v3 cover crypto/openssl: EVP api update for 3.0 lib

In reply to Kai Ji

This patch set update openssl pmd deprecated APIs to EVP APIs where supported in openssl 3.0 lib

---
v3:
- rebase to 22.07 rc1

v2:
- addin DSA routine

Kai Ji (4):
crypto/openssl: 3.0 EVP update on HMAC routine
crypto/openssl: 3.0 EVP update on RSA routine
crypto/openssl: 3.0 EVP update on DH routine
crypto/openssl: 3.0 EVP update on DSA routine

 app/test/test_cryptodev_asym.c               |  90 ++-
 drivers/crypto/openssl/compat.h              |  12 +
 drivers/crypto/openssl/openssl_pmd_private.h |  18 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 698 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 231 +++++-
 5 files changed, 1013 insertions(+), 36 deletions(-)

--
2.17.1

author
#11 lore raw

PATCH v3 1/4 crypto/openssl: 3.0 EVP update on HMAC routine

This patch update the symmetric HMAC routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 187 ++++++++++++++++++-
 2 files changed, 181 insertions(+), 10 deletions(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index b2054b3754..86dc169aaf 100644
@@ -134,8 +134,12 @@ struct openssl_session {
 				/**< pointer to EVP key */
 				const EVP_MD *evp_algo;
 				/**< pointer to EVP algorithm function */
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+				EVP_MAC_CTX * ctx;
+# else
 				HMAC_CTX *ctx;
 				/**< pointer to EVP context structure */
+# endif
 			} hmac;
 		};
 
drivers/crypto/openssl/rte_openssl_pmd.c +177 -10

289 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#13 lore raw

PATCH v3 3/4 crypto/openssl: 3.0 EVP update on DH routine

In reply to Kai Ji

This patch updates asymmetric DH routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 185 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  47 ++++-
 3 files changed, 235 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index d603626fdf..8fdbc75511 100644
@@ -177,6 +177,10 @@ struct openssl_asym_session {
 		struct dh {
 			DH *dh_key;
 			uint32_t key_op;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+			OSSL_PARAM_BLD *param_bld_peer;
+#endif
 		} dh;
 		struct {
 			DSA *dsa;
drivers/crypto/openssl/rte_openssl_pmd.c +185 -0

210 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +46 -1

67 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#12 lore raw

PATCH v3 2/4 crypto/openssl: 3.0 EVP update on RSA routine

In reply to Kai Ji

This patch updates asymmetric RSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   7 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 149 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 112 +++++++++++++-
 3 files changed, 267 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +7 -0
index 86dc169aaf..d603626fdf 100644
@@ -11,6 +11,10 @@
 #include <openssl/rsa.h>
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#endif
 
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
@@ -157,6 +161,9 @@ struct openssl_asym_session {
 	union {
 		struct rsa {
 			RSA *rsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			EVP_PKEY_CTX * ctx;
+#endif
 		} r;
 		struct exp {
 			BIGNUM *exp;
drivers/crypto/openssl/rte_openssl_pmd.c +149 -0

168 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +111 -1

138 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#14 lore raw

PATCH v3 4/4 crypto/openssl: 3.0 EVP update on DSA routine

In reply to Kai Ji

This patch updates asymmetric DSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis. Divide the single combined dsa sign test to two indiviual dsa sign and dsa verfiy tests.

---
 app/test/test_cryptodev_asym.c               |  90 ++++++++--
 drivers/crypto/openssl/compat.h              |  12 ++
 drivers/crypto/openssl/openssl_pmd_private.h |   3 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 177 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  72 +++++++-
 5 files changed, 330 insertions(+), 24 deletions(-)
app/test/test_cryptodev_asym.c +77 -13
index 7bd7cde16e..c9c48d1e87 100644
@@ -1642,7 +1642,7 @@ test_dh_keygenration(void)
 }
 
 static int
-test_dsa_sign(void)
+test_dsa_sign(struct rte_crypto_dsa_op_param *dsa_op)
 {
 	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
 	struct rte_mempool *op_mpool = ts_params->op_mpool;
@@ -1652,9 +1652,6 @@ test_dsa_sign(void)
 	struct rte_crypto_op *op = NULL, *result_op = NULL;
 	void *sess = NULL;
 	int status = TEST_SUCCESS;
-	uint8_t r[TEST_DH_MOD_LEN];
-	uint8_t s[TEST_DH_MOD_LEN];
-	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
 	int ret;
 
 	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
@@ -1676,6 +1673,7 @@ test_dsa_sign(void)
 		goto error_exit;
 	}
 	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
 
 	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
 			dsa_xform.dsa.p.length);
@@ -1689,13 +1687,6 @@ test_dsa_sign(void)
 	/* attach asymmetric crypto session to crypto operations */
 	rte_crypto_op_attach_asym_session(op, sess);
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
-	asym_op->dsa.message.data = dgst;
-	asym_op->dsa.message.length = sizeof(dgst);
-	asym_op->dsa.r.length = sizeof(r);
-	asym_op->dsa.r.data = r;
-	asym_op->dsa.s.length = sizeof(s);
-	asym_op->dsa.s.data = s;
-
 	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
 
 	/* Process crypto operation */
@@ -1719,12 +1710,71 @@ test_dsa_sign(void)
 	}
 
 	asym_op = result_op->asym;
+	dsa_op->r.length = asym_op->dsa.r.length;
+	dsa_op->s.length = asym_op->dsa.s.length;
 
 	debug_hexdump(stdout, "r:",
 			asym_op->dsa.r.data, asym_op->dsa.r.length);
 	debug_hexdump(stdout, "s:",
 			asym_op->dsa.s.data, asym_op->dsa.s.length);
+error_exit:
+	if (sess != NULL)
+		rte_cryptodev_asym_session_free(dev_id, sess);
+	if (op != NULL)
+		rte_crypto_op_free(op);
+	return status;
+}
+
+static int
+test_dsa_verify(struct rte_crypto_dsa_op_param *dsa_op)
+{
+	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	void *sess = NULL;
+	int status = TEST_SUCCESS;
+	int ret;
 
+	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
+	if (ret < 0) {
+		RTE_LOG(ERR, USER1,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
+
+	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
+			dsa_xform.dsa.p.length);
+	debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
+			dsa_xform.dsa.q.length);
+	debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
+			dsa_xform.dsa.g.length);
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	debug_hexdump(stdout, "r:",
+			asym_op->dsa.r.data, asym_op->dsa.r.length);
+	debug_hexdump(stdout, "s:",
+			asym_op->dsa.s.data, asym_op->dsa.s.length);
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM verify operation");
 	/* Test PMD DSA sign verification using signer public key */
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
 
@@ -1770,8 +1820,22 @@ static int
 test_dsa(void)
 {
 	int status;
-	status = test_dsa_sign();
-	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+	uint8_t r[TEST_DH_MOD_LEN];
+	uint8_t s[TEST_DH_MOD_LEN];
+	struct rte_crypto_dsa_op_param dsa_op;
+	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
+
+	dsa_op.message.data = dgst;
+	dsa_op.message.length = sizeof(dgst);
+	dsa_op.r.data = r;
+	dsa_op.s.data = s;
+	dsa_op.r.length = sizeof(r);
+	dsa_op.s.length = sizeof(s);
+
+	status = test_dsa_sign(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA sign test failed");
+	status = test_dsa_verify(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA verify test failed");
 	return status;
 }
 
drivers/crypto/openssl/compat.h +12 -0
index eecb7d3698..9f9167c4f1 100644
@@ -104,6 +104,18 @@ get_dsa_priv_key(DSA *dsa, BIGNUM **priv_key)
 	*priv_key = dsa->priv_key;
 }
 
+#elif (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+static __rte_always_inline void
+set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
+{
+	DSA_SIG_set0(sign, r, s);
+}
+
+static __rte_always_inline void
+get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
+{
+	DSA_SIG_get0(sign, r, s);
+}
 #else
 
 static __rte_always_inline int
drivers/crypto/openssl/openssl_pmd_private.h +3 -0
index 8fdbc75511..b0e5cd109b 100644
@@ -184,6 +184,9 @@ struct openssl_asym_session {
 		} dh;
 		struct {
 			DSA *dsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+#endif
 		} s;
 	} u;
 } __rte_cache_aligned;
drivers/crypto/openssl/rte_openssl_pmd.c +175 -2

207 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +63 -9

139 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#15 lore raw

v4 cover crypto/openssl: EVP api update for 3.0 lib

In reply to Kai Ji

This patch set update openssl pmd deprecated APIs to EVP APIs where supported in openssl 3.0 lib

---
v4:
- compilation issue fix

v3:
- rebase to 22.07 rc1

v2:
- addin DSA routine

---

Kai Ji (4):
crypto/openssl: 3.0 EVP update on HMAC routine
crypto/openssl: 3.0 EVP update on RSA routine
crypto/openssl: 3.0 EVP update on DH routine
crypto/openssl: 3.0 EVP update on DSA routine

 app/test/test_cryptodev_asym.c               |  90 ++-
 drivers/crypto/openssl/compat.h              |  12 +
 drivers/crypto/openssl/openssl_pmd_private.h |  18 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 698 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 231 +++++-
 5 files changed, 1013 insertions(+), 36 deletions(-)

--
2.17.1

author
#16 lore raw

PATCH v4 1/4 crypto/openssl: 3.0 EVP update on HMAC routine

This patch update the symmetric HMAC routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 187 ++++++++++++++++++-
 2 files changed, 181 insertions(+), 10 deletions(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index b2054b3754..86dc169aaf 100644
@@ -134,8 +134,12 @@ struct openssl_session {
 				/**< pointer to EVP key */
 				const EVP_MD *evp_algo;
 				/**< pointer to EVP algorithm function */
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+				EVP_MAC_CTX * ctx;
+# else
 				HMAC_CTX *ctx;
 				/**< pointer to EVP context structure */
+# endif
 			} hmac;
 		};
 
drivers/crypto/openssl/rte_openssl_pmd.c +177 -10

289 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#19 lore raw

PATCH v4 2/4 crypto/openssl: 3.0 EVP update on RSA routine

In reply to Kai Ji

This patch updates asymmetric RSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   7 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 149 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 112 +++++++++++++-
 3 files changed, 267 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +7 -0
index 86dc169aaf..d603626fdf 100644
@@ -11,6 +11,10 @@
 #include <openssl/rsa.h>
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#endif
 
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
@@ -157,6 +161,9 @@ struct openssl_asym_session {
 	union {
 		struct rsa {
 			RSA *rsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			EVP_PKEY_CTX * ctx;
+#endif
 		} r;
 		struct exp {
 			BIGNUM *exp;
drivers/crypto/openssl/rte_openssl_pmd.c +149 -0

168 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +111 -1

138 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#23 lore raw

PATCH v4 3/4 crypto/openssl: 3.0 EVP update on DH routine

In reply to Kai Ji

This patch updates asymmetric DH routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 185 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  47 ++++-
 3 files changed, 235 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index d603626fdf..8fdbc75511 100644
@@ -177,6 +177,10 @@ struct openssl_asym_session {
 		struct dh {
 			DH *dh_key;
 			uint32_t key_op;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+			OSSL_PARAM_BLD *param_bld_peer;
+#endif
 		} dh;
 		struct {
 			DSA *dsa;
drivers/crypto/openssl/rte_openssl_pmd.c +185 -0

210 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +46 -1

67 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#25 lore raw

PATCH v4 4/4 crypto/openssl: 3.0 EVP update on DSA routine

In reply to Kai Ji

This patch updates asymmetric DSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis. Divide the single combined dsa sign test to two individual dsa sign and dsa verfiy tests.

---
 app/test/test_cryptodev_asym.c               |  90 ++++++++--
 drivers/crypto/openssl/compat.h              |  12 ++
 drivers/crypto/openssl/openssl_pmd_private.h |   3 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 177 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  72 +++++++-
 5 files changed, 330 insertions(+), 24 deletions(-)
app/test/test_cryptodev_asym.c +77 -13
index 7bd7cde16e..c9c48d1e87 100644
@@ -1642,7 +1642,7 @@ test_dh_keygenration(void)
 }
 
 static int
-test_dsa_sign(void)
+test_dsa_sign(struct rte_crypto_dsa_op_param *dsa_op)
 {
 	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
 	struct rte_mempool *op_mpool = ts_params->op_mpool;
@@ -1652,9 +1652,6 @@ test_dsa_sign(void)
 	struct rte_crypto_op *op = NULL, *result_op = NULL;
 	void *sess = NULL;
 	int status = TEST_SUCCESS;
-	uint8_t r[TEST_DH_MOD_LEN];
-	uint8_t s[TEST_DH_MOD_LEN];
-	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
 	int ret;
 
 	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
@@ -1676,6 +1673,7 @@ test_dsa_sign(void)
 		goto error_exit;
 	}
 	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
 
 	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
 			dsa_xform.dsa.p.length);
@@ -1689,13 +1687,6 @@ test_dsa_sign(void)
 	/* attach asymmetric crypto session to crypto operations */
 	rte_crypto_op_attach_asym_session(op, sess);
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
-	asym_op->dsa.message.data = dgst;
-	asym_op->dsa.message.length = sizeof(dgst);
-	asym_op->dsa.r.length = sizeof(r);
-	asym_op->dsa.r.data = r;
-	asym_op->dsa.s.length = sizeof(s);
-	asym_op->dsa.s.data = s;
-
 	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
 
 	/* Process crypto operation */
@@ -1719,12 +1710,71 @@ test_dsa_sign(void)
 	}
 
 	asym_op = result_op->asym;
+	dsa_op->r.length = asym_op->dsa.r.length;
+	dsa_op->s.length = asym_op->dsa.s.length;
 
 	debug_hexdump(stdout, "r:",
 			asym_op->dsa.r.data, asym_op->dsa.r.length);
 	debug_hexdump(stdout, "s:",
 			asym_op->dsa.s.data, asym_op->dsa.s.length);
+error_exit:
+	if (sess != NULL)
+		rte_cryptodev_asym_session_free(dev_id, sess);
+	if (op != NULL)
+		rte_crypto_op_free(op);
+	return status;
+}
+
+static int
+test_dsa_verify(struct rte_crypto_dsa_op_param *dsa_op)
+{
+	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	void *sess = NULL;
+	int status = TEST_SUCCESS;
+	int ret;
 
+	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
+	if (ret < 0) {
+		RTE_LOG(ERR, USER1,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
+
+	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
+			dsa_xform.dsa.p.length);
+	debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
+			dsa_xform.dsa.q.length);
+	debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
+			dsa_xform.dsa.g.length);
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	debug_hexdump(stdout, "r:",
+			asym_op->dsa.r.data, asym_op->dsa.r.length);
+	debug_hexdump(stdout, "s:",
+			asym_op->dsa.s.data, asym_op->dsa.s.length);
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM verify operation");
 	/* Test PMD DSA sign verification using signer public key */
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
 
@@ -1770,8 +1820,22 @@ static int
 test_dsa(void)
 {
 	int status;
-	status = test_dsa_sign();
-	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+	uint8_t r[TEST_DH_MOD_LEN];
+	uint8_t s[TEST_DH_MOD_LEN];
+	struct rte_crypto_dsa_op_param dsa_op;
+	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
+
+	dsa_op.message.data = dgst;
+	dsa_op.message.length = sizeof(dgst);
+	dsa_op.r.data = r;
+	dsa_op.s.data = s;
+	dsa_op.r.length = sizeof(r);
+	dsa_op.s.length = sizeof(s);
+
+	status = test_dsa_sign(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA sign test failed");
+	status = test_dsa_verify(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA verify test failed");
 	return status;
 }
 
drivers/crypto/openssl/compat.h +12 -0
index eecb7d3698..9f9167c4f1 100644
@@ -104,6 +104,18 @@ get_dsa_priv_key(DSA *dsa, BIGNUM **priv_key)
 	*priv_key = dsa->priv_key;
 }
 
+#elif (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+static __rte_always_inline void
+set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
+{
+	DSA_SIG_set0(sign, r, s);
+}
+
+static __rte_always_inline void
+get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
+{
+	DSA_SIG_get0(sign, r, s);
+}
 #else
 
 static __rte_always_inline int
drivers/crypto/openssl/openssl_pmd_private.h +3 -0
index 8fdbc75511..b0e5cd109b 100644
@@ -184,6 +184,9 @@ struct openssl_asym_session {
 		} dh;
 		struct {
 			DSA *dsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+#endif
 		} s;
 	} u;
 } __rte_cache_aligned;
drivers/crypto/openssl/rte_openssl_pmd.c +175 -2

207 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +63 -9

139 lines not on this page · raw message

Signature · 1 line
2.17.1
Acked-by on v4 1/4
#17 lore raw

RE: [dpdk-dev v4 1/4] crypto/openssl: 3.0 EVP update on HMAC routine

In reply to Kai Ji
Quoted 7 lines

-----Original Message-----
From: Kai Ji <[email protected]>
Sent: Tuesday, June 14, 2022 2:26 PM
To: [email protected]
Cc: [email protected]; Ji, Kai <[email protected]>
Subject: [dpdk-dev v4 1/4] crypto/openssl: 3.0 EVP update on HMAC routine

Quoted 5 lines

This patch update the symmetric HMAC routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---

Acked-by on v4 2/4
#20 lore raw

RE: [dpdk-dev v4 2/4] crypto/openssl: 3.0 EVP update on RSA routine

In reply to Kai Ji
Quoted 7 lines

-----Original Message-----
From: Kai Ji <[email protected]>
Sent: Tuesday, June 14, 2022 2:26 PM
To: [email protected]
Cc: [email protected]; Ji, Kai <[email protected]>
Subject: [dpdk-dev v4 2/4] crypto/openssl: 3.0 EVP update on RSA routine

Quoted 5 lines

This patch updates asymmetric RSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---

Acked-by on v4 3/4
#24 lore raw

RE: [dpdk-dev v4 3/4] crypto/openssl: 3.0 EVP update on DH routine

In reply to Kai Ji
Quoted 7 lines

-----Original Message-----
From: Kai Ji <[email protected]>
Sent: Tuesday, June 14, 2022 2:26 PM
To: [email protected]
Cc: [email protected]; Ji, Kai <[email protected]>
Subject: [dpdk-dev v4 3/4] crypto/openssl: 3.0 EVP update on DH routine

Quoted 5 lines

This patch updates asymmetric DH routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---

Acked-by on v4 4/4
#26 lore raw

RE: [dpdk-dev v4 4/4] crypto/openssl: 3.0 EVP update on DSA routine

In reply to Kai Ji
Quoted 7 lines

-----Original Message-----
From: Kai Ji <[email protected]>
Sent: Tuesday, June 14, 2022 2:26 PM
To: [email protected]
Cc: [email protected]; Ji, Kai <[email protected]>
Subject: [dpdk-dev v4 4/4] crypto/openssl: 3.0 EVP update on DSA routine

Quoted 6 lines

This patch updates asymmetric DSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis. Divide the single combined dsa sign test to two individual dsa sign and dsa verfiy tests.

---

#18 lore raw

RE: [EXT] [dpdk-dev v4 1/4] crypto/openssl: 3.0 EVP update on HMAC routine

In reply to Kai Ji
Quoted 2 lines

Subject: [EXT] [dpdk-dev v4 1/4] crypto/openssl: 3.0 EVP update on HMAC routine

Title should be
Crypto/openssl: update HMAC routine with 3.0 EVP API

Quoted 16 lines

This patch update the symmetric HMAC routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 187 ++++++++++++++++++-
 2 files changed, 181 insertions(+), 10 deletions(-)
drivers/crypto/openssl/openssl_pmd_private.h +0 -0
index b2054b3754..86dc169aaf 100644

drivers/crypto/openssl/openssl_pmd_private.h struct openssl_session { · line 142

Quoted 9 lines
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
@@ -134,8 +134,12 @@ struct openssl_session {
 				/**< pointer to EVP key */
 				const EVP_MD *evp_algo;
 				/**< pointer to EVP algorithm function */
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+				EVP_MAC_CTX * ctx;
+# else
 				HMAC_CTX *ctx;
 				/**< pointer to EVP context structure */
+# endif

Endif should be above comment.

Quoted 13 lines
drivers/crypto/openssl/openssl_pmd_private.h +0 -0
 			} hmac;
 		};
 
drivers/crypto/openssl/rte_openssl_pmd.c +1 -0
index 6ac2dfff5a..5dbe6074eb 100644
@@ -41,6 +41,61 @@ static void HMAC_CTX_free(HMAC_CTX *ctx)
 }
 #endif
 
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)

drivers/crypto/openssl/rte_openssl_pmd.c static void HMAC_CTX_free(HMAC_CTX *ctx) · line 54

Quoted 10 lines
drivers/crypto/openssl/rte_openssl_pmd.c +10 -0
+
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+
+#define MAX_OSSL_ALGO_NAME_SIZE		16
+
+OSSL_PROVIDER *legacy;
+OSSL_PROVIDER *deflt;
+
+static void ossl_load_legacy_provider(void)

Static void should be separate line.
Check for other functions as well.

verb should be in the end
Ossl_legacy_provider_load/unload

Quoted 14 lines
drivers/crypto/openssl/rte_openssl_pmd.c +14 -0
+{
+	/* Load Multiple providers into the default (NULL) library context */
+	legacy = OSSL_PROVIDER_load(NULL, "legacy");
+	if (legacy == NULL) {
+		OPENSSL_LOG(ERR, "Failed to load Legacy provider\n");
+		return;
+	}
+
+	deflt = OSSL_PROVIDER_load(NULL, "default");
+	if (deflt == NULL) {
+		OPENSSL_LOG(ERR, "Failed to load Default provider\n");
+		OSSL_PROVIDER_unload(legacy);
+		return;
+	}

drivers/crypto/openssl/rte_openssl_pmd.c static void HMAC_CTX_free(HMAC_CTX *ctx) · line 78

Quoted 10 lines
drivers/crypto/openssl/rte_openssl_pmd.c +10 -0
+}
+
+static void ossl_unload_legacy_provider(void)
+{
+	OSSL_PROVIDER_unload(legacy);
+	OSSL_PROVIDER_unload(deflt);
+}
+
+static __rte_always_inline const char *
+get_digest_name(const struct rte_crypto_sym_xform *xform)

Digest_name_get

Quoted 30 lines
drivers/crypto/openssl/rte_openssl_pmd.c +22 -0
+{
+	switch (xform->auth.algo) {
+	case RTE_CRYPTO_AUTH_MD5_HMAC:
+		return OSSL_DIGEST_NAME_MD5;
+	case RTE_CRYPTO_AUTH_SHA1_HMAC:
+		return OSSL_DIGEST_NAME_SHA1;
+	case RTE_CRYPTO_AUTH_SHA224_HMAC:
+		return OSSL_DIGEST_NAME_SHA2_224;
+	case RTE_CRYPTO_AUTH_SHA256_HMAC:
+		return OSSL_DIGEST_NAME_SHA2_256;
+	case RTE_CRYPTO_AUTH_SHA384_HMAC:
+		return OSSL_DIGEST_NAME_SHA2_384;
+	case RTE_CRYPTO_AUTH_SHA512_HMAC:
+		return OSSL_DIGEST_NAME_SHA2_512;
+	default:
+		return NULL;
+	}
+}
+#endif
+
 static int cryptodev_openssl_remove(struct rte_vdev_device *vdev);
 
 /*----------------------------------------------------------------------------*/
@@ -582,6 +637,40 @@ openssl_set_session_auth_parameters(struct
 openssl_session *sess,
 		sess->auth.auth.ctx = EVP_MD_CTX_create();
 		break;
 
+# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+	case RTE_CRYPTO_AUTH_MD5_HMAC:

drivers/crypto/openssl/rte_openssl_pmd.c openssl_set_session_auth_parameters(struct · line 652

Quoted 10 lines
drivers/crypto/openssl/rte_openssl_pmd.c +10 -0
+	case RTE_CRYPTO_AUTH_SHA1_HMAC:
+	case RTE_CRYPTO_AUTH_SHA224_HMAC:
+	case RTE_CRYPTO_AUTH_SHA256_HMAC:
+	case RTE_CRYPTO_AUTH_SHA384_HMAC:
+	case RTE_CRYPTO_AUTH_SHA512_HMAC:
+		sess->auth.mode = OPENSSL_AUTH_AS_HMAC;
+
+		OSSL_PARAM params[2];
+		const char *algo;
+		algo = get_digest_name(xform);

Pass xform->auth.algo directly

Quoted 235 lines
drivers/crypto/openssl/rte_openssl_pmd.c +22 -0
+		if (!algo)
+			return -EINVAL;
+		char algo_name[MAX_OSSL_ALGO_NAME_SIZE];
+		rte_memcpy(algo_name, algo, (sizeof(algo)+1));
+
+		EVP_MAC *mac = EVP_MAC_fetch(NULL, "HMAC", NULL);
+		sess->auth.hmac.ctx = EVP_MAC_CTX_new(mac);
+		EVP_MAC_free(mac);
+		if (get_auth_algo(xform->auth.algo,
+				&sess->auth.hmac.evp_algo) != 0)
+			return -EINVAL;
+
+		params[0] = OSSL_PARAM_construct_utf8_string("digest",
+					algo_name, 0);
+		params[1] = OSSL_PARAM_construct_end();
+		if (EVP_MAC_init(sess->auth.hmac.ctx,
+				xform->auth.key.data,
+				xform->auth.key.length,
+				params) != 1)
+			return -EINVAL;
+		break;
+# else
 	case RTE_CRYPTO_AUTH_MD5_HMAC:
 	case RTE_CRYPTO_AUTH_SHA1_HMAC:
drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
 	case RTE_CRYPTO_AUTH_SHA224_HMAC:
@@ -600,7 +689,7 @@ openssl_set_session_auth_parameters(struct
 openssl_session *sess,
 				sess->auth.hmac.evp_algo, NULL) != 1)
 			return -EINVAL;
 		break;
-
+# endif
 	default:
 		return -ENOTSUP;
drivers/crypto/openssl/rte_openssl_pmd.c +57 -0
 	}
@@ -725,7 +814,11 @@ openssl_reset_session(struct openssl_session *sess)
 		break;
 	case OPENSSL_AUTH_AS_HMAC:
 		EVP_PKEY_free(sess->auth.hmac.pkey);
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+		EVP_MAC_CTX_free(sess->auth.hmac.ctx);
+# else
 		HMAC_CTX_free(sess->auth.hmac.ctx);
+# endif
 		break;
 	default:
 		break;
@@ -1262,6 +1355,59 @@ process_openssl_auth(struct rte_mbuf *mbuf_src,
 uint8_t *dst, int offset,
 	return -EINVAL;
 }
 
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+/** Process standard openssl auth algorithms with hmac */
+static int
+process_openssl_auth_hmac(struct rte_mbuf *mbuf_src, uint8_t *dst, int
 offset,
+		int srclen, EVP_MAC_CTX *ctx)
+{
+	size_t dstlen;
+	struct rte_mbuf *m;
+	int l, n = srclen;
+	uint8_t *src;
+
+	for (m = mbuf_src; m != NULL && offset > rte_pktmbuf_data_len(m);
+			m = m->next)
+		offset -= rte_pktmbuf_data_len(m);
+
+	if (m == 0)
+		goto process_auth_err;
+
+	src = rte_pktmbuf_mtod_offset(m, uint8_t *, offset);
+
+	l = rte_pktmbuf_data_len(m) - offset;
+	if (srclen <= l) {
+		if (EVP_MAC_update(ctx, (unsigned char *)src, srclen) != 1)
+			goto process_auth_err;
+		goto process_auth_final;
+	}
+
+	if (EVP_MAC_update(ctx, (unsigned char *)src, l) != 1)
+		goto process_auth_err;
+
+	n -= l;
+
+	for (m = m->next; (m != NULL) && (n > 0); m = m->next) {
+		src = rte_pktmbuf_mtod(m, uint8_t *);
+		l = rte_pktmbuf_data_len(m) < n ? rte_pktmbuf_data_len(m) : n;
+		if (EVP_MAC_update(ctx, (unsigned char *)src, l) != 1)
+			goto process_auth_err;
+		n -= l;
+	}
+
+process_auth_final:
+	if (EVP_MAC_final(ctx, dst, &dstlen, sizeof(dst)) != 1)
+		goto process_auth_err;
+
+	EVP_MAC_CTX_free(ctx);
+	return 0;
+
+process_auth_err:
+	EVP_MAC_CTX_free(ctx);
+	OPENSSL_LOG(ERR, "Process openssl auth failed");
+	return -EINVAL;
+}
+# else
 /** Process standard openssl auth algorithms with hmac */

static int
process_openssl_auth_hmac(struct rte_mbuf *mbuf_src, uint8_t *dst, int
offset,

drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
@@ -1314,7 +1460,7 @@ process_openssl_auth_hmac(struct rte_mbuf
 *mbuf_src, uint8_t *dst, int offset,
 	OPENSSL_LOG(ERR, "Process openssl auth failed");
 	return -EINVAL;
 }
-
+# endif
 /*----------------------------------------------------------------------------*/
 

/** Process auth/cipher combined operation */

drivers/crypto/openssl/rte_openssl_pmd.c +19 -8
@@ -1328,7 +1474,6 @@ process_openssl_combined_op
 	int srclen, aadlen, status = -1;
 	uint32_t offset;
 	uint8_t taglen;
-	EVP_CIPHER_CTX *ctx_copy;
 
 	/*
 	 * Segmented destination buffer is not supported for
@@ -1365,8 +1510,6 @@ process_openssl_combined_op
 	}
 
 	taglen = sess->auth.digest_length;
-	ctx_copy = EVP_CIPHER_CTX_new();
-	EVP_CIPHER_CTX_copy(ctx_copy, sess->cipher.ctx);
 
 	if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1374,12 +1517,12 @@ process_openssl_combined_op
 			status = process_openssl_auth_encryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, ctx_copy);
+					dst, tag, sess->cipher.ctx);
 		else
 			status = process_openssl_auth_encryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, ctx_copy);
+					dst, tag, taglen, sess->cipher.ctx);
 
 	} else {
 		if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC ||
@@ -1387,15 +1530,14 @@ process_openssl_combined_op
 			status = process_openssl_auth_decryption_gcm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, ctx_copy);
+					dst, tag, sess->cipher.ctx);
 		else
 			status = process_openssl_auth_decryption_ccm(
 					mbuf_src, offset, srclen,
 					aad, aadlen, iv,
-					dst, tag, taglen, ctx_copy);
+					dst, tag, taglen, sess->cipher.ctx);
 	}
 
-	EVP_CIPHER_CTX_free(ctx_copy);
 	if (status != 0) {
 		if (status == (-EFAULT) &&
 				sess->auth.operation ==
@@ -1557,7 +1699,12 @@ process_openssl_auth_op(struct openssl_qp *qp,
 struct rte_crypto_op *op,
 	uint8_t *dst;
 	int srclen, status;
 	EVP_MD_CTX *ctx_a;
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+	EVP_MAC_CTX *ctx_h;
+	EVP_MAC *mac;
+# else
 	HMAC_CTX *ctx_h;
+# endif
 
 	srclen = op->sym->auth.data.length;
@@ -1573,12 +1720,22 @@ process_openssl_auth_op(struct openssl_qp *qp,
 struct rte_crypto_op *op,
 		EVP_MD_CTX_destroy(ctx_a);
 		break;
 	case OPENSSL_AUTH_AS_HMAC:
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+		mac = EVP_MAC_fetch(NULL, "HMAC", NULL);
+		ctx_h = EVP_MAC_CTX_new(mac);
+		ctx_h = EVP_MAC_CTX_dup(sess->auth.hmac.ctx);
+		EVP_MAC_free(mac);
+		status = process_openssl_auth_hmac(mbuf_src, dst,
+				op->sym->auth.data.offset, srclen,
+				ctx_h);
+# else
 		ctx_h = HMAC_CTX_new();
 		HMAC_CTX_copy(ctx_h, sess->auth.hmac.ctx);
 		status = process_openssl_auth_hmac(mbuf_src, dst,
 				op->sym->auth.data.offset, srclen,
 				ctx_h);
 		HMAC_CTX_free(ctx_h);
+# endif
 		break;
 	default:
drivers/crypto/openssl/rte_openssl_pmd.c +10 -1
 		status = -1;
@@ -2212,6 +2369,13 @@ cryptodev_openssl_create(const char *name,
 
 	rte_cryptodev_pmd_probing_finish(dev);
 
+# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+	/* Load legacy provider
+	 * Some algorithms are no longer available in earlier version of openssl,
+	 * unless the legacy provider explicitly loaded. e.g. DES
+	 */
+	ossl_load_legacy_provider();
+# endif
 	return 0;
 
 init_error:
@@ -2260,6 +2424,9 @@ cryptodev_openssl_remove(struct rte_vdev_device
 *vdev)
 	if (cryptodev == NULL)
 		return -ENODEV;
 
+# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+	ossl_unload_legacy_provider();
+# endif
 	return rte_cryptodev_pmd_destroy(cryptodev);
 }
 
--

2.17.1

#21 lore raw

RE: [EXT] [dpdk-dev v4 2/4] crypto/openssl: 3.0 EVP update on RSA routine

In reply to Kai Ji
Quoted 78 lines

This patch updates asymmetric RSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   7 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 149 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 112 +++++++++++++-
 3 files changed, 267 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +7 -0
index 86dc169aaf..d603626fdf 100644
@@ -11,6 +11,10 @@
 #include <openssl/rsa.h>
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#endif
 
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
@@ -157,6 +161,9 @@ struct openssl_asym_session {
 	union {
 		struct rsa {
 			RSA *rsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			EVP_PKEY_CTX * ctx;
+#endif
 		} r;
 		struct exp {
 			BIGNUM *exp;
drivers/crypto/openssl/rte_openssl_pmd.c +32 -0
index 5dbe6074eb..cac157aba3 100644
@@ -2046,6 +2046,150 @@ process_openssl_modexp_op(struct rte_crypto_op
 *cop,
 }
 
 /* process rsa operations */
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+static int
+process_openssl_rsa_op_evp(struct rte_crypto_op *cop,
+		struct openssl_asym_session *sess)
+{
+	struct rte_crypto_asym_op *op = cop->asym;
+	uint32_t pad = (op->rsa.padding.type);
+	uint8_t *tmp;
+	size_t outlen = 0;
+	int ret = -1;
+
+	cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+	EVP_PKEY_CTX *rsa_ctx = sess->u.r.ctx;
+	if (!rsa_ctx)
+		return ret;
+
+	switch (pad) {
+	case RTE_CRYPTO_RSA_PADDING_PKCS1_5:
+		pad = RSA_PKCS1_PADDING;
+		break;
+	case RTE_CRYPTO_RSA_PADDING_NONE:
+		pad = RSA_NO_PADDING;
+		break;
+	default:
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		OPENSSL_LOG(ERR,
+				"rsa pad type not supported %d\n", pad);
+		return ret;
+	}
+
+	switch (op->rsa.op_type) {
+	case RTE_CRYPTO_ASYM_OP_ENCRYPT:

drivers/crypto/openssl/rte_openssl_pmd.c process_openssl_modexp_op(struct rte_crypto_op · line 2091

Quoted 10 lines
drivers/crypto/openssl/rte_openssl_pmd.c +9 -0
+		if (EVP_PKEY_encrypt_init(rsa_ctx) != 1)
+			goto err_rsa;
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_encrypt(rsa_ctx, NULL, &outlen,
+							op->rsa.message.data,
+							op-
 >rsa.message.length) <= 0)

Remove extra indentation here and below also.

Cop->status is not updated in case of failure gotos.

Quoted 244 lines
drivers/crypto/openssl/rte_openssl_pmd.c +25 -0
+			goto err_rsa;
+
+		if (outlen <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_encrypt(rsa_ctx, op->rsa.cipher.data, &outlen,
+							op->rsa.message.data,
+							op-
 >rsa.message.length) <= 0)
+			goto err_rsa;
+		op->rsa.cipher.length = outlen;
+
+		OPENSSL_LOG(DEBUG,
+				"length of encrypted text %zu\n", outlen);
+		break;
+
+	case RTE_CRYPTO_ASYM_OP_DECRYPT:
+		if (EVP_PKEY_decrypt_init(rsa_ctx) != 1)
+			goto err_rsa;
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_decrypt(rsa_ctx, NULL, &outlen,
+							op->rsa.cipher.data,
+							op->rsa.cipher.length)

<= 0)

drivers/crypto/openssl/rte_openssl_pmd.c +8 -0
+			goto err_rsa;
+
+		if (outlen <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_decrypt(rsa_ctx, op->rsa.message.data, &outlen,
+							op->rsa.cipher.data,
+							op->rsa.cipher.length)

<= 0)

drivers/crypto/openssl/rte_openssl_pmd.c +4 -0
+			goto err_rsa;
+		op->rsa.message.length = outlen;
+
+		OPENSSL_LOG(DEBUG, "length of decrypted text %zu\n",

outlen);

drivers/crypto/openssl/rte_openssl_pmd.c +12 -0
+		break;
+
+	case RTE_CRYPTO_ASYM_OP_SIGN:
+		if (EVP_PKEY_sign_init(rsa_ctx) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_sign(rsa_ctx, op->rsa.sign.data, &outlen,
+							op->rsa.message.data,
+							op-
Quoted 1 line

rsa.message.length) <= 0)

drivers/crypto/openssl/rte_openssl_pmd.c +24 -0
+			goto err_rsa;
+		op->rsa.sign.length = outlen;
+		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");
+			goto err_rsa;
+		}
+
+		if (EVP_PKEY_verify_recover_init(rsa_ctx) <= 0) {
+			rte_free(tmp);
+			goto err_rsa;
+		}
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0) {
+			rte_free(tmp);
+			goto err_rsa;
+		}
+
+		if (EVP_PKEY_verify_recover(rsa_ctx, tmp, &outlen,
+							op->rsa.sign.data,
+							op->rsa.sign.length) <=

0) {

drivers/crypto/openssl/rte_openssl_pmd.c +35 -0
+			rte_free(tmp);
+			goto err_rsa;
+		}
+
+		OPENSSL_LOG(DEBUG,
+				"Length of public_decrypt %zu "
+				"length of message %zd\n",
+				outlen, op->rsa.message.length);
+		if (CRYPTO_memcmp(tmp, op->rsa.message.data,
+				op->rsa.message.length)) {
+			OPENSSL_LOG(ERR, "RSA sign Verification failed");
+		}
+		rte_free(tmp);
+		break;
+
+	default:
+		/* allow ops with invalid args to be pushed to
+		 * completion queue
+		 */
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		goto err_rsa;
+	}
+
+	ret = 0;
+	cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+err_rsa:
+	return ret;
+
+}
+#else
 static int
 process_openssl_rsa_op(struct rte_crypto_op *cop,
 		struct openssl_asym_session *sess)
@@ -2144,6 +2288,7 @@ process_openssl_rsa_op(struct rte_crypto_op *cop,
 
 	return 0;
 }
+#endif
 
 static int
 process_asym_op(struct openssl_qp *qp, struct rte_crypto_op *op,
@@ -2155,7 +2300,11 @@ process_asym_op(struct openssl_qp *qp, struct
 rte_crypto_op *op,
 
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+		retval = process_openssl_rsa_op_evp(op, sess);
+# else
 		retval = process_openssl_rsa_op(op, sess);
+#endif
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:
drivers/crypto/openssl/rte_openssl_pmd.c +0 -0
 		retval = process_openssl_modexp_op(op, sess);
drivers/crypto/openssl/rte_openssl_pmd_ops.c +62 -1
index 7d0da52a33..6d94da499e 100644
@@ -12,7 +12,11 @@
 
 #include "openssl_pmd_private.h"
 #include "compat.h"
-
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#include <openssl/param_build.h>
+#endif
 
 static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
 	{	/* MD5 HMAC */
@@ -835,6 +839,106 @@ static int openssl_set_asym_session_parameters(
 		if (!n || !e)
 			goto err_rsa;
 
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+		OSSL_PARAM_BLD * param_bld = OSSL_PARAM_BLD_new();
+		if (!param_bld) {
+			OPENSSL_LOG(ERR, "failed to allocate resources\n");
+			goto err_rsa;
+		}
+
+		if (!OSSL_PARAM_BLD_push_BN(param_bld,
 OSSL_PKEY_PARAM_RSA_N, n)
+			|| !OSSL_PARAM_BLD_push_BN(param_bld,
+					OSSL_PKEY_PARAM_RSA_E, e)) {
+			OSSL_PARAM_BLD_free(param_bld);
+			OPENSSL_LOG(ERR, "failed to allocate resources\n");
+			goto err_rsa;
+		}
+
+		if (xform->rsa.key_type == RTE_RSA_KEY_TYPE_EXP) {
+			d = BN_bin2bn(
+			(const unsigned char *)xform->rsa.d.data,
+			xform->rsa.d.length,
+			d);
+			if (!d) {
+				OSSL_PARAM_BLD_free(param_bld);
+				goto err_rsa;
+			}
+		} else {
+			p = BN_bin2bn((const unsigned char *)
+					xform->rsa.qt.p.data,
+					xform->rsa.qt.p.length,
+					p);
+			q = BN_bin2bn((const unsigned char *)
+					xform->rsa.qt.q.data,
+					xform->rsa.qt.q.length,
+					q);
+			dmp1 = BN_bin2bn((const unsigned char *)
+					xform->rsa.qt.dP.data,
+					xform->rsa.qt.dP.length,
+					dmp1);
+			dmq1 = BN_bin2bn((const unsigned char *)
+					xform->rsa.qt.dQ.data,
+					xform->rsa.qt.dQ.length,
+					dmq1);
+			iqmp = BN_bin2bn((const unsigned char *)
+					xform->rsa.qt.qInv.data,
+					xform->rsa.qt.qInv.length,
+					iqmp);
+
+			if (!p || !q || !dmp1 || !dmq1 || !iqmp) {
+				OSSL_PARAM_BLD_free(param_bld);
+				goto err_rsa;
+			}
+
+			if (!OSSL_PARAM_BLD_push_BN(param_bld,
+
 	OSSL_PKEY_PARAM_RSA_FACTOR1, p)
+				|| !OSSL_PARAM_BLD_push_BN(param_bld,
+
 	OSSL_PKEY_PARAM_RSA_FACTOR2, q)
+				|| !OSSL_PARAM_BLD_push_BN(param_bld,
+

OSSL_PKEY_PARAM_RSA_EXPONENT1, dmp1)

drivers/crypto/openssl/rte_openssl_pmd_ops.c +2 -0
+				|| !OSSL_PARAM_BLD_push_BN(param_bld,
+

OSSL_PKEY_PARAM_RSA_EXPONENT2, dmq1)

drivers/crypto/openssl/rte_openssl_pmd_ops.c +2 -0
+				|| !OSSL_PARAM_BLD_push_BN(param_bld,
+
	OSSL_PKEY_PARAM_RSA_COEFFICIENT1, iqmp)) {
drivers/crypto/openssl/rte_openssl_pmd_ops.c +6 -0
+				OSSL_PARAM_BLD_free(param_bld);
+				goto err_rsa;
+			}
+		}
+
+		if (!OSSL_PARAM_BLD_push_BN(param_bld,

OSSL_PKEY_PARAM_RSA_N, n)

drivers/crypto/openssl/rte_openssl_pmd_ops.c +1 -0
+			|| !OSSL_PARAM_BLD_push_BN(param_bld,

OSSL_PKEY_PARAM_RSA_E, e)

drivers/crypto/openssl/rte_openssl_pmd_ops.c +2 -0
+			|| !OSSL_PARAM_BLD_push_BN(param_bld,
+						OSSL_PKEY_PARAM_RSA_D,

d)) {

drivers/crypto/openssl/rte_openssl_pmd_ops.c +5 -0
+			OSSL_PARAM_BLD_free(param_bld);
+			goto err_rsa;
+		}
+
+		EVP_PKEY_CTX *key_ctx =

EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL);

drivers/crypto/openssl/rte_openssl_pmd_ops.c +4 -0
+		EVP_PKEY *pkey = NULL;
+		EVP_PKEY_CTX *rsa_ctx = NULL;
+		OSSL_PARAM *params = NULL;
+

drivers/crypto/openssl/rte_openssl_pmd_ops.c static int openssl_set_asym_session_parameters( · line 930

Quoted 10 lines
drivers/crypto/openssl/rte_openssl_pmd_ops.c +10 -0
+		params = OSSL_PARAM_BLD_to_param(param_bld);
+		if (!params) {
+			OSSL_PARAM_BLD_free(param_bld);
+			goto err_rsa;
+		}
+
+		if (key_ctx == NULL
+			|| EVP_PKEY_fromdata_init(key_ctx) <= 0
+			|| EVP_PKEY_fromdata(key_ctx, &pkey,
+					EVP_PKEY_KEYPAIR, params) <= 0) {

Indentation not correct above.

Quoted 39 lines
drivers/crypto/openssl/rte_openssl_pmd_ops.c +17 -0
+			OSSL_PARAM_free(params);
+			goto err_rsa;
+		}
+
+		rsa_ctx = EVP_PKEY_CTX_new(pkey, NULL);
+		asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_RSA;
+		asym_session->u.r.ctx = rsa_ctx;
+		EVP_PKEY_CTX_free(key_ctx);
+		OSSL_PARAM_free(params);
+		break;
+#else
 		RSA *rsa = RSA_new();
 		if (rsa == NULL)
 			goto err_rsa;
@@ -904,6 +1008,7 @@ static int openssl_set_asym_session_parameters(
 		asym_session->u.r.rsa = rsa;
 		asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_RSA;
 		break;
+#endif
 err_rsa:
 		BN_clear_free(n);
 		BN_clear_free(e);
@@ -1135,8 +1240,13 @@ static void openssl_reset_asym_session(struct
 openssl_asym_session *sess)
 {
 	switch (sess->xfrm_type) {
 	case RTE_CRYPTO_ASYM_XFORM_RSA:
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+		if (sess->u.r.ctx)
+			EVP_PKEY_CTX_free(sess->u.r.ctx);
+#else
 		if (sess->u.r.rsa)
 			RSA_free(sess->u.r.rsa);
+#endif
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_MODEX:

if (sess->u.e.ctx) {
--
2.17.1

#27 lore raw

RE: [EXT] [dpdk-dev v4 0/4] crypto/openssl: EVP api update for 3.0 lib

In reply to Kai Ji
Quoted 21 lines

This patch set update openssl pmd deprecated APIs to EVP APIs where supported in openssl 3.0 lib

---
v4:
- compilation issue fix

v3:
- rebase to 22.07 rc1

v2:
- addin DSA routine

---

Kai Ji (4):
crypto/openssl: 3.0 EVP update on HMAC routine
crypto/openssl: 3.0 EVP update on RSA routine
crypto/openssl: 3.0 EVP update on DH routine
crypto/openssl: 3.0 EVP update on DSA routine

Quoted 6 lines
 app/test/test_cryptodev_asym.c               |  90 ++-
 drivers/crypto/openssl/compat.h              |  12 +
 drivers/crypto/openssl/openssl_pmd_private.h |  18 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 698 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 231 +++++-
 5 files changed, 1013 insertions(+), 36 deletions(-)

Add release notes too to highlight 3.0 support.

author
#22 lore raw

RE: [EXT] [dpdk-dev v4 2/4] crypto/openssl: 3.0 EVP update on RSA routine

In reply to Akhil Goyal
Quoted 51 lines

-----Original Message-----

drivers/crypto/openssl/rte_openssl_pmd.c process_openssl_modexp_op(struct

Quoted 3 lines
drivers/crypto/openssl/rte_openssl_pmd.c +0 -0
@@ -2046,6 +2046,150 @@ process_openssl_modexp_op(struct

rte_crypto_op

Quoted 44 lines
drivers/crypto/openssl/rte_openssl_pmd.c +40 -0
 *cop,  }
 
 /* process rsa operations */
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) static int
+process_openssl_rsa_op_evp(struct rte_crypto_op *cop,
+		struct openssl_asym_session *sess)
+{
+	struct rte_crypto_asym_op *op = cop->asym;
+	uint32_t pad = (op->rsa.padding.type);
+	uint8_t *tmp;
+	size_t outlen = 0;
+	int ret = -1;
+
+	cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+	EVP_PKEY_CTX *rsa_ctx = sess->u.r.ctx;
+	if (!rsa_ctx)
+		return ret;
+
+	switch (pad) {
+	case RTE_CRYPTO_RSA_PADDING_PKCS1_5:
+		pad = RSA_PKCS1_PADDING;
+		break;
+	case RTE_CRYPTO_RSA_PADDING_NONE:
+		pad = RSA_NO_PADDING;
+		break;
+	default:
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		OPENSSL_LOG(ERR,
+				"rsa pad type not supported %d\n", pad);
+		return ret;
+	}
+
+	switch (op->rsa.op_type) {
+	case RTE_CRYPTO_ASYM_OP_ENCRYPT:
+		if (EVP_PKEY_encrypt_init(rsa_ctx) != 1)
+			goto err_rsa;
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_encrypt(rsa_ctx, NULL, &outlen,
+							op-
 rsa.message.data,
+							op-
Quoted 6 lines

drivers/crypto/openssl/rte_openssl_pmd.c process_openssl_modexp_op(struct · line 2090

Quoted 1 line
drivers/crypto/openssl/rte_openssl_pmd.c +0 -0
 >rsa.message.length) <= 0)

Remove extra indentation here and below also.

Cop->status is not updated in case of failure gotos.

Cop->status was assigned RTE_CRYPTO_OP_STATUS_ERROR at the top of this func, and only change to RTE_CRYPTO_OP_STATUS_SUCCESS before the return when no failure.

Quoted 115 lines
Quoted 29 lines
drivers/crypto/openssl/rte_openssl_pmd.c +8 -0
+			goto err_rsa;
+
+		if (outlen <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_encrypt(rsa_ctx, op->rsa.cipher.data, &outlen,
+							op-
 rsa.message.data,
+							op-
Quoted 1 line

rsa.message.length) <= 0)

drivers/crypto/openssl/rte_openssl_pmd.c +17 -0
+			goto err_rsa;
+		op->rsa.cipher.length = outlen;
+
+		OPENSSL_LOG(DEBUG,
+				"length of encrypted text %zu\n", outlen);
+		break;
+
+	case RTE_CRYPTO_ASYM_OP_DECRYPT:
+		if (EVP_PKEY_decrypt_init(rsa_ctx) != 1)
+			goto err_rsa;
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_decrypt(rsa_ctx, NULL, &outlen,
+							op->rsa.cipher.data,
+							op->rsa.cipher.length)

<= 0)

drivers/crypto/openssl/rte_openssl_pmd.c process_openssl_modexp_op(struct rte_crypto_op *cop,

Quoted 6 lines
drivers/crypto/openssl/rte_openssl_pmd.c +6 -0
+			goto err_rsa;
+
+		if (outlen <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_decrypt(rsa_ctx, op->rsa.message.data,

&outlen,

Quoted 36 lines
drivers/crypto/openssl/rte_openssl_pmd.c +2 -0
+							op->rsa.cipher.data,
+							op->rsa.cipher.length)

<= 0)

drivers/crypto/openssl/rte_openssl_pmd.c +4 -0
+			goto err_rsa;
+		op->rsa.message.length = outlen;
+
+		OPENSSL_LOG(DEBUG, "length of decrypted text %zu\n",

outlen);

drivers/crypto/openssl/rte_openssl_pmd.c +11 -0
+		break;
+
+	case RTE_CRYPTO_ASYM_OP_SIGN:
+		if (EVP_PKEY_sign_init(rsa_ctx) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0)
+			goto err_rsa;
+
+		if (EVP_PKEY_sign(rsa_ctx, op->rsa.sign.data, &outlen,
+							op-

rsa.message.data,

drivers/crypto/openssl/rte_openssl_pmd.c +1 -0
+							op-
Quoted 1 line

rsa.message.length) <= 0)

drivers/crypto/openssl/rte_openssl_pmd.c +14 -0
+			goto err_rsa;
+		op->rsa.sign.length = outlen;
+		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");
+			goto err_rsa;
+		}
+
+		if (EVP_PKEY_verify_recover_init(rsa_ctx) <= 0) {
+			rte_free(tmp);
+			goto err_rsa;

drivers/crypto/openssl/rte_openssl_pmd.c process_openssl_modexp_op(struct rte_crypto_op *cop,

Quoted 10 lines
drivers/crypto/openssl/rte_openssl_pmd.c +10 -0
+		}
+
+		if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0) {
+			rte_free(tmp);
+			goto err_rsa;
+		}
+
+		if (EVP_PKEY_verify_recover(rsa_ctx, tmp, &outlen,
+							op->rsa.sign.data,
+							op->rsa.sign.length)

<=

Quoted 32 lines

0) {

drivers/crypto/openssl/rte_openssl_pmd.c +29 -1
+			rte_free(tmp);
+			goto err_rsa;
+		}
+
+		OPENSSL_LOG(DEBUG,
+				"Length of public_decrypt %zu "
+				"length of message %zd\n",
+				outlen, op->rsa.message.length);
+		if (CRYPTO_memcmp(tmp, op->rsa.message.data,
+				op->rsa.message.length)) {
+			OPENSSL_LOG(ERR, "RSA sign Verification failed");
+		}
+		rte_free(tmp);
+		break;
+
+	default:
+		/* allow ops with invalid args to be pushed to
+		 * completion queue
+		 */
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		goto err_rsa;
+	}
+
+	ret = 0;
+	cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+err_rsa:
+	return ret;
+
+}
--

2.17.1

author
#28 lore raw

v5 cover crypto/openssl: EVP api update for 3.0 lib

In reply to Kai Ji

This patch set update openssl pmd deprecated APIs to EVP APIs where supported in openssl 3.0 lib

---
v5:
- review comments fix and release notes update

v4:
- compilation issue fix

v3:
- rebase to 22.07 rc1

v2:
- addin DSA routine

---

Kai Ji (4):
crypto/openssl: update on HMAC routine with 3.0 EVP API crypto/openssl: update on RSA routine with 3.0 EVP API crypto/openssl: update on DH routine with 3.0 EVP API crypto/openssl: update on DSA routine with 3.0 EVP API

 app/test/test_cryptodev_asym.c               |  90 ++-
 doc/guides/rel_notes/release_22_07.rst       |   4 +
 drivers/crypto/openssl/compat.h              |  12 +
 drivers/crypto/openssl/openssl_pmd_private.h |  18 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 698 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 231 +++++-
 6 files changed, 1017 insertions(+), 36 deletions(-)

--
2.17.1

author
#29 lore raw

PATCH v5 1/4 crypto/openssl: update on HMAC routine with 3.0 EVP API

This patch update the symmetric HMAC routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 187 ++++++++++++++++++-
 2 files changed, 181 insertions(+), 10 deletions(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index b2054b3754..6bcfb584a4 100644
@@ -134,7 +134,11 @@ struct openssl_session {
 				/**< pointer to EVP key */
 				const EVP_MD *evp_algo;
 				/**< pointer to EVP algorithm function */
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+				EVP_MAC_CTX * ctx;
+# else
 				HMAC_CTX *ctx;
+# endif
 				/**< pointer to EVP context structure */
 			} hmac;
 		};
drivers/crypto/openssl/rte_openssl_pmd.c +177 -10

289 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#30 lore raw

PATCH v5 2/4 crypto/openssl: update on RSA routine with 3.0 EVP API

In reply to Kai Ji

This patch updates asymmetric RSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   7 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 149 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 112 +++++++++++++-
 3 files changed, 267 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +7 -0
index 6bcfb584a4..9d4ac721a7 100644
@@ -11,6 +11,10 @@
 #include <openssl/rsa.h>
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#endif
 
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
@@ -157,6 +161,9 @@ struct openssl_asym_session {
 	union {
 		struct rsa {
 			RSA *rsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			EVP_PKEY_CTX * ctx;
+#endif
 		} r;
 		struct exp {
 			BIGNUM *exp;
drivers/crypto/openssl/rte_openssl_pmd.c +149 -0

168 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +111 -1

138 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#31 lore raw

PATCH v5 3/4 crypto/openssl: update on DH routine with 3.0 EVP API

In reply to Kai Ji

This patch updates asymmetric DH routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 185 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  47 ++++-
 3 files changed, 235 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index 9d4ac721a7..b952188c9d 100644
@@ -177,6 +177,10 @@ struct openssl_asym_session {
 		struct dh {
 			DH *dh_key;
 			uint32_t key_op;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+			OSSL_PARAM_BLD *param_bld_peer;
+#endif
 		} dh;
 		struct {
 			DSA *dsa;
drivers/crypto/openssl/rte_openssl_pmd.c +185 -0

210 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +46 -1

67 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#32 lore raw

PATCH v5 4/4 crypto/openssl: update on DSA routine with 3.0 EVP API

In reply to Kai Ji

This patch updates asymmetric DSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis. Divide the single combined dsa sign test to two individual dsa sign and dsa verfiy tests.

---
 app/test/test_cryptodev_asym.c               |  90 ++++++++--
 doc/guides/rel_notes/release_22_07.rst       |   4 +
 drivers/crypto/openssl/compat.h              |  12 ++
 drivers/crypto/openssl/openssl_pmd_private.h |   3 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 177 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  72 +++++++-
 6 files changed, 334 insertions(+), 24 deletions(-)
app/test/test_cryptodev_asym.c +77 -13
index 7bd7cde16e..c9c48d1e87 100644
@@ -1642,7 +1642,7 @@ test_dh_keygenration(void)
 }
 
 static int
-test_dsa_sign(void)
+test_dsa_sign(struct rte_crypto_dsa_op_param *dsa_op)
 {
 	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
 	struct rte_mempool *op_mpool = ts_params->op_mpool;
@@ -1652,9 +1652,6 @@ test_dsa_sign(void)
 	struct rte_crypto_op *op = NULL, *result_op = NULL;
 	void *sess = NULL;
 	int status = TEST_SUCCESS;
-	uint8_t r[TEST_DH_MOD_LEN];
-	uint8_t s[TEST_DH_MOD_LEN];
-	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
 	int ret;
 
 	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
@@ -1676,6 +1673,7 @@ test_dsa_sign(void)
 		goto error_exit;
 	}
 	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
 
 	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
 			dsa_xform.dsa.p.length);
@@ -1689,13 +1687,6 @@ test_dsa_sign(void)
 	/* attach asymmetric crypto session to crypto operations */
 	rte_crypto_op_attach_asym_session(op, sess);
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
-	asym_op->dsa.message.data = dgst;
-	asym_op->dsa.message.length = sizeof(dgst);
-	asym_op->dsa.r.length = sizeof(r);
-	asym_op->dsa.r.data = r;
-	asym_op->dsa.s.length = sizeof(s);
-	asym_op->dsa.s.data = s;
-
 	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
 
 	/* Process crypto operation */
@@ -1719,12 +1710,71 @@ test_dsa_sign(void)
 	}
 
 	asym_op = result_op->asym;
+	dsa_op->r.length = asym_op->dsa.r.length;
+	dsa_op->s.length = asym_op->dsa.s.length;
 
 	debug_hexdump(stdout, "r:",
 			asym_op->dsa.r.data, asym_op->dsa.r.length);
 	debug_hexdump(stdout, "s:",
 			asym_op->dsa.s.data, asym_op->dsa.s.length);
+error_exit:
+	if (sess != NULL)
+		rte_cryptodev_asym_session_free(dev_id, sess);
+	if (op != NULL)
+		rte_crypto_op_free(op);
+	return status;
+}
+
+static int
+test_dsa_verify(struct rte_crypto_dsa_op_param *dsa_op)
+{
+	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	void *sess = NULL;
+	int status = TEST_SUCCESS;
+	int ret;
 
+	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
+	if (ret < 0) {
+		RTE_LOG(ERR, USER1,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
+
+	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
+			dsa_xform.dsa.p.length);
+	debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
+			dsa_xform.dsa.q.length);
+	debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
+			dsa_xform.dsa.g.length);
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	debug_hexdump(stdout, "r:",
+			asym_op->dsa.r.data, asym_op->dsa.r.length);
+	debug_hexdump(stdout, "s:",
+			asym_op->dsa.s.data, asym_op->dsa.s.length);
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM verify operation");
 	/* Test PMD DSA sign verification using signer public key */
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
 
@@ -1770,8 +1820,22 @@ static int
 test_dsa(void)
 {
 	int status;
-	status = test_dsa_sign();
-	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+	uint8_t r[TEST_DH_MOD_LEN];
+	uint8_t s[TEST_DH_MOD_LEN];
+	struct rte_crypto_dsa_op_param dsa_op;
+	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
+
+	dsa_op.message.data = dgst;
+	dsa_op.message.length = sizeof(dgst);
+	dsa_op.r.data = r;
+	dsa_op.s.data = s;
+	dsa_op.r.length = sizeof(r);
+	dsa_op.s.length = sizeof(s);
+
+	status = test_dsa_sign(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA sign test failed");
+	status = test_dsa_verify(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA verify test failed");
 	return status;
 }
 
doc/guides/rel_notes/release_22_07.rst +4 -0
index 6fc044edaa..180cbd84c4 100644
@@ -215,6 +215,10 @@ New Features
   Merged l3fwd-acl code into l3fwd as l3fwd-acl contains duplicate
   and common functions to l3fwd.
 
+* **Update Openssl PMD with 3.0 EVP API
+
+  Update Openssl PMD deprecated APIs to EVP APIs where supported in Openssl
+  3.0 lib.
 
 Removed Items
 -------------
drivers/crypto/openssl/compat.h +12 -0
index eecb7d3698..9f9167c4f1 100644
@@ -104,6 +104,18 @@ get_dsa_priv_key(DSA *dsa, BIGNUM **priv_key)
 	*priv_key = dsa->priv_key;
 }
 
+#elif (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+static __rte_always_inline void
+set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
+{
+	DSA_SIG_set0(sign, r, s);
+}
+
+static __rte_always_inline void
+get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
+{
+	DSA_SIG_get0(sign, r, s);
+}
 #else
 
 static __rte_always_inline int
drivers/crypto/openssl/openssl_pmd_private.h +3 -0
index b952188c9d..5963a67a08 100644
@@ -184,6 +184,9 @@ struct openssl_asym_session {
 		} dh;
 		struct {
 			DSA *dsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+#endif
 		} s;
 	} u;
 } __rte_cache_aligned;
drivers/crypto/openssl/rte_openssl_pmd.c +175 -2

207 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +63 -9

139 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#33 lore raw

v5 cover crypto/openssl: EVP api update for 3.0 lib

In reply to Kai Ji

This patch set update openssl pmd deprecated APIs to EVP APIs where supported in openssl 3.0 lib

---
v5:
- review comments fix and release notes update

v4:
- compilation issue fix

v3:
- rebase to 22.07 rc1

v2:
- addin DSA routine

---

Kai Ji (4):
crypto/openssl: update on HMAC routine with 3.0 EVP API crypto/openssl: update on RSA routine with 3.0 EVP API crypto/openssl: update on DH routine with 3.0 EVP API crypto/openssl: update on DSA routine with 3.0 EVP API

 app/test/test_cryptodev_asym.c               |  90 ++-
 doc/guides/rel_notes/release_22_07.rst       |   4 +
 drivers/crypto/openssl/compat.h              |  12 +
 drivers/crypto/openssl/openssl_pmd_private.h |  18 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 698 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 231 +++++-
 6 files changed, 1017 insertions(+), 36 deletions(-)

--
2.17.1

author
#34 lore raw

PATCH v5 1/4 crypto/openssl: update on HMAC routine with 3.0 EVP API

This patch update the symmetric HMAC routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 187 ++++++++++++++++++-
 2 files changed, 181 insertions(+), 10 deletions(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index b2054b3754..6bcfb584a4 100644
@@ -134,7 +134,11 @@ struct openssl_session {
 				/**< pointer to EVP key */
 				const EVP_MD *evp_algo;
 				/**< pointer to EVP algorithm function */
+# if OPENSSL_VERSION_NUMBER >= 0x30000000L
+				EVP_MAC_CTX * ctx;
+# else
 				HMAC_CTX *ctx;
+# endif
 				/**< pointer to EVP context structure */
 			} hmac;
 		};
drivers/crypto/openssl/rte_openssl_pmd.c +177 -10

289 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#35 lore raw

PATCH v5 2/4 crypto/openssl: update on RSA routine with 3.0 EVP API

In reply to Kai Ji

This patch updates asymmetric RSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   7 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 149 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 112 +++++++++++++-
 3 files changed, 267 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +7 -0
index 6bcfb584a4..9d4ac721a7 100644
@@ -11,6 +11,10 @@
 #include <openssl/rsa.h>
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+#include <openssl/provider.h>
+#include <openssl/core_names.h>
+#endif
 
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
@@ -157,6 +161,9 @@ struct openssl_asym_session {
 	union {
 		struct rsa {
 			RSA *rsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			EVP_PKEY_CTX * ctx;
+#endif
 		} r;
 		struct exp {
 			BIGNUM *exp;
drivers/crypto/openssl/rte_openssl_pmd.c +149 -0

168 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +111 -1

138 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#36 lore raw

PATCH v5 3/4 crypto/openssl: update on DH routine with 3.0 EVP API

In reply to Kai Ji

This patch updates asymmetric DH routine in crypto openssl pmd to adopt openssl 3.0 EVP apis.

---
 drivers/crypto/openssl/openssl_pmd_private.h |   4 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 185 +++++++++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  47 ++++-
 3 files changed, 235 insertions(+), 1 deletion(-)
drivers/crypto/openssl/openssl_pmd_private.h +4 -0
index 9d4ac721a7..b952188c9d 100644
@@ -177,6 +177,10 @@ struct openssl_asym_session {
 		struct dh {
 			DH *dh_key;
 			uint32_t key_op;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+			OSSL_PARAM_BLD *param_bld_peer;
+#endif
 		} dh;
 		struct {
 			DSA *dsa;
drivers/crypto/openssl/rte_openssl_pmd.c +185 -0

210 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +46 -1

67 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#37 lore raw

PATCH v5 4/4 crypto/openssl: update on DSA routine with 3.0 EVP API

In reply to Kai Ji

This patch updates asymmetric DSA routine in crypto openssl pmd to adopt openssl 3.0 EVP apis. Divide the single combined dsa sign test to two individual dsa sign and dsa verfiy tests.

---
 app/test/test_cryptodev_asym.c               |  90 ++++++++--
 doc/guides/rel_notes/release_22_07.rst       |   4 +
 drivers/crypto/openssl/compat.h              |  12 ++
 drivers/crypto/openssl/openssl_pmd_private.h |   3 +
 drivers/crypto/openssl/rte_openssl_pmd.c     | 177 ++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  72 +++++++-
 6 files changed, 334 insertions(+), 24 deletions(-)
app/test/test_cryptodev_asym.c +77 -13
index 7bd7cde16e..c9c48d1e87 100644
@@ -1642,7 +1642,7 @@ test_dh_keygenration(void)
 }
 
 static int
-test_dsa_sign(void)
+test_dsa_sign(struct rte_crypto_dsa_op_param *dsa_op)
 {
 	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
 	struct rte_mempool *op_mpool = ts_params->op_mpool;
@@ -1652,9 +1652,6 @@ test_dsa_sign(void)
 	struct rte_crypto_op *op = NULL, *result_op = NULL;
 	void *sess = NULL;
 	int status = TEST_SUCCESS;
-	uint8_t r[TEST_DH_MOD_LEN];
-	uint8_t s[TEST_DH_MOD_LEN];
-	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
 	int ret;
 
 	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
@@ -1676,6 +1673,7 @@ test_dsa_sign(void)
 		goto error_exit;
 	}
 	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
 
 	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
 			dsa_xform.dsa.p.length);
@@ -1689,13 +1687,6 @@ test_dsa_sign(void)
 	/* attach asymmetric crypto session to crypto operations */
 	rte_crypto_op_attach_asym_session(op, sess);
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
-	asym_op->dsa.message.data = dgst;
-	asym_op->dsa.message.length = sizeof(dgst);
-	asym_op->dsa.r.length = sizeof(r);
-	asym_op->dsa.r.data = r;
-	asym_op->dsa.s.length = sizeof(s);
-	asym_op->dsa.s.data = s;
-
 	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
 
 	/* Process crypto operation */
@@ -1719,12 +1710,71 @@ test_dsa_sign(void)
 	}
 
 	asym_op = result_op->asym;
+	dsa_op->r.length = asym_op->dsa.r.length;
+	dsa_op->s.length = asym_op->dsa.s.length;
 
 	debug_hexdump(stdout, "r:",
 			asym_op->dsa.r.data, asym_op->dsa.r.length);
 	debug_hexdump(stdout, "s:",
 			asym_op->dsa.s.data, asym_op->dsa.s.length);
+error_exit:
+	if (sess != NULL)
+		rte_cryptodev_asym_session_free(dev_id, sess);
+	if (op != NULL)
+		rte_crypto_op_free(op);
+	return status;
+}
+
+static int
+test_dsa_verify(struct rte_crypto_dsa_op_param *dsa_op)
+{
+	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	void *sess = NULL;
+	int status = TEST_SUCCESS;
+	int ret;
 
+	ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
+	if (ret < 0) {
+		RTE_LOG(ERR, USER1,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		RTE_LOG(ERR, USER1,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	asym_op->dsa = *dsa_op;
+
+	debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
+			dsa_xform.dsa.p.length);
+	debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
+			dsa_xform.dsa.q.length);
+	debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
+			dsa_xform.dsa.g.length);
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	debug_hexdump(stdout, "r:",
+			asym_op->dsa.r.data, asym_op->dsa.r.length);
+	debug_hexdump(stdout, "s:",
+			asym_op->dsa.s.data, asym_op->dsa.s.length);
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM verify operation");
 	/* Test PMD DSA sign verification using signer public key */
 	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
 
@@ -1770,8 +1820,22 @@ static int
 test_dsa(void)
 {
 	int status;
-	status = test_dsa_sign();
-	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+	uint8_t r[TEST_DH_MOD_LEN];
+	uint8_t s[TEST_DH_MOD_LEN];
+	struct rte_crypto_dsa_op_param dsa_op;
+	uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
+
+	dsa_op.message.data = dgst;
+	dsa_op.message.length = sizeof(dgst);
+	dsa_op.r.data = r;
+	dsa_op.s.data = s;
+	dsa_op.r.length = sizeof(r);
+	dsa_op.s.length = sizeof(s);
+
+	status = test_dsa_sign(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA sign test failed");
+	status = test_dsa_verify(&dsa_op);
+	TEST_ASSERT_EQUAL(status, 0, "DSA verify test failed");
 	return status;
 }
 
doc/guides/rel_notes/release_22_07.rst +4 -0
index 6fc044edaa..92eb88d929 100644
@@ -215,6 +215,10 @@ New Features
   Merged l3fwd-acl code into l3fwd as l3fwd-acl contains duplicate
   and common functions to l3fwd.
 
+* **Update Openssl PMD with 3.0 EVP API.**
+
+  Update Openssl PMD deprecated APIs to EVP APIs where supported in Openssl
+  3.0 lib.
 
 Removed Items
 -------------
drivers/crypto/openssl/compat.h +12 -0
index eecb7d3698..9f9167c4f1 100644
@@ -104,6 +104,18 @@ get_dsa_priv_key(DSA *dsa, BIGNUM **priv_key)
 	*priv_key = dsa->priv_key;
 }
 
+#elif (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+static __rte_always_inline void
+set_dsa_sign(DSA_SIG *sign, BIGNUM *r, BIGNUM *s)
+{
+	DSA_SIG_set0(sign, r, s);
+}
+
+static __rte_always_inline void
+get_dsa_sign(DSA_SIG *sign, const BIGNUM **r, const BIGNUM **s)
+{
+	DSA_SIG_get0(sign, r, s);
+}
 #else
 
 static __rte_always_inline int
drivers/crypto/openssl/openssl_pmd_private.h +3 -0
index b952188c9d..5963a67a08 100644
@@ -184,6 +184,9 @@ struct openssl_asym_session {
 		} dh;
 		struct {
 			DSA *dsa;
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+			OSSL_PARAM_BLD * param_bld;
+#endif
 		} s;
 	} u;
 } __rte_cache_aligned;
drivers/crypto/openssl/rte_openssl_pmd.c +175 -2

207 lines not on this page · raw message

drivers/crypto/openssl/rte_openssl_pmd_ops.c +63 -9

139 lines not on this page · raw message

Signature · 1 line
2.17.1
Acked-by on the v5 series Applied
#38 lore raw

RE: [EXT] [dpdk-dev v5 0/4] crypto/openssl: EVP api update for 3.0 lib

In reply to Kai Ji
Quoted 6 lines

This patch set update openssl pmd deprecated APIs to EVP APIs where supported in openssl 3.0 lib

---
v5:
- review comments fix and release notes update

Added Fan's Ack from previous version, updated release notes.

Applied to dpdk-next-crypto
Thanks.