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 938E045475; Sun, 16 Jun 2024 06:42:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93DAB40608; Sun, 16 Jun 2024 06:42:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 094E240430; Sun, 16 Jun 2024 06:42:37 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45G40L8K015184; Sat, 15 Jun 2024 21:42:36 -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=N qMG/aeS7ClOJkUjq2ojQWEKKGgF083xKcV/3eqbdqE=; b=Zjj8cPZJ8ul8O+UJ+ jiBpaGS23CMzBsnz3zVBuDLH0q8PsL3Dh44wthY7t90sFEB+3vH5gogI+nfI4Vq2 c9JCOCauhO7xGCp0gd5EkMgglO+W5iH1iK1+PBf/SghmDRM2P0FGtGW/aivFXiZl SZnNIPu97fykY97EtVaPuDFMHIQb3qy3pwiFtdnMpGOyzf0oyh8mvGgPeVf4GZjY GPGfPX4I2rVKPmBP+RX0nhWHN4kn6YO4zogZTDFkx2frHnCMl/DEPzWfubRyglXl gOiForUW4bqx+pC3UFwC8JYghT8Gw8B2x0866Jp5syKR06caoQOR6KUzG9DIacCk X+NsQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3ysafh1h8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 15 Jun 2024 21:42:36 -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; Sat, 15 Jun 2024 21:42:34 -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; Sat, 15 Jun 2024 21:42:34 -0700 Received: from BG-LT91401.marvell.com (unknown [10.193.65.26]) by maili.marvell.com (Postfix) with ESMTP id C7C745B6953; Sat, 15 Jun 2024 21:42:31 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Akhil Goyal , Fan Zhang , Gowrishankar Muthukrishnan , Arkadiusz Kusztal , Ciara Power CC: Anoob Joseph , Subject: [PATCH v1 1/4] test/crypto: validate modex result from first nonzero value Date: Sun, 16 Jun 2024 10:12:17 +0530 Message-ID: <20240616044223.2841-2-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240616044223.2841-1-gmuthukrishn@marvell.com> References: <20240616044223.2841-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: WW4WH3diOxeH-rbo6s2858EzTlkKy_av X-Proofpoint-GUID: WW4WH3diOxeH-rbo6s2858EzTlkKy_av 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-16_03,2024-06-14_03,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 17daf734e8..c26be9b2bf 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; -- 2.25.1