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 E152B45500 for ; Wed, 26 Jun 2024 12:10:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA12042EA5; Wed, 26 Jun 2024 12:10:52 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 76DB640672; Wed, 26 Jun 2024 12:03:59 +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 45Q5RL7r005033; Wed, 26 Jun 2024 03:03:58 -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=dJ62daHxBd5VttvaZ dcMb9wObt4QwQli1VzG127YAnx6yqhJlDDmoE8sbh2EpZ6GEEdfrpZaSqqABlkFu TPmVRweJ2fHrst8YKCLrM/ihwZLao3ou5NQzPlUqZCV85XpVJXolU+/lJp9XuAHk gLaYCvfgutLJTLeGRZGZpkAnVcAT3xZjAhwfHT9+I64lQJJojWkfLLgy7WArIxkp JPLhLFyT9RcLH3Ps9dRmmRhUsvd6IpXRJkQPJi5z8gL1cuPiBUfEt8GziRv3nNab Fqmt5oavvaM8Z3TMK8H2mv7QEuaTfj77Cpiwegr4ZybwCO7shsaoV+gJRm+TntEE IkEVQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 400cur8t4h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 03:03:58 -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; Wed, 26 Jun 2024 03:03:57 -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; Wed, 26 Jun 2024 03:03:57 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 6664F3F707D; Wed, 26 Jun 2024 03:03:53 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Akhil Goyal , Fan Zhang , Arkadiusz Kusztal , Ciara Power , Gowrishankar Muthukrishnan CC: Anoob Joseph , Subject: [PATCH v3 1/3] test/crypto: validate modex result from first nonzero value Date: Wed, 26 Jun 2024 15:33:40 +0530 Message-ID: <20240626100345.1758-2-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240626100345.1758-1-gmuthukrishn@marvell.com> References: <20240621023832.1707-1-gmuthukrishn@marvell.com> <20240626100345.1758-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Ib8B17Iyu29oMELrt7cZPkrNgBMNUyrZ X-Proofpoint-GUID: Ib8B17Iyu29oMELrt7cZPkrNgBMNUyrZ 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-26_04,2024-06-25_01,2024-05-17_01 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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; -- 2.25.1