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 3D0BF43BDF; Fri, 8 Mar 2024 09:18:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF22140298; Fri, 8 Mar 2024 09:18:01 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by mails.dpdk.org (Postfix) with ESMTP id 45FDA40274; Fri, 8 Mar 2024 09:17:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709885880; x=1741421880; h=from:to:cc:subject:date:message-id; bh=r8oOlcqu0cwmL445NFwE4vut8eOSmkjZ22Sdnp2o05Y=; b=eqnNPyg4Yn+OlyGd+4JcUztUpJ56rq2NHLRNSG1A5ku6gcqcPHVLk6D/ jhaLuYPag1Z5BhEVqBzbjeQ3F16DiQrJG14dWcMBBcfGPs8iAlkLgX+LQ 1foff2ghYMIMcfw98V/6UsPYGLjTM/WuIesgFee0FBJjJ/3PlkjJpQB4l oJc9eMIUMEJXv3KYVCmj/r080zvxozFRgvfJ0P5iO3UlarupoYzf5mPmk lz7mdkP7f5Adtvj/sd+FZErSSgr8Ssw7tZZtrL33S3GNes2w/hzSg8TAM 1GUxs8pVmTl9hZA7I8196xhSMEi98KUOnDenLq2dUuTOrX82dOfJkloXx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="5192592" X-IronPort-AV: E=Sophos;i="6.07,108,1708416000"; d="scan'208";a="5192592" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 00:17:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,108,1708416000"; d="scan'208";a="10944085" Received: from silpixa00400308.ir.intel.com ([10.237.214.154]) by orviesa008.jf.intel.com with ESMTP; 08 Mar 2024 00:17:57 -0800 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, ciara.power@intel.com, Arkadiusz Kusztal , stable@dpdk.org Subject: [PATCH] app/test: fix rsa tests in qat suite Date: Fri, 8 Mar 2024 08:17:50 +0000 Message-Id: <20240308081750.5157-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 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 This commit fixes incorrectly set keys in the QAT testsuite for the RSA algorithm. Fixes: 9b5465867fb8 ("test/crypto: add RSA none padding cases") Cc: stable@dpdk.org Signed-off-by: Arkadiusz Kusztal --- app/test/test_cryptodev_asym.c | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 17daf734e8..241f9c30a0 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -3292,9 +3292,6 @@ modular_multiplicative_inverse(const void *test_data) arg.qt.coef.data = coef; \ arg.qt.coef.length = vector->coef.len -typedef void (*rsa_key_init_t)(struct rte_crypto_asym_xform *, - const struct rsa_test_data_2 *); - static int RSA_Encrypt(const struct rsa_test_data_2 *vector, uint8_t *cipher_buf) { @@ -3335,41 +3332,14 @@ RSA_Decrypt(const struct rsa_test_data_2 *vector, uint8_t *plaintext, return 0; } -static void -RSA_key_init_Exp(struct rte_crypto_asym_xform *xform, - const struct rsa_test_data_2 *vector) -{ - SET_RSA_PARAM(xform->rsa, vector, n); - SET_RSA_PARAM(xform->rsa, vector, e); - SET_RSA_PARAM(xform->rsa, vector, d); - xform->rsa.key_type = RTE_RSA_KEY_TYPE_EXP; -} - -static void -RSA_key_init_CRT(struct rte_crypto_asym_xform *xform, - const struct rsa_test_data_2 *vector) -{ - SET_RSA_PARAM(xform->rsa, vector, n); - SET_RSA_PARAM(xform->rsa, vector, e); - SET_RSA_PARAM_QT(xform->rsa, vector, p); - SET_RSA_PARAM_QT(xform->rsa, vector, q); - SET_RSA_PARAM_QT(xform->rsa, vector, dP); - SET_RSA_PARAM_QT(xform->rsa, vector, dQ); - SET_RSA_PARAM_QT(xform->rsa, vector, qInv); - xform->rsa.key_type = RTE_RSA_KEY_TYPE_QT; -} - static int -RSA_Init_Session(const struct rsa_test_data_2 *vector, - rsa_key_init_t key_init) +RSA_Init_Session(struct rte_crypto_asym_xform *xform) { const uint8_t dev_id = params->valid_devs[0]; struct rte_cryptodev_info dev_info; - struct rte_crypto_asym_xform xform = { }; int ret = 0; - key_init(&xform, vector); - xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA; + xform->xform_type = RTE_CRYPTO_ASYM_XFORM_RSA; rte_cryptodev_info_get(dev_id, &dev_info); if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) { @@ -3377,7 +3347,7 @@ RSA_Init_Session(const struct rsa_test_data_2 *vector, "Device doesn't support decrypt op with quintuple key type. Test skipped\n"); return TEST_SKIPPED; } - ret = rte_cryptodev_asym_session_create(dev_id, &xform, + ret = rte_cryptodev_asym_session_create(dev_id, xform, params->session_mpool, &self->sess); if (ret < 0) { RTE_LOG(ERR, USER1, @@ -3392,7 +3362,13 @@ KAT_RSA_Encrypt(const void *data) { uint8_t cipher_buf[TEST_DATA_SIZE] = {0}; const struct rsa_test_data_2 *vector = data; - int ret = RSA_Init_Session(vector, RSA_key_init_Exp); + struct rte_crypto_asym_xform xform = { }; + + SET_RSA_PARAM(xform.rsa, vector, n); + SET_RSA_PARAM(xform.rsa, vector, e); + SET_RSA_PARAM(xform.rsa, vector, d); + xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP; + int ret = RSA_Init_Session(&xform); if (ret) { RTE_LOG(ERR, USER1, "Failed to init session for RSA\n"); @@ -3412,8 +3388,17 @@ KAT_RSA_Encrypt_CRT(const void *data) { uint8_t cipher_buf[TEST_DATA_SIZE] = {0}; const struct rsa_test_data_2 *vector = data; - int ret = RSA_Init_Session(vector, RSA_key_init_CRT); + struct rte_crypto_asym_xform xform = { }; + SET_RSA_PARAM(xform.rsa, vector, n); + SET_RSA_PARAM(xform.rsa, vector, e); + SET_RSA_PARAM_QT(xform.rsa, vector, p); + SET_RSA_PARAM_QT(xform.rsa, vector, q); + SET_RSA_PARAM_QT(xform.rsa, vector, dP); + SET_RSA_PARAM_QT(xform.rsa, vector, dQ); + SET_RSA_PARAM_QT(xform.rsa, vector, qInv); + xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT; + int ret = RSA_Init_Session(&xform); if (ret) { RTE_LOG(ERR, USER1, "Failed to init session for RSA\n"); return ret; @@ -3432,7 +3417,13 @@ KAT_RSA_Decrypt(const void *data) { uint8_t message[TEST_DATA_SIZE] = {0}; const struct rsa_test_data_2 *vector = data; - int ret = RSA_Init_Session(vector, RSA_key_init_Exp); + struct rte_crypto_asym_xform xform = { }; + + SET_RSA_PARAM(xform.rsa, vector, n); + SET_RSA_PARAM(xform.rsa, vector, e); + SET_RSA_PARAM(xform.rsa, vector, d); + xform.rsa.key_type = RTE_RSA_KEY_TYPE_EXP; + int ret = RSA_Init_Session(&xform); if (ret) { RTE_LOG(ERR, USER1, "Failed to init session for RSA\n"); @@ -3452,8 +3443,17 @@ KAT_RSA_Decrypt_CRT(const void *data) { uint8_t message[TEST_DATA_SIZE] = {0}; const struct rsa_test_data_2 *vector = data; - int ret = RSA_Init_Session(vector, RSA_key_init_CRT); + struct rte_crypto_asym_xform xform = { }; + SET_RSA_PARAM(xform.rsa, vector, n); + SET_RSA_PARAM(xform.rsa, vector, e); + SET_RSA_PARAM_QT(xform.rsa, vector, p); + SET_RSA_PARAM_QT(xform.rsa, vector, q); + SET_RSA_PARAM_QT(xform.rsa, vector, dP); + SET_RSA_PARAM_QT(xform.rsa, vector, dQ); + SET_RSA_PARAM_QT(xform.rsa, vector, qInv); + xform.rsa.key_type = RTE_RSA_KEY_TYPE_QT; + int ret = RSA_Init_Session(&xform); if (ret) { RTE_LOG(ERR, USER1, "Failed to init session for RSA\n"); return ret; -- 2.13.6