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 23124454B3 for ; Fri, 21 Jun 2024 04:38:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1988A42E96; Fri, 21 Jun 2024 04:38:49 +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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: 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