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>
Cc: Anoob Joseph <anoobj@marvell.com>,
	Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Subject: [PATCH v3 3/3] test/crypto: add modex tests for zero padded operands
Date: Wed, 26 Jun 2024 15:33:42 +0530	[thread overview]
Message-ID: <20240626100345.1758-4-gmuthukrishn@marvell.com> (raw)
In-Reply-To: <20240626100345.1758-1-gmuthukrishn@marvell.com>

Add modex tests for zero padded operands, as in ASN encoding.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_cryptodev_asym.c             | 16 +++++
 app/test/test_cryptodev_mod_test_vectors.h | 75 ++++++++++++++++++++++
 2 files changed, 91 insertions(+)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index fec53f87db..ef926c6229 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -3510,6 +3510,14 @@ static struct unit_test_suite cryptodev_openssl_asym_testsuite  = {
 				test_rsa_sign_verify_crt),
 		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_inv),
 		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_exp),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Modex test for zero padding",
+			ut_setup_asym, ut_teardown_asym,
+			modular_exponentiation, &modex_test_cases[0]),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Modex test for zero padding (2)",
+			ut_setup_asym, ut_teardown_asym,
+			modular_exponentiation, &modex_test_cases[1]),
 		TEST_CASE_NAMED_WITH_DATA(
 			"Modex Group 5 test",
 			ut_setup_asym, ut_teardown_asym,
@@ -3585,6 +3593,14 @@ static struct unit_test_suite cryptodev_octeontx_asym_testsuite  = {
 		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym,
 				test_rsa_sign_verify_crt),
 		TEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_mod_exp),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Modex test for zero padding",
+			ut_setup_asym, ut_teardown_asym,
+			modular_exponentiation, &modex_test_cases[0]),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Modex test for zero padding (2)",
+			ut_setup_asym, ut_teardown_asym,
+			modular_exponentiation, &modex_test_cases[1]),
 		TEST_CASE_NAMED_WITH_DATA(
 			"Modex Group 5 test",
 			ut_setup_asym, ut_teardown_asym,
diff --git a/app/test/test_cryptodev_mod_test_vectors.h b/app/test/test_cryptodev_mod_test_vectors.h
index a4e06c0291..34af2d73b7 100644
--- a/app/test/test_cryptodev_mod_test_vectors.h
+++ b/app/test/test_cryptodev_mod_test_vectors.h
@@ -265,6 +265,81 @@ struct rte_crypto_asym_xform modinv_xform = {
 	}
 };
 
+static const struct
+modex_test_data modex_test_cases[] = {
+{
+	.description = "Modular Exponentiation (mod=20, base=20, exp=12, res=18)",
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0x00, 0x00, 0x45, 0xCA, 0x2C, 0x5C, 0x3A, 0x90,
+			0x00, 0xC4, 0xD7, 0x47, 0xA8, 0x2B, 0x12, 0x07,
+			0xBD, 0x1F, 0xD7, 0x81
+		},
+		.len = 20
+	},
+	.exponent = {
+		.data = {
+			0x00, 0x00, 0x00, 0x75, 0x74, 0x19, 0x19, 0x69,
+			0xBF, 0x15, 0x2A, 0xAC
+		},
+		.len = 12
+	},
+	.reminder = {
+		.data = {
+			0x5c, 0x94, 0x8f, 0x00, 0x79, 0xe3, 0xe1, 0x0b,
+			0x3f, 0x3e, 0x36, 0x75, 0xed, 0x1d, 0x84, 0xc6,
+			0x36, 0x9e
+		},
+		.len = 18
+	},
+	.modulus = {
+		.data = {
+			0x00, 0x00, 0x99, 0x28, 0x09, 0x8A, 0xE9, 0x89,
+			0xBB, 0x81, 0x3B, 0x07, 0x0E, 0x31, 0x00, 0x7F,
+			0x79, 0x97, 0xED, 0x35
+		},
+		.len = 20
+	}
+},
+{
+	.description = "Modular Exponentiation (mod=32, base=20, exp=12, res=17)",
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.base = {
+		.data = {
+			0x01, 0x31, 0x72, 0xFB, 0x81, 0x9D, 0x81, 0x7A,
+			0x91, 0xDC, 0xE6, 0x6C, 0x2D, 0x55, 0xD9, 0x25,
+			0x7A, 0xB2, 0xFF, 0xFF
+		},
+		.len = 20
+	},
+	.exponent = {
+		.data = {
+			0x00, 0x00, 0x00, 0x02, 0x36, 0x38, 0x31, 0x47,
+			0x3C, 0x07, 0x36, 0x21
+		},
+		.len = 12
+	},
+	.reminder = {
+		.data = {
+			0x02, 0x99, 0x2F, 0xE3, 0x00, 0x9F, 0xF0, 0x9E,
+			0x65, 0x3C, 0x0B, 0x4A, 0xD3, 0x1B, 0x7C, 0x7F,
+			0x1C
+		},
+		.len = 17
+	},
+	.modulus = {
+		.data = {
+			0x00, 0x00, 0x00, 0x00,	0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+			0xCE, 0xF0, 0x7C, 0x13, 0x26, 0x90, 0xAF, 0x49,
+			0x06, 0x4D, 0xA4, 0x5C, 0xB2, 0x43, 0x13, 0x25,
+		},
+		.len = 32
+	}
+}
+};
+
 static const struct
 modex_test_data modex_group_test_cases[] = {
 {
-- 
2.25.1


  parent reply	other threads:[~2024-06-26 10:11 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   ` [PATCH v2 1/4] test/crypto: validate modex result from first nonzero value Gowrishankar Muthukrishnan
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     ` Gowrishankar Muthukrishnan [this message]
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=20240626100345.1758-4-gmuthukrishn@marvell.com \
    --to=gmuthukrishn@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=gakhil@marvell.com \
    /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).