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 46D35454B2; Fri, 21 Jun 2024 04:39:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F26C642EAA; Fri, 21 Jun 2024 04:38:57 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 4572C42EC4 for ; Fri, 21 Jun 2024 04:38:56 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45KH7sfn024779; Thu, 20 Jun 2024 19:38:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=3 4F1ukCQfXjzvoGB9TJF0dpJILaV3QEtx7p1Lr69QSs=; b=X0pkqv4+IJ5/Sp2L2 ejHJfLcRnkvh55OPz82t09C4WT9CDfaUf64+/3onIZ4q6Bxg/Eoqs/bmAfRWbtFl 5Y1bWczyRB7T7P+RuRI4kDdoCy/1aq2C0Ehlx2LFQGGp5sg1u6IHfc5RbmwARyIi kKIisLvm2ZJuEzRoxWFLdxNFQ9TA3YCpY91vnNFgGiwoH6zIo4X8BY/PaalTIRIc NIFfVOZN1mYZKkCgl1IzjzE8AvDNjcuRyUeRiWiV63k6/LrlMfpr9vsLe9SQzsGG 0f7Yz5Fq7BBIAE1JpRBAhb6YPoos6+nFIX3KykBCSVbladTSXKLpFN4omCMtHnlr C0/ew== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3yvrj7a02r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jun 2024 19:38:55 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 20 Jun 2024 19:38:54 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 20 Jun 2024 19:38:54 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 244F83F7082; Thu, 20 Jun 2024 19:38:51 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Akhil Goyal , Fan Zhang CC: Anoob Joseph , Gowrishankar Muthukrishnan Subject: [PATCH v2 3/4] test/crypto: use common test function for mod tests Date: Fri, 21 Jun 2024 08:08:28 +0530 Message-ID: <20240621023832.1707-4-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240621023832.1707-1-gmuthukrishn@marvell.com> References: <20240616044223.2841-1-gmuthukrishn@marvell.com> <20240621023832.1707-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: fLpWdugavASI2VIAaWQAQoBMid7ftMe9 X-Proofpoint-ORIG-GUID: fLpWdugavASI2VIAaWQAQoBMid7ftMe9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-20_12,2024-06-20_04,2024-05-17_01 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 Use common test function for modex and modinv tests. Signed-off-by: Gowrishankar Muthukrishnan --- v2: - Old functions not removed. --- app/test/test_cryptodev_asym.c | 21 +++- app/test/test_cryptodev_mod_test_vectors.h | 124 +++++++++++++++++++++ 2 files changed, 140 insertions(+), 5 deletions(-) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index fec53f87db..32fb198f96 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -988,7 +988,8 @@ test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm) return status; } -static int +/* Below function is in use by cryptodev doc */ +static int __rte_unused test_mod_inv(void) { struct crypto_testsuite_params_asym *ts_params = &testsuite_params; @@ -1100,7 +1101,8 @@ test_mod_inv(void) return status; } -static int +/* Below function is in use by cryptodev doc */ +static int __rte_unused test_mod_exp(void) { struct crypto_testsuite_params_asym *ts_params = &testsuite_params; @@ -3508,8 +3510,14 @@ static struct unit_test_suite cryptodev_openssl_asym_testsuite = { test_rsa_enc_dec_crt), TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_rsa_sign_verify_crt), - TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_inv), - TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_exp), + TEST_CASE_NAMED_WITH_DATA( + "Modinv test", + ut_setup_asym, ut_teardown_asym, + modular_multiplicative_inverse, &modinv_test_cases[0]), + TEST_CASE_NAMED_WITH_DATA( + "Modex test", + ut_setup_asym, ut_teardown_asym, + modular_exponentiation, &modex_test_cases[0]), TEST_CASE_NAMED_WITH_DATA( "Modex Group 5 test", ut_setup_asym, ut_teardown_asym, @@ -3584,7 +3592,10 @@ static struct unit_test_suite cryptodev_octeontx_asym_testsuite = { test_rsa_enc_dec_crt), TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_rsa_sign_verify_crt), - TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_exp), + TEST_CASE_NAMED_WITH_DATA( + "Modex test", + ut_setup_asym, ut_teardown_asym, + modular_exponentiation, &modex_test_cases[0]), TEST_CASE_NAMED_WITH_DATA( "Modex Group 5 test", ut_setup_asym, ut_teardown_asym, diff --git a/app/test/test_cryptodev_mod_test_vectors.h b/app/test/test_cryptodev_mod_test_vectors.h index a4e06c0291..e7b930b765 100644 --- a/app/test/test_cryptodev_mod_test_vectors.h +++ b/app/test/test_cryptodev_mod_test_vectors.h @@ -265,6 +265,130 @@ struct rte_crypto_asym_xform modinv_xform = { } }; +static const struct +modex_test_data modex_test_cases[] = { +{ + .description = "Modular Exponentiation (mod=129, base=20, exp=3, res=128)", + .xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX, + .base = { + .data = { + 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE, + 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB, + 0x7E, 0x78, 0xA0, 0x50 + }, + .len = 20 + }, + .exponent = { + .data = { + 0x01, 0x00, 0x01 + }, + .len = 3 + }, + .reminder = { + .data = { + 0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72, + 0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C, + 0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17, + 0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D, + 0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C, + 0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7, + 0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11, + 0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32, + 0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B, + 0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99, + 0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E, + 0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38, + 0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7, + 0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F, + 0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46, + 0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A + }, + .len = 128 + }, + .modulus = { + .data = { + 0x00, 0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, + 0x0a, 0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, + 0xce, 0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, + 0xa2, 0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, + 0x0a, 0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, + 0x3d, 0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, + 0x6a, 0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, + 0x6e, 0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, + 0x72, 0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, + 0x87, 0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, + 0x62, 0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, + 0x18, 0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, + 0x4e, 0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, + 0x03, 0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, + 0xee, 0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, + 0xa6, 0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, + 0x55 + }, + .len = 129 + } +} +}; + +static const struct +modinv_test_data modinv_test_cases[] = { +{ + .description = "Modular Inverse (mod=129, base=20, inv=128)", + .xform_type = RTE_CRYPTO_ASYM_XFORM_MODINV, + .base = { + .data = { + 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, + 0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, + 0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50 + }, + .len = 20 + }, + .inverse = { + .data = { + 0x52, 0xb1, 0xa3, 0x8c, 0xc5, 0x8a, 0xb9, 0x1f, + 0xb6, 0x82, 0xf5, 0x6a, 0x9a, 0xde, 0x8d, 0x2e, + 0x62, 0x4b, 0xac, 0x49, 0x21, 0x1d, 0x30, 0x4d, + 0x32, 0xac, 0x1f, 0x40, 0x6d, 0x52, 0xc7, 0x9b, + 0x6c, 0x0a, 0x82, 0x3a, 0x2c, 0xaf, 0x6b, 0x6d, + 0x17, 0xbe, 0x43, 0xed, 0x97, 0x78, 0xeb, 0x4c, + 0x92, 0x6f, 0xcf, 0xed, 0xb1, 0x09, 0xcb, 0x27, + 0xc2, 0xde, 0x62, 0xfd, 0x21, 0xe6, 0xbd, 0x4f, + 0xfe, 0x7a, 0x1b, 0x50, 0xfe, 0x10, 0x4a, 0xb0, + 0xb7, 0xcf, 0xdb, 0x7d, 0xca, 0xc2, 0xf0, 0x1c, + 0x39, 0x48, 0x6a, 0xb5, 0x4d, 0x8c, 0xfe, 0x63, + 0x91, 0x9c, 0x21, 0xc3, 0x0e, 0x76, 0xad, 0x44, + 0x8d, 0x54, 0x33, 0x99, 0xe1, 0x80, 0x19, 0xba, + 0xb5, 0xac, 0x7d, 0x9c, 0xce, 0x91, 0x2a, 0xd9, + 0x2c, 0xe1, 0x16, 0xd6, 0xd7, 0xcf, 0x9d, 0x05, + 0x9a, 0x66, 0x9a, 0x3a, 0xc1, 0xb8, 0x4b, 0xc3 + }, + .len = 128 + }, + .modulus = { + .data = { + 0x00, 0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, + 0x0a, 0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, + 0xce, 0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, + 0xa2, 0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, + 0x0a, 0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, + 0x3d, 0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, + 0x6a, 0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, + 0x6e, 0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, + 0x72, 0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, + 0x87, 0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, + 0x62, 0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, + 0x18, 0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, + 0x4e, 0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, + 0x03, 0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, + 0xee, 0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, + 0xa6, 0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, + 0x55 + }, + .len = 129 + } +} +}; + static const struct modex_test_data modex_group_test_cases[] = { { -- 2.25.1