From patchwork Tue Oct 18 13:53:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 118427 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9B290A0560; Tue, 18 Oct 2022 17:07:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D93840395; Tue, 18 Oct 2022 17:07:12 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 956874021D for ; Tue, 18 Oct 2022 17:07:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666105629; x=1697641629; h=from:to:cc:subject:date:message-id; bh=wim32ID8QE2PkBWjr8KbkbCPSRSuFtD4DCR3uG1I0F4=; b=ixptJ6fQeFS27X2nt04s56gT7PIVwyd0GuVl9alQTC7+eJMvEa9KSqRH E85UFAfqTfu1ZwjfCSF5CQEDGNaOfTzdQo2UvE/ltJyHIA57yk7Y81C+9 wym9c7uYq8exmYBq9BxF/fJFGiYEZyyOWRF3gmuAfXaSyweZQwAKIkipK Yl06kLfROt9UWoMK5LIBLNlIHt7q76ASQmv4CUVLTm0IMOptDXhg9FxTe Q35OczwyYSfxZoxSwMAO5BmNgZxuibUkGJbmO1XfhXjoXghqN/9tQ4FoB NbPcVwbmKWDSEWeQBu45Zq3OdqQV0QLWfjV9UIi6P2H21ZF9yKVe+jNKQ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="307792737" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="307792737" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 08:02:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="579825381" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="579825381" Received: from silpixa00399302.ir.intel.com ([10.237.214.136]) by orsmga003.jf.intel.com with ESMTP; 18 Oct 2022 08:02:27 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, kai.ji@intel.com, Arek Kusztal Subject: [PATCH v2 1/3] crypto/qat: fix uncleared cookies in asym Date: Tue, 18 Oct 2022 14:53:32 +0100 Message-Id: <20221018135334.34873-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 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 incorrectly placed clean function in asym response. Fixes: 002486db239e ("crypto/qat: refactor asymmetric session") Signed-off-by: Arek Kusztal Acked-by: Ciara Power --- v2: - fixed compilation issues - split into 3 patches drivers/crypto/qat/qat_asym.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 19931791c4..3d7a800392 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -129,20 +129,23 @@ cleanup_crt(struct qat_asym_op_cookie *cookie, static void cleanup(struct qat_asym_op_cookie *cookie, - struct rte_crypto_asym_xform *xform, int alg_size) + struct rte_crypto_asym_xform *xform) { if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) cleanup_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS, - QAT_ASYM_MODEXP_NUM_OUT_PARAMS, alg_size); + QAT_ASYM_MODEXP_NUM_OUT_PARAMS, + cookie->alg_bytesize); else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) cleanup_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS, - QAT_ASYM_MODINV_NUM_OUT_PARAMS, alg_size); + QAT_ASYM_MODINV_NUM_OUT_PARAMS, + cookie->alg_bytesize); else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) { if (xform->rsa.key_type == RTE_RSA_KEY_TYPE_QT) - cleanup_crt(cookie, alg_size); + cleanup_crt(cookie, cookie->alg_bytesize); else { cleanup_arrays(cookie, QAT_ASYM_RSA_NUM_IN_PARAMS, - QAT_ASYM_RSA_NUM_OUT_PARAMS, alg_size); + QAT_ASYM_RSA_NUM_OUT_PARAMS, + cookie->alg_bytesize); } } else { cleanup_arrays(cookie, QAT_ASYM_MAX_PARAMS, @@ -804,12 +807,13 @@ qat_asym_build_request(void *in_op, uint8_t *out_msg, void *op_cookie, op->asym->session->sess_private_data; int err = 0; + op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; if (unlikely(qat_session == NULL)) { QAT_DP_LOG(ERR, "Session was not created for this device"); + op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; goto error; } - op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; switch (op->sess_type) { case RTE_CRYPTO_OP_WITH_SESSION: request_init(qat_req); @@ -882,10 +886,11 @@ qat_asym_process_response(void **out_op, uint8_t *resp, struct rte_crypto_op *op = (struct rte_crypto_op *)(uintptr_t) (resp_msg->opaque); struct qat_asym_op_cookie *cookie = op_cookie; - struct rte_crypto_asym_xform *xform; + struct rte_crypto_asym_xform *xform = NULL; struct qat_asym_session *qat_session = (struct qat_asym_session *) op->asym->session->sess_private_data; + *out_op = op; if (cookie->error) { cookie->error = 0; if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) @@ -917,17 +922,13 @@ qat_asym_process_response(void **out_op, uint8_t *resp, default: QAT_DP_LOG(ERR, "Invalid session/xform settings in response ring!"); - op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; - } - - if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) { - op->status = qat_asym_collect_response(op, - cookie, xform); - cleanup(cookie, xform, cookie->alg_bytesize); + op->status = RTE_CRYPTO_OP_STATUS_ERROR; } - - *out_op = op; + if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) + op->status = qat_asym_collect_response(op, cookie, xform); HEXDUMP("resp_msg:", resp_msg, sizeof(struct icp_qat_fw_pke_resp)); + if (likely(xform != NULL)) + cleanup(cookie, xform); return 1; } From patchwork Tue Oct 18 13:53:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 118428 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF402A0560; Tue, 18 Oct 2022 17:07:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15858410EE; Tue, 18 Oct 2022 17:07:13 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 9AB3F4021D for ; Tue, 18 Oct 2022 17:07:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666105630; x=1697641630; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=6TOvieTjonAMXREOenQP6PmacZKL3XhhguBbeMPiH1o=; b=S8KCC30y4dgf2H5D1VcEpVB1pbnVtXxNlbAziGkjb+gChlWS/RK604N6 sUDMXXZ48Fye1EGblVJgfhppTbdeehloyzP0hEcAB5vJqJ1Jx2mlFtN4a bKADUfUh6orcsLONOKVE0O7GTgToBnYoYtb1MFAMVpiEIZ6Kc0G1wmKCx IpmwhpQY357JHqxwOs7qfYEMNsMKmxQmYjBC2XYdN1iYCDymFaY79oMdk yrEQ2qkBOD0PN2GYhfzYcVaU58BfDp+w1mSJJz4f84howX4F0DD4BMmVA xtVYbpxK52AOAwnxGwiAwN4bXoRBSJ6s6d2mtrUWwP7P2Peo34lAM8XJS w==; X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="307792752" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="307792752" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 08:02:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="579825410" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="579825410" Received: from silpixa00399302.ir.intel.com ([10.237.214.136]) by orsmga003.jf.intel.com with ESMTP; 18 Oct 2022 08:02:30 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, kai.ji@intel.com, Arek Kusztal Subject: [PATCH v2 2/3] crypto/qat: fix unnecessary session check Date: Tue, 18 Oct 2022 14:53:33 +0100 Message-Id: <20221018135334.34873-2-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20221018135334.34873-1-arkadiuszx.kusztal@intel.com> References: <20221018135334.34873-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 Removed unncessary session check which could lead to segfault, in case api was changed. Fixes: 002486db239e ("crypto/qat: refactor asymmetric session") Signed-off-by: Arek Kusztal Acked-by: Ciara Power --- v2: - fixed compilation issues - split into 3 patches drivers/crypto/qat/qat_asym.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 3d7a800392..0eb5ba79bc 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -808,15 +808,15 @@ qat_asym_build_request(void *in_op, uint8_t *out_msg, void *op_cookie, int err = 0; op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; - if (unlikely(qat_session == NULL)) { - QAT_DP_LOG(ERR, "Session was not created for this device"); - op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; - goto error; - } - switch (op->sess_type) { case RTE_CRYPTO_OP_WITH_SESSION: request_init(qat_req); + if (unlikely(qat_session == NULL)) { + QAT_DP_LOG(ERR, + "Session was not created for this device"); + op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; + goto error; + } xform = &qat_session->xform; break; case RTE_CRYPTO_OP_SESSIONLESS: From patchwork Tue Oct 18 13:53:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 118429 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1CA75A0560; Tue, 18 Oct 2022 17:07:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05C4A41148; Tue, 18 Oct 2022 17:07:14 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id C84CF40395 for ; Tue, 18 Oct 2022 17:07:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666105631; x=1697641631; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=WVNcUPYcxA8xorxD7xVEfI5zoxukFLO/FEVf+wz2QLs=; b=WtcamxXg0LprLDdW/ATL7F+6/vtOiYB5IbNnYHbFN40SVCzt65bMXl38 dM85hX66XOzCrf/7b+wyG+030DFzbXBdb/bUgHGecwEIFgiqEJNAw77Ai AqhQuoz66jdXTyx8iJfs5z9q3zU4nisAZLya4KjZiqT2VQNv24Ur6BFps a7gb+raYQZa1tHn9mUxKAJasGLy+6PcS3A0r3P/ZufmSy+Ceg0xT40tp4 3/W4heHrqHQT3XqC7/OEeOrOaO9mtHLEMuFDohZaASwVeqYDS/s2RkvnV wC1re0ogrfKWNlsg/v/WROFIUrzZoY/5oGesAe2wKdDtxQ0lwqq+kqdFM Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="307792768" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="307792768" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 08:02:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="579825441" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="579825441" Received: from silpixa00399302.ir.intel.com ([10.237.214.136]) by orsmga003.jf.intel.com with ESMTP; 18 Oct 2022 08:02:32 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, kai.ji@intel.com, Arek Kusztal Subject: [PATCH v2 3/3] crypto/qat: fix not set rsa lengths Date: Tue, 18 Oct 2022 14:53:34 +0100 Message-Id: <20221018135334.34873-3-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20221018135334.34873-1-arkadiuszx.kusztal@intel.com> References: <20221018135334.34873-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 not set output length in asym pmd when doing RSA. Fixes: 002486db239e ("crypto/qat: refactor asymmetric session") Signed-off-by: Arek Kusztal Acked-by: Ciara Power --- v2: - fixed compilation issues - split into 3 patches drivers/crypto/qat/qat_asym.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 0eb5ba79bc..05ca95319b 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -508,21 +508,19 @@ rsa_collect(struct rte_crypto_asym_op *asym_op, if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) { - uint8_t *rsa_result = asym_op->rsa.cipher.data; - - rte_memcpy(rsa_result, + rte_memcpy(asym_op->rsa.cipher.data, cookie->output_array[0], alg_bytesize); + asym_op->rsa.cipher.length = alg_bytesize; HEXDUMP("RSA Encrypted data", cookie->output_array[0], alg_bytesize); } else { - uint8_t *rsa_result = asym_op->rsa.cipher.data; - switch (asym_op->rsa.padding.type) { case RTE_CRYPTO_RSA_PADDING_NONE: - rte_memcpy(rsa_result, + rte_memcpy(asym_op->rsa.cipher.data, cookie->output_array[0], alg_bytesize); + asym_op->rsa.cipher.length = alg_bytesize; HEXDUMP("RSA signature", cookie->output_array[0], alg_bytesize); @@ -534,13 +532,12 @@ rsa_collect(struct rte_crypto_asym_op *asym_op, } } else { if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) { - uint8_t *rsa_result = asym_op->rsa.message.data; - switch (asym_op->rsa.padding.type) { case RTE_CRYPTO_RSA_PADDING_NONE: - rte_memcpy(rsa_result, + rte_memcpy(asym_op->rsa.message.data, cookie->output_array[0], alg_bytesize); + asym_op->rsa.message.length = alg_bytesize; HEXDUMP("RSA Decrypted Message", cookie->output_array[0], alg_bytesize); @@ -550,11 +547,10 @@ rsa_collect(struct rte_crypto_asym_op *asym_op, return RTE_CRYPTO_OP_STATUS_ERROR; } } else { - uint8_t *rsa_result = asym_op->rsa.sign.data; - - rte_memcpy(rsa_result, - cookie->output_array[0], - alg_bytesize); + rte_memcpy(asym_op->rsa.sign.data, + cookie->output_array[0], + alg_bytesize); + asym_op->rsa.sign.length = alg_bytesize; HEXDUMP("RSA Signature", cookie->output_array[0], alg_bytesize); }