DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: <dev@dpdk.org>, Akhil Goyal <gakhil@marvell.com>,
	Fan Zhang <fanzhang.oss@gmail.com>,
	Ciara Power <ciara.power@intel.com>,
	"Gowrishankar Muthukrishnan" <gmuthukrishn@marvell.com>,
	Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
Cc: Anoob Joseph <anoobj@marvell.com>, <stable@dpdk.org>
Subject: [PATCH v2 1/4] test/crypto: validate modex result from first nonzero value
Date: Fri, 21 Jun 2024 08:08:26 +0530	[thread overview]
Message-ID: <20240621023832.1707-2-gmuthukrishn@marvell.com> (raw)
In-Reply-To: <20240621023832.1707-1-gmuthukrishn@marvell.com>

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 <gmuthukrishn@marvell.com>
---
 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


  reply	other threads:[~2024-06-21  2:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-16  4:42 [PATCH v1 0/4] test/crypto: enhance modex tests Gowrishankar Muthukrishnan
2024-06-16  4:42 ` [PATCH v1 1/4] test/crypto: validate modex result from first nonzero value Gowrishankar Muthukrishnan
2024-06-16  4:42 ` [PATCH v1 2/4] test/crypto: remove unused variable in modex test data Gowrishankar Muthukrishnan
2024-06-16  4:42 ` [PATCH v1 3/4] test/crypto: use common test function for mod tests Gowrishankar Muthukrishnan
2024-06-16  4:42 ` [PATCH v1 4/4] test/crypto: add modex tests for zero padded operands Gowrishankar Muthukrishnan
2024-06-17  7:12 ` [PATCH v1 0/4] test/crypto: enhance modex tests Anoob Joseph
2024-06-20  7:10 ` Akhil Goyal
2024-06-21  2:38 ` [PATCH v2 " Gowrishankar Muthukrishnan
2024-06-21  2:38   ` Gowrishankar Muthukrishnan [this message]
2024-06-21  2:38   ` [PATCH v2 2/4] test/crypto: remove unused variable in modex test data Gowrishankar Muthukrishnan
2024-06-21  2:38   ` [PATCH v2 3/4] test/crypto: use common test function for mod tests Gowrishankar Muthukrishnan
2024-06-21  2:38   ` [PATCH v2 4/4] test/crypto: add modex tests for zero padded operands Gowrishankar Muthukrishnan
2024-06-26 10:03   ` [PATCH v3 0/3] test/crypto: add modex test for zero padding Gowrishankar Muthukrishnan
2024-06-26 10:03     ` [PATCH v3 1/3] test/crypto: validate modex result from first nonzero value Gowrishankar Muthukrishnan
2024-06-26 10:03     ` [PATCH v3 2/3] test/crypto: remove unused variable in modex test data Gowrishankar Muthukrishnan
2024-06-26 10:03     ` [PATCH v3 3/3] test/crypto: add modex tests for zero padded operands Gowrishankar Muthukrishnan
2024-06-27  5:12     ` [PATCH v3 0/3] test/crypto: add modex test for zero padding Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240621023832.1707-2-gmuthukrishn@marvell.com \
    --to=gmuthukrishn@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=arkadiuszx.kusztal@intel.com \
    --cc=ciara.power@intel.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=gakhil@marvell.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).