* [PATCH] crypto/qat: fix ecdsa session handling
@ 2024-10-31 19:19 Arkadiusz Kusztal
2024-11-04 9:30 ` [PATCH v2] " Arkadiusz Kusztal
0 siblings, 1 reply; 6+ messages in thread
From: Arkadiusz Kusztal @ 2024-10-31 19:19 UTC (permalink / raw)
To: dev; +Cc: gakhil, brian.dooley, Arkadiusz Kusztal, stable
Fixed a problem with setting the key in the session
in the ECDSA alghoritm.
Fixes: badc0c6f6d6a ("cryptodev: set private and public keys in EC session")
Cc: stable@dpdk.org
Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
drivers/crypto/qat/qat_asym.c | 42 +++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 9e97582e22..d404fe48c0 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -1346,6 +1346,46 @@ session_set_rsa(struct qat_asym_session *qat_session,
return ret;
}
+static int
+session_set_ecdsa(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.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.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.data == NULL) {
+ rte_free(qat_session->xform.ec.pkey.data);
+ rte_free(qat_session->xform.ec.q.x.data);
+ return -ENOMEM;
+ }
+
+ rte_memcpy(qat_session->xform.ec.pkey.data, pkey,
+ xform->ec.pkey.length);
+ qat_session->xform.ec.pkey.length = xform->ec.pkey.length;
+ rte_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;
+ rte_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;
+}
+
static void
session_set_ec(struct qat_asym_session *qat_session,
struct rte_crypto_asym_xform *xform)
@@ -1384,6 +1424,8 @@ qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
}
break;
case RTE_CRYPTO_ASYM_XFORM_ECDSA:
+ ret = session_set_ecdsa(qat_session, xform);
+ break;
case RTE_CRYPTO_ASYM_XFORM_ECPM:
case RTE_CRYPTO_ASYM_XFORM_ECDH:
session_set_ec(qat_session, xform);
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] crypto/qat: fix ecdsa session handling
2024-10-31 19:19 [PATCH] crypto/qat: fix ecdsa session handling Arkadiusz Kusztal
@ 2024-11-04 9:30 ` Arkadiusz Kusztal
2024-11-06 11:51 ` [EXTERNAL] " Akhil Goyal
2024-11-06 15:14 ` [PATCH v3] " Arkadiusz Kusztal
0 siblings, 2 replies; 6+ messages in thread
From: Arkadiusz Kusztal @ 2024-11-04 9:30 UTC (permalink / raw)
To: dev; +Cc: gakhil, brian.dooley, Arkadiusz Kusztal, stable
Fixed a problem with setting the key in the session
in the ECDSA alghorithm.
Fixes: badc0c6f6d6a ("cryptodev: set private and public keys in EC session")
Cc: stable@dpdk.org
Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
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 9e97582e22..dfc52d1286 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -1346,11 +1346,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;
+ }
+
+ rte_memcpy(qat_session->xform.ec.pkey.data, pkey,
+ xform->ec.pkey.length);
+ qat_session->xform.ec.pkey.length = xform->ec.pkey.length;
+ rte_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;
+ rte_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
@@ -1386,7 +1423,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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [EXTERNAL] [PATCH v2] crypto/qat: fix ecdsa session handling
2024-11-04 9:30 ` [PATCH v2] " Arkadiusz Kusztal
@ 2024-11-06 11:51 ` Akhil Goyal
2024-11-06 14:44 ` Kusztal, ArkadiuszX
2024-11-06 15:14 ` [PATCH v3] " Arkadiusz Kusztal
1 sibling, 1 reply; 6+ messages in thread
From: Akhil Goyal @ 2024-11-06 11:51 UTC (permalink / raw)
To: Arkadiusz Kusztal, dev; +Cc: brian.dooley, stable
> Fixed a problem with setting the key in the session
> in the ECDSA alghorithm.
Please elaborate what is the problem and what is being done in the patch.
>
> Fixes: badc0c6f6d6a ("cryptodev: set private and public keys in EC session")
> Cc: stable@dpdk.org
>
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
> 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 9e97582e22..dfc52d1286 100644
> --- a/drivers/crypto/qat/qat_asym.c
> +++ b/drivers/crypto/qat/qat_asym.c
> @@ -1346,11 +1346,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;
> + }
> +
> + rte_memcpy(qat_session->xform.ec.pkey.data, pkey,
> + xform->ec.pkey.length);
> + qat_session->xform.ec.pkey.length = xform->ec.pkey.length;
> + rte_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;
> + rte_memcpy(qat_session->xform.ec.q.y.data, q_y,
> + xform->ec.q.y.length);
Do you really need rte_memcpy?
memcpy is not enough?
> + 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
> @@ -1386,7 +1423,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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [EXTERNAL] [PATCH v2] crypto/qat: fix ecdsa session handling
2024-11-06 11:51 ` [EXTERNAL] " Akhil Goyal
@ 2024-11-06 14:44 ` Kusztal, ArkadiuszX
0 siblings, 0 replies; 6+ messages in thread
From: Kusztal, ArkadiuszX @ 2024-11-06 14:44 UTC (permalink / raw)
To: Akhil Goyal, dev; +Cc: Dooley, Brian, stable
> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Wednesday, November 6, 2024 12:52 PM
> To: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>; dev@dpdk.org
> Cc: Dooley, Brian <brian.dooley@intel.com>; stable@dpdk.org
> Subject: RE: [EXTERNAL] [PATCH v2] crypto/qat: fix ecdsa session handling
>
> > Fixed a problem with setting the key in the session in the ECDSA
> > alghorithm.
>
> Please elaborate what is the problem and what is being done in the patch.
>
> >
> > Fixes: badc0c6f6d6a ("cryptodev: set private and public keys in EC
> > session")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> > ---
> > 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 9e97582e22..dfc52d1286 100644
> > --- a/drivers/crypto/qat/qat_asym.c
> > +++ b/drivers/crypto/qat/qat_asym.c
> > @@ -1346,11 +1346,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;
> > + }
> > +
> > + rte_memcpy(qat_session->xform.ec.pkey.data, pkey,
> > + xform->ec.pkey.length);
> > + qat_session->xform.ec.pkey.length = xform->ec.pkey.length;
> > + rte_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;
> > + rte_memcpy(qat_session->xform.ec.q.y.data, q_y,
> > + xform->ec.q.y.length);
>
> Do you really need rte_memcpy?
> memcpy is not enough?
This is a session, so yes, this can be a memcpy call.
I will change.
>
> > + 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
> > @@ -1386,7 +1423,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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] crypto/qat: fix ecdsa session handling
2024-11-04 9:30 ` [PATCH v2] " Arkadiusz Kusztal
2024-11-06 11:51 ` [EXTERNAL] " Akhil Goyal
@ 2024-11-06 15:14 ` Arkadiusz Kusztal
2024-11-06 17:44 ` [EXTERNAL] " Akhil Goyal
1 sibling, 1 reply; 6+ messages in thread
From: Arkadiusz Kusztal @ 2024-11-06 15:14 UTC (permalink / raw)
To: dev; +Cc: gakhil, brian.dooley, Arkadiusz Kusztal, stable
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [EXTERNAL] [PATCH v3] crypto/qat: fix ecdsa session handling
2024-11-06 15:14 ` [PATCH v3] " Arkadiusz Kusztal
@ 2024-11-06 17:44 ` Akhil Goyal
0 siblings, 0 replies; 6+ messages in thread
From: Akhil Goyal @ 2024-11-06 17:44 UTC (permalink / raw)
To: Arkadiusz Kusztal, dev; +Cc: brian.dooley, stable
> 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>
Applied to dpdk-next-crypto
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-06 17:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-31 19:19 [PATCH] crypto/qat: fix ecdsa session handling 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 ` [PATCH v3] " Arkadiusz Kusztal
2024-11-06 17:44 ` [EXTERNAL] " Akhil Goyal
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).