patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, brian.dooley@intel.com,
	Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>,
	stable@dpdk.org
Subject: [PATCH v3] crypto/qat: fix ecdsa session handling
Date: Wed,  6 Nov 2024 15:14:21 +0000	[thread overview]
Message-ID: <20241106151421.2722-1-arkadiuszx.kusztal@intel.com> (raw)
In-Reply-To: <20241104093048.20351-1-arkadiuszx.kusztal@intel.com>

Fixed a problem with setting the key in the session in the ECDSA
algorithm. Since the key is being initialized in the session for EC,
it should be reflected in the PMD session initialization function.

Fixes: badc0c6f6d6a ("cryptodev: set private and public keys in EC session")
Cc: stable@dpdk.org

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
v2:
- added a generic solution
v3:
- replaced rte_memcpy with memcpy

 drivers/crypto/qat/qat_asym.c | 41 +++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 7bb2f6c1e0..f5b56b2f71 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -1348,11 +1348,48 @@ session_set_rsa(struct qat_asym_session *qat_session,
 	return ret;
 }
 
-static void
+static int
 session_set_ec(struct qat_asym_session *qat_session,
 			struct rte_crypto_asym_xform *xform)
 {
+	uint8_t *pkey = xform->ec.pkey.data;
+	uint8_t *q_x = xform->ec.q.x.data;
+	uint8_t *q_y = xform->ec.q.y.data;
+
+	qat_session->xform.ec.pkey.data =
+		rte_malloc(NULL, xform->ec.pkey.length, 0);
+	if (qat_session->xform.ec.pkey.length &&
+		qat_session->xform.ec.pkey.data == NULL)
+		return -ENOMEM;
+	qat_session->xform.ec.q.x.data = rte_malloc(NULL,
+		xform->ec.q.x.length, 0);
+	if (qat_session->xform.ec.q.x.length &&
+		qat_session->xform.ec.q.x.data == NULL) {
+		rte_free(qat_session->xform.ec.pkey.data);
+		return -ENOMEM;
+	}
+	qat_session->xform.ec.q.y.data = rte_malloc(NULL,
+		xform->ec.q.y.length, 0);
+	if (qat_session->xform.ec.q.y.length &&
+		qat_session->xform.ec.q.y.data == NULL) {
+		rte_free(qat_session->xform.ec.pkey.data);
+		rte_free(qat_session->xform.ec.q.x.data);
+		return -ENOMEM;
+	}
+
+	memcpy(qat_session->xform.ec.pkey.data, pkey,
+		xform->ec.pkey.length);
+	qat_session->xform.ec.pkey.length = xform->ec.pkey.length;
+	memcpy(qat_session->xform.ec.q.x.data, q_x,
+		xform->ec.q.x.length);
+	qat_session->xform.ec.q.x.length = xform->ec.q.x.length;
+	memcpy(qat_session->xform.ec.q.y.data, q_y,
+		xform->ec.q.y.length);
+	qat_session->xform.ec.q.y.length = xform->ec.q.y.length;
 	qat_session->xform.ec.curve_id = xform->ec.curve_id;
+
+	return 0;
+
 }
 
 int
@@ -1388,7 +1425,7 @@ qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 	case RTE_CRYPTO_ASYM_XFORM_ECPM:
 	case RTE_CRYPTO_ASYM_XFORM_ECDH:
-		session_set_ec(qat_session, xform);
+		ret = session_set_ec(qat_session, xform);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_SM2:
 		break;
-- 
2.34.1


  parent reply	other threads:[~2024-11-06 15:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31 19:19 [PATCH] " Arkadiusz Kusztal
2024-11-04  9:30 ` [PATCH v2] " Arkadiusz Kusztal
2024-11-06 11:51   ` [EXTERNAL] " Akhil Goyal
2024-11-06 14:44     ` Kusztal, ArkadiuszX
2024-11-06 15:14   ` Arkadiusz Kusztal [this message]
2024-11-06 17:44     ` [EXTERNAL] [PATCH v3] " Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241106151421.2722-1-arkadiuszx.kusztal@intel.com \
    --to=arkadiuszx.kusztal@intel.com \
    --cc=brian.dooley@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=stable@dpdk.org \
    /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).