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 46A2EA0547; Thu, 21 Oct 2021 12:06:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A27C411E5; Thu, 21 Oct 2021 12:06:11 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 3973F40142; Thu, 21 Oct 2021 12:06:08 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10143"; a="215914118" X-IronPort-AV: E=Sophos;i="5.87,169,1631602800"; d="scan'208";a="215914118" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2021 03:06:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,169,1631602800"; d="scan'208";a="495062486" Received: from silpixa00400308.ir.intel.com ([10.237.214.196]) by orsmga008.jf.intel.com with ESMTP; 21 Oct 2021 03:06:06 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, roy.fan.zhang@intel.com, Arek Kusztal , stable@dpdk.org Date: Thu, 21 Oct 2021 11:06:01 +0100 Message-Id: <20211021100601.16190-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] crypto/qat: fix uncleared cookies after operation 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 Sender: "dev" This commit fixes uncleared cookies issue when using RSA algorithm. Fixes: e2c5f4ea994c ("crypto/qat: support RSA in asym") Cc: stable@dpdk.org Signed-off-by: Arek Kusztal --- drivers/crypto/qat/qat_asym.c | 41 +++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 983c639d68..f893508030 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -65,27 +65,45 @@ static size_t max_of(int n, ...) } static void qat_clear_arrays(struct qat_asym_op_cookie *cookie, - int in_count, int out_count, int in_size, int out_size) + int in_count, int out_count, int alg_size) { int i; for (i = 0; i < in_count; i++) - memset(cookie->input_array[i], 0x0, in_size); + memset(cookie->input_array[i], 0x0, alg_size); for (i = 0; i < out_count; i++) - memset(cookie->output_array[i], 0x0, out_size); + memset(cookie->output_array[i], 0x0, alg_size); +} + +static void qat_clear_arrays_crt(struct qat_asym_op_cookie *cookie, + int alg_size) +{ + int i; + + memset(cookie->input_array[0], 0x0, alg_size); + for (i = 1; i < QAT_ASYM_RSA_QT_NUM_IN_PARAMS; i++) + memset(cookie->input_array[i], 0x0, alg_size / 2); + for (i = 0; i < QAT_ASYM_RSA_NUM_OUT_PARAMS; i++) + memset(cookie->output_array[i], 0x0, alg_size); } static void qat_clear_arrays_by_alg(struct qat_asym_op_cookie *cookie, - enum rte_crypto_asym_xform_type alg, int in_size, int out_size) + struct rte_crypto_asym_xform *xform, int alg_size) { - if (alg == RTE_CRYPTO_ASYM_XFORM_MODEX) + if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) qat_clear_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS, - QAT_ASYM_MODEXP_NUM_OUT_PARAMS, in_size, - out_size); - else if (alg == RTE_CRYPTO_ASYM_XFORM_MODINV) + QAT_ASYM_MODEXP_NUM_OUT_PARAMS, alg_size); + else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) qat_clear_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS, - QAT_ASYM_MODINV_NUM_OUT_PARAMS, in_size, - out_size); + QAT_ASYM_MODINV_NUM_OUT_PARAMS, alg_size); + else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) { + if (xform->rsa.key_type == RTE_RSA_KET_TYPE_QT) + qat_clear_arrays_crt(cookie, alg_size); + else { + qat_clear_arrays(cookie, QAT_ASYM_RSA_NUM_IN_PARAMS, + QAT_ASYM_RSA_NUM_OUT_PARAMS, alg_size); + } + } } static int qat_asym_check_nonzero(rte_crypto_param n) @@ -657,8 +675,7 @@ static void qat_asym_collect_response(struct rte_crypto_op *rx_op, } } } - qat_clear_arrays_by_alg(cookie, xform->xform_type, alg_size_in_bytes, - alg_size_in_bytes); + qat_clear_arrays_by_alg(cookie, xform, alg_size_in_bytes); } void -- 2.21.3