From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CAEA045C75; Mon, 4 Nov 2024 10:30:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E4E340DCD; Mon, 4 Nov 2024 10:30:56 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id BB3B64021F; Mon, 4 Nov 2024 10:30:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730712655; x=1762248655; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=qYU6NW5N4b1UlEfQf/e856hvhUVtb/zQBRP/+3GUrgU=; b=dhC9zbnp+7ablqtpRLeNepMj28+aRrM5RyZgr509B9hW3PqN+5km5awX 8iNMn3kdZ/+hOAeDAscfnUd4lddwprVyUT+n6dOm6AfWuPWVEFt20sriX DNUqqMljxq3UIOeW6rnfdQtdQ4qnd54JVCMtpoA6egPrEJK9kqGj8VAfs sKXWrSCYew3f2OlduONdBlyMLO6UtzKmrabRrrYaJY1imQ6m4HQkNRi2+ AYt0iQLMXQTMDgLD5wlUzv7EBjnHc+U/ltKWlIry+snavG9RKD4DnAGfy G/KD/d+1sO8AIeC67vrRxHAOUwiuSEnk6KmBjeSRYGhLrsVj1bIYk4yda A==; X-CSE-ConnectionGUID: Vgr5KDLATY6KzHBdxgYKJg== X-CSE-MsgGUID: c4/TNYvvTUKamF/kBxQWZQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="52961639" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="52961639" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 01:30:54 -0800 X-CSE-ConnectionGUID: VAahvkjjTM6Hkfbk4E58PA== X-CSE-MsgGUID: SX1asGIqTdGVxu81KpVNQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="88174731" Received: from silpixa00400308.ir.intel.com ([10.237.214.154]) by fmviesa004.fm.intel.com with ESMTP; 04 Nov 2024 01:30:53 -0800 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, brian.dooley@intel.com, Arkadiusz Kusztal , stable@dpdk.org Subject: [PATCH v2] crypto/qat: fix ecdsa session handling Date: Mon, 4 Nov 2024 09:30:48 +0000 Message-Id: <20241104093048.20351-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241031191952.20863-1-arkadiuszx.kusztal@intel.com> References: <20241031191952.20863-1-arkadiuszx.kusztal@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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