Skip to content

Commit

Permalink
crypto/qat: fix ECDSA session handling
Browse files Browse the repository at this point in the history
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: badc0c6 ("cryptodev: set private and public keys in EC session")
Cc: [email protected]

Signed-off-by: Arkadiusz Kusztal <[email protected]>
  • Loading branch information
arekk67 authored and Akhil Goyal committed Nov 6, 2024
1 parent 5b2fe7e commit 20e633b
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions drivers/crypto/qat/qat_asym.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 20e633b

Please sign in to comment.