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 0393945C96; Wed, 6 Nov 2024 16:14:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 367C842E68; Wed, 6 Nov 2024 16:14:29 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id 6882E40265; Wed, 6 Nov 2024 16:14:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730906068; x=1762442068; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=9YTFf/DldBDiXkVlaChlhg3ZzWpLAaZ2VwpcO1o9iI0=; b=GQ1Ny/Q4h07wUWEbyXBy66BN1TV2Py67PvbW1lVM9XtUlQVKwRLtseoK HjqElPJZNoqQ0UPsm9YkX8drk+Qxyidsl768OTz/ETumrUNlV4iK8jZ46 rBM5aiFf0uICDLub3o/IAGEY+NEUYPeIps0u1bVQUfPJGXfNIDYzwOw0w zzb+pZgJVjucd7z+sAwcgOKMEItqoAc4KqImNGuqOH2MGucSEBZKA6sEC N79t9KtJkmXISgR7g+wwu0w867ZxMCMi4Mx8P4oKva1VGd7QTLBnHeHB+ ZJsdp8Dm6Ji1GSpGTpX83GhqcrciTHKKC5GgKWC4khAiXX/mhODWQZnwF A==; X-CSE-ConnectionGUID: hRlVhN84TmC32c1h1zRiwg== X-CSE-MsgGUID: u3BGB19zT8STpSGRs6BZEg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="48171028" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="48171028" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2024 07:14:26 -0800 X-CSE-ConnectionGUID: hrsQp1xzTXG0QArkYk8iiQ== X-CSE-MsgGUID: 7tgZ5jbGQOuCBbNRR4VTzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="89393420" Received: from silpixa00400308.ir.intel.com ([10.237.214.154]) by orviesa003.jf.intel.com with ESMTP; 06 Nov 2024 07:14:25 -0800 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, brian.dooley@intel.com, Arkadiusz Kusztal , stable@dpdk.org Subject: [PATCH v3] crypto/qat: fix ecdsa session handling Date: Wed, 6 Nov 2024 15:14:21 +0000 Message-Id: <20241106151421.2722-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241104093048.20351-1-arkadiuszx.kusztal@intel.com> References: <20241104093048.20351-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 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 --- 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