From patchwork Fri Jun 21 02:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 141473 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 D630A454B2; Fri, 21 Jun 2024 04:38:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C90A342E87; Fri, 21 Jun 2024 04:38:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 6D85A42E7D; Fri, 21 Jun 2024 04:38:46 +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 45KH7hxG024685; Thu, 20 Jun 2024 19:38:45 -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=4 1hayc/HLWHxskc11ottxx5V2tVGnPpVngoD5goAt7s=; b=dyyAzG6X7EMIDM4yI 1nxJfCDBVeui9ZitQd2QCYS7MPY5THIOLbkqgEJJkDcf5KU3YLVaVTmg3swX80vX 2kd5hN3M99LZuq7YLBbXimBp8oiMuirnirW+VOKLO/1zAoP/TRxKWsPf2GQHmj6H N42hHhQf17Dd9QWNIUPObaV63Cm8OZdi7YSe0xJsWndmt2JEJMZxZkJQG5E4NRoS 1qGUWVVxbpp27ntrdZ6FbD5TvXt/MjpR9R8bf9dK/P5L3LE40M3kNE1DRiucCfEh lPCU4jAMnlMWWTnxSQy5EH0I7wzXj/Ol7+wt5+ojYt/5mjkeXbPs1bcudDqpqTCF SDycA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3yvrj7a011-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jun 2024 19:38:45 -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:44 -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:44 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 3F3773F708E; Thu, 20 Jun 2024 19:38:41 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Akhil Goyal , Fan Zhang , Ciara Power , "Gowrishankar Muthukrishnan" , Arkadiusz Kusztal CC: Anoob Joseph , Subject: [PATCH v2 1/4] test/crypto: validate modex result from first nonzero value Date: Fri, 21 Jun 2024 08:08:26 +0530 Message-ID: <20240621023832.1707-2-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 X-Proofpoint-GUID: Keq8cgtMFl5tD5v7a7ICpcUu6AEQqyka X-Proofpoint-ORIG-GUID: Keq8cgtMFl5tD5v7a7ICpcUu6AEQqyka 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 At present, there is no specification of whether modex op output can carry leading zeroes without changing the value. OpenSSL strips leading zeroes, but other hardware need not be. Hence, when output is compared against expected result, validation could start from first non-zero. Fixes: 1ffefe00f1 ("test/crypto: add modexp and modinv functions") Cc: stable@dpdk.org Signed-off-by: Gowrishankar Muthukrishnan --- app/test/test_cryptodev_asym.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 2c745a7f7c..fec53f87db 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -3200,6 +3200,27 @@ static int send_one(void) return TEST_SUCCESS; } +static int +modular_cmpeq(const uint8_t *a, const uint8_t *b, size_t len) +{ + const uint8_t *new_a = a, *new_b = b; + size_t i, j; + + /* Strip leading NUL bytes */ + for (i = 0; i < len; i++) + if (a[i] != 0) + new_a = &a[i]; + + for (j = 0; j < len; j++) + if (b[j] != 0) + new_b = &b[i]; + + if (i != j || memcmp(new_a, new_b, len - i)) + return 1; + + return 0; +} + static int modular_exponentiation(const void *test_data) { @@ -3234,9 +3255,9 @@ modular_exponentiation(const void *test_data) TEST_ASSERT_SUCCESS(send_one(), "Failed to process crypto op"); - TEST_ASSERT_BUFFERS_ARE_EQUAL(vector->reminder.data, + TEST_ASSERT_SUCCESS(modular_cmpeq(vector->reminder.data, self->result_op->asym->modex.result.data, - self->result_op->asym->modex.result.length, + self->result_op->asym->modex.result.length), "operation verification failed\n"); return TEST_SUCCESS; From patchwork Fri Jun 21 02:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 141474 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 57168454B2; Fri, 21 Jun 2024 04:38:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4600242EAB; Fri, 21 Jun 2024 04:38:53 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id D8C0742E7D for ; Fri, 21 Jun 2024 04:38:50 +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 45KH7sfh024779; Thu, 20 Jun 2024 19:38:50 -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=m 4FnF0UHLErh79EaB+Q0FV9s2pu7ZT9WyH8ZFQCoqx0=; b=LkmEsDyJkN4BTzROQ uCqlp7ITPWYYFHdOmo6gTatBORucyCydA9wNkOXiKVWNicK6mq8Umy3fBe3Whq5l 4erS7MFzadBFAMCmcvSUjJgqph0/l8tZ3ANkPmapSqliVCTG+5ZCcrIO0tMk+V4y 4NKYnLzL92bswgSzrvaZGFzeKFNUNmV9rF7fAdYWYj21ov7aVy/AysgWxC/rEwrH n3QVVW45Nf561a46GlsmelOySwRxEWgFG5qPQiECjZ0z2iyrtCuzDf6hTcw7RgrR SGGWyy8H4PffKwjHbiEHIC+QF4CUGVXfwV9OtvWd4/Bg7ArheRRzp2YwTRYnn6Db KA4DA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3yvrj7a01w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jun 2024 19:38:49 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.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:49 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 20 Jun 2024 19:38:49 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 0EF293F7082; Thu, 20 Jun 2024 19:38:46 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Akhil Goyal , Fan Zhang CC: Anoob Joseph , Gowrishankar Muthukrishnan Subject: [PATCH v2 2/4] test/crypto: remove unused variable in modex test data Date: Fri, 21 Jun 2024 08:08:27 +0530 Message-ID: <20240621023832.1707-3-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 X-Proofpoint-GUID: aQevTdBTXFALhYFl8L-mEUoUd0ApfqPa X-Proofpoint-ORIG-GUID: aQevTdBTXFALhYFl8L-mEUoUd0ApfqPa 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 Remove unused result_len from modex test data. Signed-off-by: Gowrishankar Muthukrishnan --- app/test/test_cryptodev_mod_test_vectors.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/test/test_cryptodev_mod_test_vectors.h b/app/test/test_cryptodev_mod_test_vectors.h index c773c37018..a4e06c0291 100644 --- a/app/test/test_cryptodev_mod_test_vectors.h +++ b/app/test/test_cryptodev_mod_test_vectors.h @@ -27,7 +27,6 @@ struct modex_test_data { uint8_t data[DATA_SIZE]; uint16_t len; } reminder; - uint16_t result_len; }; struct modinv_test_data { enum rte_crypto_asym_xform_type xform_type; @@ -44,7 +43,6 @@ struct modinv_test_data { uint8_t data[DATA_SIZE]; uint16_t len; } inverse; - uint16_t result_len; }; /* ModExp #1 */ @@ -109,7 +107,6 @@ modex_test_data modex_test_case_m128_b20_e3 = { }, .len = 128 }, - .result_len = 128 }; /* ModInv #1 */ @@ -167,7 +164,6 @@ modinv_test_data modinv_test_case = { }, .len = 128 }, - .result_len = 128 }; /* modular operation test data */ @@ -347,7 +343,6 @@ modex_test_data modex_group_test_cases[] = { }, .len = 192 }, - .result_len = 192 }, { .description = "Modular Exponentiation tests for Group 14", @@ -442,7 +437,6 @@ modex_test_data modex_group_test_cases[] = { }, .len = 256 }, - .result_len = 256 }, { .description = "Modular Exponentiation tests for Group 15", @@ -571,7 +565,6 @@ modex_test_data modex_group_test_cases[] = { }, .len = 384 }, - .result_len = 384 }, { .description = "Modular Exponentiation tests for Group 16", @@ -733,7 +726,6 @@ modex_test_data modex_group_test_cases[] = { }, .len = 512 }, - .result_len = 512 }, { .description = "Modular Exponentiation tests for Group 17", @@ -960,7 +952,6 @@ modex_test_data modex_group_test_cases[] = { }, .len = 768 }, - .result_len = 768 }, { .description = "Modular Exponentiation tests for Group 18", @@ -1252,7 +1243,6 @@ modex_test_data modex_group_test_cases[] = { }, .len = 1024 }, - .result_len = 1024 }, }; From patchwork Fri Jun 21 02:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 141475 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 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 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[] = { { From patchwork Fri Jun 21 02:38:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 141476 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 692D0454B2; Fri, 21 Jun 2024 04:39:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43E1D42ECC; Fri, 21 Jun 2024 04:39:03 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 61ADD42EC8 for ; Fri, 21 Jun 2024 04:39:01 +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 45KH7kkS024744; Thu, 20 Jun 2024 19:39:00 -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=A kC2aRnbZOuZm4JAontR7iyQXICb7Oxt8VlRyRGqdJo=; b=Ta4cAI6+lSLiz/7gY NlqCg14HtqN8mMdsMxKAoH6q7R8qNJEERFK+xU9GjyMZb1LbW4eWNTit8brJqhTa MGpRI0S/+ALCb6xKt7AtWRTzQWH4BXImoi7zTGVXkWqtEUpmkU3OUXNtvMIA7Qwi 84E4zQWHHosovVnVknlIlLmGbKj6dio2W8P7ox0kV68YcLZhGSvQq4lUVoje4UcF Yw5JJY6u9R1xoil/kasDhQ/iDcBPIccqfl15lobaEihnvvKaDpEOvkY9hakNaqLv 6F6tBVno2i5j+Crjfwfwb+3pE7fakZ5Rwo1+MWCyvXsuUtj0NjATGs8mW++9hbCn ZIorg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3yvrj7a04h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jun 2024 19:39:00 -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:59 -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:59 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 1FA2C3F7082; Thu, 20 Jun 2024 19:38:56 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Akhil Goyal , Fan Zhang CC: Anoob Joseph , Gowrishankar Muthukrishnan Subject: [PATCH v2 4/4] test/crypto: add modex tests for zero padded operands Date: Fri, 21 Jun 2024 08:08:29 +0530 Message-ID: <20240621023832.1707-5-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 X-Proofpoint-GUID: DLbR8x9lSHNs16Bnnorj296aUaQZ9Lu_ X-Proofpoint-ORIG-GUID: DLbR8x9lSHNs16Bnnorj296aUaQZ9Lu_ 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 Add modex tests for zero padded operands, as in ASN encoding. Signed-off-by: Gowrishankar Muthukrishnan --- app/test/test_cryptodev_asym.c | 16 +++++ app/test/test_cryptodev_mod_test_vectors.h | 71 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 32fb198f96..26afa082af 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -3518,6 +3518,14 @@ static struct unit_test_suite cryptodev_openssl_asym_testsuite = { "Modex test", ut_setup_asym, ut_teardown_asym, modular_exponentiation, &modex_test_cases[0]), + TEST_CASE_NAMED_WITH_DATA( + "Modex test for zero padding", + ut_setup_asym, ut_teardown_asym, + modular_exponentiation, &modex_test_cases[1]), + TEST_CASE_NAMED_WITH_DATA( + "Modex test for zero padding (2)", + ut_setup_asym, ut_teardown_asym, + modular_exponentiation, &modex_test_cases[2]), TEST_CASE_NAMED_WITH_DATA( "Modex Group 5 test", ut_setup_asym, ut_teardown_asym, @@ -3596,6 +3604,14 @@ static struct unit_test_suite cryptodev_octeontx_asym_testsuite = { "Modex test", ut_setup_asym, ut_teardown_asym, modular_exponentiation, &modex_test_cases[0]), + TEST_CASE_NAMED_WITH_DATA( + "Modex test for zero padding", + ut_setup_asym, ut_teardown_asym, + modular_exponentiation, &modex_test_cases[1]), + TEST_CASE_NAMED_WITH_DATA( + "Modex test for zero padding (2)", + ut_setup_asym, ut_teardown_asym, + modular_exponentiation, &modex_test_cases[2]), 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 e7b930b765..9a7f3e710b 100644 --- a/app/test/test_cryptodev_mod_test_vectors.h +++ b/app/test/test_cryptodev_mod_test_vectors.h @@ -327,6 +327,77 @@ modex_test_data modex_test_cases[] = { }, .len = 129 } +}, +{ + .description = "Modular Exponentiation (mod=20, base=20, exp=12, res=18)", + .xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX, + .base = { + .data = { + 0x00, 0x00, 0x45, 0xCA, 0x2C, 0x5C, 0x3A, 0x90, + 0x00, 0xC4, 0xD7, 0x47, 0xA8, 0x2B, 0x12, 0x07, + 0xBD, 0x1F, 0xD7, 0x81 + }, + .len = 20 + }, + .exponent = { + .data = { + 0x00, 0x00, 0x00, 0x75, 0x74, 0x19, 0x19, 0x69, + 0xBF, 0x15, 0x2A, 0xAC + }, + .len = 12 + }, + .reminder = { + .data = { + 0x5c, 0x94, 0x8f, 0x00, 0x79, 0xe3, 0xe1, 0x0b, + 0x3f, 0x3e, 0x36, 0x75, 0xed, 0x1d, 0x84, 0xc6, + 0x36, 0x9e + }, + .len = 18 + }, + .modulus = { + .data = { + 0x00, 0x00, 0x99, 0x28, 0x09, 0x8A, 0xE9, 0x89, + 0xBB, 0x81, 0x3B, 0x07, 0x0E, 0x31, 0x00, 0x7F, + 0x79, 0x97, 0xED, 0x35 + }, + .len = 20 + } +}, +{ + .description = "Modular Exponentiation (mod=32, base=20, exp=12, res=17)", + .xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX, + .base = { + .data = { + 0x01, 0x31, 0x72, 0xFB, 0x81, 0x9D, 0x81, 0x7A, + 0x91, 0xDC, 0xE6, 0x6C, 0x2D, 0x55, 0xD9, 0x25, + 0x7A, 0xB2, 0xFF, 0xFF + }, + .len = 20 + }, + .exponent = { + .data = { + 0x00, 0x00, 0x00, 0x02, 0x36, 0x38, 0x31, 0x47, + 0x3C, 0x07, 0x36, 0x21 + }, + .len = 12 + }, + .reminder = { + .data = { + 0x02, 0x99, 0x2F, 0xE3, 0x00, 0x9F, 0xF0, 0x9E, + 0x65, 0x3C, 0x0B, 0x4A, 0xD3, 0x1B, 0x7C, 0x7F, + 0x1C + }, + .len = 17 + }, + .modulus = { + .data = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0xCE, 0xF0, 0x7C, 0x13, 0x26, 0x90, 0xAF, 0x49, + 0x06, 0x4D, 0xA4, 0x5C, 0xB2, 0x43, 0x13, 0x25, + }, + .len = 32 + } } };