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 3AC3645625; Mon, 15 Jul 2024 15:38:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 265724067A; Mon, 15 Jul 2024 15:38:45 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id AD24B402B0; Mon, 15 Jul 2024 15:38:43 +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 46FD9obX009289; Mon, 15 Jul 2024 06:38:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=CTGgQefMkn7uFfqWwJRzDkZ eI9mWUtDzvNQ/SKz/hKI=; b=DgYskV5qjWQ9FQFJwGe3PXVztAPyGFeh9yMXK0t IQKKxieeKRm5kP4y0JZjMSKtSGn5lsHTit68EoweNIN1ULxSkXiqmU7JW3NtJ4om +ucsluNaauQL8iUvJiG4ggpK/WKL3cJgrx7BFCfdk3U5U61Qqw/PU/EKqd+23uaZ R05VhqsIkYxCAjHRY4PNYU/DOw7BgR8dXAdQ59DxrTP7dDaBIr3Kwz6l5biGxCLA zcp66PxB5X1dxBSt5hqFkDnGjkTmqCveKSj2YCCG47sPbJ1B4OFBny4Z9K/w3mJp bFTULhSkrOh0wKsoLfWbKlE37RFc5Xw6cAE96VlM++kGEUw== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 40cs5da1c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jul 2024 06:38:42 -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; Mon, 15 Jul 2024 06:38:41 -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; Mon, 15 Jul 2024 06:38:41 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 332383F704E; Mon, 15 Jul 2024 06:38:38 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , Akhil Goyal , Fan Zhang , Gowrishankar Muthukrishnan CC: Anoob Joseph , Subject: [PATCH v1] test/crypto: fix comparison function for modex values Date: Mon, 15 Jul 2024 19:08:33 +0530 Message-ID: <20240715133836.1579-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: QtmG8I0cdXo7lH-S32Zt0XQ5XdAo0Nqd X-Proofpoint-GUID: QtmG8I0cdXo7lH-S32Zt0XQ5XdAo0Nqd 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-07-15_08,2024-07-11_01,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 Fix comparison function used by modex test to check from first non-zero value itself. Coverity issue: 430125 Fixes: 2162d32c1c3 ("test/crypto: validate modex from first non-zero") Cc: stable@dpdk.org Signed-off-by: Gowrishankar Muthukrishnan --- app/test/test_cryptodev_asym.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 1d88832146..f0b5d38543 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -3197,21 +3197,26 @@ static int send_one(void) } static int -modular_cmpeq(const uint8_t *a, const uint8_t *b, size_t len) +modular_cmpeq(const uint8_t *a, size_t a_len, const uint8_t *b, size_t b_len) { - const uint8_t *new_a = a, *new_b = b; + const uint8_t *new_a, *new_b; size_t i, j; /* Strip leading NUL bytes */ - for (i = 0; i < len; i++) + for (i = 0; i < a_len; i++) if (a[i] != 0) - new_a = &a[i]; + break; - for (j = 0; j < len; j++) + for (j = 0; j < b_len; j++) if (b[j] != 0) - new_b = &b[i]; + break; + + if (a_len - i != b_len - j) + return 1; - if (i != j || memcmp(new_a, new_b, len - i)) + new_a = &a[i]; + new_b = &b[j]; + if (memcmp(new_a, new_b, a_len - i)) return 1; return 0; @@ -3251,7 +3256,7 @@ modular_exponentiation(const void *test_data) TEST_ASSERT_SUCCESS(send_one(), "Failed to process crypto op"); - TEST_ASSERT_SUCCESS(modular_cmpeq(vector->reminder.data, + TEST_ASSERT_SUCCESS(modular_cmpeq(vector->reminder.data, vector->reminder.len, self->result_op->asym->modex.result.data, self->result_op->asym->modex.result.length), "operation verification failed\n"); -- 2.21.0