DPDK patches and discussions
 help / color / mirror / Atom feed
From: Arek Kusztal <arkadiuszx.kusztal@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, anoobj@marvell.com, roy.fan.zhang@intel.com,
	Arek Kusztal <arkadiuszx.kusztal@intel.com>
Subject: [PATCH 40/40] test/crypto: added test for dh priv key generation
Date: Fri, 20 May 2022 06:54:45 +0100	[thread overview]
Message-ID: <20220520055445.40063-41-arkadiuszx.kusztal@intel.com> (raw)
In-Reply-To: <20220520055445.40063-1-arkadiuszx.kusztal@intel.com>

- re-added test for dh private gey generation.
This time zero length of priv key determines if key is
generated.

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
 app/test/test_cryptodev_asym.c | 90 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index ed86eaf8ba..3a562eb443 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -1290,6 +1290,90 @@ test_dh_gen_pub_key(struct rte_crypto_asym_xform *xfrm)
 }
 
 static int
+test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm)
+{
+	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 ret, status = TEST_SUCCESS;
+	uint8_t out_pub_key[TEST_DH_MOD_LEN];
+	uint8_t out_prv_key[TEST_DH_MOD_LEN];
+	struct rte_crypto_asym_xform xform = *xfrm;
+
+	/* 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;
+	/* Setup a xform chain to generate
+	 * private key first followed by
+	 * public key
+	 */
+
+	asym_op->dh.op_type = RTE_CRYPTO_ASYM_KE_PUBLIC_KEY_GENERATE;
+	asym_op->dh.pub_key.data = out_pub_key;
+	asym_op->dh.pub_key.length = sizeof(out_pub_key);
+	asym_op->dh.priv_key.data = out_prv_key;
+	asym_op->dh.priv_key.length = 0;
+
+	ret = rte_cryptodev_asym_session_create(dev_id, &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;
+	}
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	RTE_LOG(DEBUG, USER1, "Process ASYM operation");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		RTE_LOG(ERR, USER1,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		RTE_LOG(ERR, USER1,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	debug_hexdump(stdout, "priv key:",
+			out_prv_key, asym_op->dh.priv_key.length);
+	debug_hexdump(stdout, "pub key:",
+			out_pub_key, asym_op->dh.pub_key.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_mod_inv(void)
 {
 	struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
@@ -1525,6 +1609,12 @@ test_dh_keygenration(void)
 			dh_test_params.priv_key.length);
 
 	RTE_LOG(INFO, USER1,
+		"Test Public and Private key pair generation\n");
+
+	status = test_dh_gen_kp(&dh_xform);
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	RTE_LOG(INFO, USER1,
 		"Test Public Key Generation using pre-defined priv key\n");
 
 	status = test_dh_gen_pub_key(&dh_xform);
-- 
2.13.6


  parent reply	other threads:[~2022-05-20  7:06 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  5:54 [PATCH 00/40] cryptodev: rsa, dh, ecdh changes Arek Kusztal
2022-05-20  5:54 ` [PATCH 01/40] cryptodev: redefine ec group enum Arek Kusztal
2022-05-20  5:54 ` [PATCH 02/40] cryptodev: remove list end enumerators Arek Kusztal
2022-05-20  7:19   ` [EXT] " Akhil Goyal
2022-05-20  5:54 ` [PATCH 03/40] test/crypto: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 04/40] cryptodev: reduce number of comments in asym xform Arek Kusztal
2022-05-24 10:59   ` [EXT] " Akhil Goyal
2022-05-24 17:37     ` Kusztal, ArkadiuszX
2022-05-25  5:44       ` Akhil Goyal
2022-05-20  5:54 ` [PATCH 05/40] test/crypto: removed asym xform none Arek Kusztal
2022-05-20  5:54 ` [PATCH 06/40] cryptodev: separate key exchange operation enum Arek Kusztal
2022-05-24 11:45   ` [EXT] " Akhil Goyal
2022-05-20  5:54 ` [PATCH 07/40] crypto/openssl: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 08/40] test/crypto: " Arek Kusztal
2022-05-20  7:18   ` [EXT] " Akhil Goyal
2022-05-20  5:54 ` [PATCH 09/40] cryptodev: remove unnecessary zero assignement Arek Kusztal
2022-05-20  7:13   ` [EXT] " Akhil Goyal
2022-05-20  5:54 ` [PATCH 10/40] cryptodev: remove comment about using ephemeral key in dsa Arek Kusztal
2022-05-20  5:54 ` [PATCH 11/40] cryptodev: remove asym crypto next xform Arek Kusztal
2022-05-20  7:22   ` [EXT] " Akhil Goyal
2022-05-24 11:12   ` Akhil Goyal
2022-05-24 14:47     ` Kusztal, ArkadiuszX
2022-05-25  6:06       ` Akhil Goyal
2022-05-25  6:36         ` Kusztal, ArkadiuszX
2022-05-25  7:05           ` Anoob Joseph
2022-05-27  6:30             ` Kusztal, ArkadiuszX
2022-05-27  6:40               ` Kusztal, ArkadiuszX
2022-05-27  6:55                 ` Kusztal, ArkadiuszX
2022-05-27  7:27                   ` Anoob Joseph
2022-05-27  7:47                     ` Kusztal, ArkadiuszX
2022-05-20  5:54 ` [PATCH 12/40] crypto/openssl: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 13/40] test/crypto: " Arek Kusztal
2022-05-20  7:24   ` [EXT] " Akhil Goyal
2022-05-20  7:38     ` Kusztal, ArkadiuszX
2022-05-20  5:54 ` [PATCH 14/40] app/test-crypto-perf: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 15/40] app/test-eventdev: " Arek Kusztal
2022-05-20  7:25   ` [EXT] " Akhil Goyal
2022-05-20  5:54 ` [PATCH 16/40] cryptodev: move dh type from xform to dh op Arek Kusztal
2022-05-24 11:52   ` [EXT] " Akhil Goyal
2022-05-20  5:54 ` [PATCH 17/40] crypto/openssl: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 18/40] test/crypto: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 19/40] cryptodev: changed order of dh fields Arek Kusztal
2022-05-20  5:54 ` [PATCH 20/40] cryptodev: add elliptic curve diffie hellman Arek Kusztal
2022-05-24 12:08   ` [EXT] " Akhil Goyal
2022-05-24 14:52     ` Kusztal, ArkadiuszX
2022-05-24 14:55       ` Kusztal, ArkadiuszX
2022-05-25  6:02         ` Akhil Goyal
2022-05-25  6:33           ` Kusztal, ArkadiuszX
2022-05-20  5:54 ` [PATCH 21/40] cryptodev: add public key verify option Arek Kusztal
2022-05-24 12:12   ` [EXT] " Akhil Goyal
2022-05-24 14:59     ` Kusztal, ArkadiuszX
2022-05-25  6:00       ` Akhil Goyal
2022-05-25  6:30         ` Kusztal, ArkadiuszX
2022-05-20  5:54 ` [PATCH 22/40] cryptodev: move RSA padding into separate struct Arek Kusztal
2022-05-20  5:54 ` [PATCH 23/40] crypto/qat: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 24/40] crypto/openssl: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 25/40] crypto/octeontx: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 26/40] crypto/cnxk: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 27/40] common/cpt: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 28/40] test/crypto: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 29/40] cryptodev: add salt length and optional label Arek Kusztal
2022-05-24 12:30   ` [EXT] " Akhil Goyal
2022-05-24 15:14     ` Kusztal, ArkadiuszX
2022-05-25  5:57       ` Akhil Goyal
2022-05-20  5:54 ` [PATCH 30/40] cryptodev: reduce rsa struct to only necessary fields Arek Kusztal
2022-05-24 12:52   ` [EXT] " Akhil Goyal
2022-05-24 15:33     ` Kusztal, ArkadiuszX
2022-05-25  5:48       ` Akhil Goyal
2022-05-20  5:54 ` [PATCH 31/40] crypto/qat: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 32/40] crypto/openssl: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 33/40] crypto/octeontx: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 34/40] crypto/cnxk: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 35/40] common/cpt: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 36/40] test/crypto: " Arek Kusztal
2022-05-20  5:54 ` [PATCH 37/40] cryptodev: add asym op flags Arek Kusztal
2022-05-20 12:07   ` [EXT] " Akhil Goyal
2022-05-20  5:54 ` [PATCH 38/40] cryptodev: clarify usage of private key in dh Arek Kusztal
2022-05-24 12:56   ` [EXT] " Akhil Goyal
2022-05-24 14:30     ` Kusztal, ArkadiuszX
2022-05-25  6:09       ` Akhil Goyal
2022-05-25  6:37         ` Kusztal, ArkadiuszX
2022-05-20  5:54 ` [PATCH 39/40] crypto/openssl: generate dh private key Arek Kusztal
2022-05-20  5:54 ` Arek Kusztal [this message]
2022-05-20  7:30 ` [EXT] [PATCH 00/40] cryptodev: rsa, dh, ecdh changes Akhil Goyal
2022-05-20  7:37   ` Kusztal, ArkadiuszX

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=20220520055445.40063-41-arkadiuszx.kusztal@intel.com \
    --to=arkadiuszx.kusztal@intel.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=roy.fan.zhang@intel.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).