DPDK patches and discussions
 help / color / mirror / Atom feed
From: Volodymyr Fialko <vfialko@marvell.com>
To: <dev@dpdk.org>, Akhil Goyal <gakhil@marvell.com>,
	Fan Zhang <royzhang1980@gmail.com>,
	Yipeng Wang <yipeng1.wang@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Cc: <jerinj@marvell.com>, <anoobj@marvell.com>,
	<vikas.gupta@broadcom.com>, <raveendra.padasalagi@broadcom.com>,
	<ravi1.kumar@amd.com>, Volodymyr Fialko <vfialko@marvell.com>
Subject: [PATCH] app/test: add SHA3 test cases
Date: Wed, 9 Nov 2022 16:28:09 +0100	[thread overview]
Message-ID: <20221109152809.2026484-1-vfialko@marvell.com> (raw)

Add test cases for SHA3 hash family for Digest and Digest-Verify.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>

Expected vectors were generated with OpenSSL. Adding to CC original authors of PMDs that currently
have support for SHA3 to check if there's any issues.

---
 app/test/test_cryptodev_hash_test_vectors.h | 286 ++++++++++++++++++++
 1 file changed, 286 insertions(+)

diff --git a/app/test/test_cryptodev_hash_test_vectors.h b/app/test/test_cryptodev_hash_test_vectors.h
index 62602310b2..4b57286fa5 100644
--- a/app/test/test_cryptodev_hash_test_vectors.h
+++ b/app/test/test_cryptodev_hash_test_vectors.h
@@ -332,6 +332,212 @@ hmac_sha512_test_vector = {
 	}
 };
 
+static const struct blockcipher_test_data
+sha3_224_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_224,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.digest = {
+		.data = {
+			0xFF, 0x7D, 0xAB, 0xC4, 0xB8, 0xF8, 0x0D, 0x5C,
+			0x3A, 0xD3, 0xCD, 0x71, 0x58, 0x62, 0x24, 0x0F,
+			0xCC, 0x58, 0xE4, 0x42, 0x1B, 0xA3, 0x6F, 0xE8,
+			0x9A, 0x44, 0xBF, 0x45
+		},
+		.len = 28,
+		.truncated_len = 28
+	}
+};
+
+static const struct blockcipher_test_data
+hmac_sha3_224_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_224_HMAC,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
+			0xFB, 0xBF, 0xB0, 0x8C
+		},
+		.len = 28
+	},
+	.digest = {
+		.data = {
+			0x86, 0xDB, 0x99, 0x80, 0xFC, 0x13, 0x75, 0x4E,
+			0xB5, 0x30, 0x7A, 0x58, 0xC1, 0x0D, 0xE4, 0x00,
+			0x7F, 0xE3, 0xD8, 0xC2, 0x0E, 0x0C, 0xC1, 0xFD,
+			0xF9, 0x33, 0x05, 0x40
+		},
+		.len = 28,
+		.truncated_len = 14
+	}
+};
+
+static const struct blockcipher_test_data
+sha3_256_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_256,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.digest = {
+		.data = {
+			0xC3, 0x6B, 0x73, 0xF4, 0x97, 0x7F, 0xFA, 0xD9,
+			0x35, 0xF1, 0x1F, 0x54, 0x35, 0xC2, 0x19, 0x6C,
+			0xA2, 0x24, 0xC7, 0x01, 0xAD, 0xCC, 0xD4, 0x35,
+			0x88, 0xB9, 0x0C, 0x15, 0xAE, 0x3F, 0x92, 0x47
+		},
+		.len = 32,
+		.truncated_len = 32
+	}
+};
+
+static const struct blockcipher_test_data
+hmac_sha3_256_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_256_HMAC,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
+			0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC
+		},
+		.len = 32
+	},
+	.digest = {
+		.data = {
+			0x8E, 0xB1, 0xBD, 0xEE, 0xEF, 0x26, 0xDD, 0xE7,
+			0x66, 0xBD, 0x9C, 0x2B, 0xBC, 0x5D, 0x6E, 0xC8,
+			0x8C, 0x4A, 0x9C, 0x79, 0xD7, 0x05, 0xDE, 0xFC,
+			0x21, 0x48, 0xD5, 0x95, 0x6D, 0x37, 0x0E, 0x00
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+static const struct blockcipher_test_data
+sha3_384_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_384,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.digest = {
+		.data = {
+			0x56, 0x18, 0x64, 0x95, 0x70, 0x64, 0x32, 0x80,
+			0xB3, 0x67, 0x7B, 0xE3, 0x09, 0x75, 0x92, 0x2B,
+			0x56, 0x40, 0xA9, 0xC5, 0x19, 0x47, 0x50, 0x33,
+			0xA7, 0xA2, 0x2B, 0x45, 0x46, 0xFD, 0x69, 0xE5,
+			0xDE, 0x2B, 0x35, 0xE6, 0x06, 0xC7, 0x0D, 0x28,
+			0x5A, 0xFB, 0x37, 0x4A, 0xE5, 0x8F, 0x9F, 0x4A
+		},
+		.len = 48,
+		.truncated_len = 48
+	}
+};
+
+static const struct blockcipher_test_data
+hmac_sha3_384_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_384_HMAC,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
+			0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC,
+			0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05,
+			0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89
+		},
+		.len = 48
+	},
+	.digest = {
+		.data = {
+			0x91, 0xCF, 0x69, 0xE5, 0x5A, 0x1A, 0x54, 0x0C,
+			0xE2, 0xA9, 0xE7, 0x06, 0xF2, 0x44, 0xA7, 0x8A,
+			0x0B, 0x5C, 0xD6, 0x34, 0x8F, 0xF7, 0x08, 0x90,
+			0x0D, 0xF1, 0x60, 0xC6, 0xD3, 0x90, 0xA9, 0x10,
+			0xAF, 0xA1, 0xEA, 0x83, 0x2E, 0xB8, 0x35, 0xD9,
+			0x7B, 0x70, 0xB1, 0x13, 0x08, 0xA8, 0x90, 0x07
+		},
+		.len = 48,
+		.truncated_len = 24
+	}
+};
+
+static const struct blockcipher_test_data
+sha3_512_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_512,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.digest = {
+		.data = {
+			0x0B, 0xFF, 0x02, 0x45, 0xC5, 0xE7, 0x72, 0xD6,
+			0x1B, 0xD6, 0x7A, 0xB1, 0xFB, 0x34, 0x0E, 0xAA,
+			0xAE, 0x85, 0xCD, 0x04, 0xC8, 0x77, 0x97, 0xC7,
+			0x99, 0x6A, 0xF8, 0xC1, 0x6A, 0x2A, 0x17, 0xE2,
+			0xE2, 0xBC, 0x32, 0x53, 0x69, 0x9C, 0xCF, 0x02,
+			0x83, 0x3D, 0x89, 0xEE, 0xC9, 0xDF, 0xBC, 0xEC,
+			0xE6, 0xD9, 0x3B, 0x8E, 0xA4, 0xF9, 0x5E, 0x6A,
+			0xBB, 0x32, 0x7C, 0x04, 0x5E, 0xEB, 0x18, 0xC7
+		},
+		.len = 64,
+		.truncated_len = 64
+	}
+};
+
+static const struct blockcipher_test_data
+hmac_sha3_512_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SHA3_512_HMAC,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
+			0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC,
+			0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05,
+			0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89,
+			0xDE, 0xAA, 0x36, 0x44, 0x98, 0x93, 0x97, 0x1E,
+			0x6D, 0x53, 0x83, 0x87, 0xB3, 0xB7, 0x56, 0x41
+		},
+		.len = 64
+	},
+	.digest = {
+		.data = {
+			0x1C, 0x46, 0xD2, 0x95, 0xDC, 0xB4, 0x5F, 0xF8,
+			0xB7, 0x63, 0xA7, 0xCD, 0x27, 0x79, 0x04, 0x9B,
+			0x19, 0x97, 0xBF, 0x41, 0x5C, 0xCC, 0x02, 0xD3,
+			0x19, 0xCB, 0x65, 0x59, 0x43, 0xD8, 0xB7, 0x3B,
+			0xF6, 0xAF, 0xAA, 0xA5, 0x6E, 0x24, 0xA4, 0xFA,
+			0xC6, 0xE0, 0xC1, 0x1B, 0x61, 0xFD, 0xB6, 0xA2,
+			0x3E, 0xF0, 0xD1, 0x64, 0x3B, 0x30, 0x40, 0x67,
+			0xE5, 0x41, 0x82, 0xE8, 0xC8, 0x41, 0x42, 0x3D
+		},
+		.len = 64,
+		.truncated_len = 32
+	}
+};
+
 static const struct blockcipher_test_data
 cmac_test_vector = {
 	.auth_algo = RTE_CRYPTO_AUTH_AES_CMAC,
@@ -567,6 +773,86 @@ static const struct blockcipher_test_case hash_test_cases[] = {
 		.test_data = &hmac_sha512_test_vector,
 		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
 	},
+	{
+		.test_descr = "SHA3_224 Digest",
+		.test_data = &sha3_224_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "SHA3_224 Digest Verify",
+		.test_data = &sha3_224_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SHA3_224 Digest",
+		.test_data = &hmac_sha3_224_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "HMAC-SHA3_224 Digest Verify",
+		.test_data = &hmac_sha3_224_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "SHA3_256 Digest",
+		.test_data = &sha3_256_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "SHA3_256 Digest Verify",
+		.test_data = &sha3_256_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SHA3_256 Digest",
+		.test_data = &hmac_sha3_256_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "HMAC-SHA3_256 Digest Verify",
+		.test_data = &hmac_sha3_256_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "SHA3_384 Digest",
+		.test_data = &sha3_384_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "SHA3_384 Digest Verify",
+		.test_data = &sha3_384_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SHA3_384 Digest",
+		.test_data = &hmac_sha3_384_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "HMAC-SHA3_384 Digest Verify",
+		.test_data = &hmac_sha3_384_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "SHA3_512 Digest",
+		.test_data = &sha3_512_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "SHA3_512 Digest Verify",
+		.test_data = &sha3_512_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SHA3_512 Digest",
+		.test_data = &hmac_sha3_512_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "HMAC-SHA3_512 Digest Verify",
+		.test_data = &hmac_sha3_512_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
 	{
 		.test_descr = "CMAC Digest 12B",
 		.test_data = &cmac_test_vector_12,
-- 
2.25.1


             reply	other threads:[~2022-11-09 15:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 15:28 Volodymyr Fialko [this message]
2022-12-14 16:09 ` Power, Ciara
2023-01-04 11:11   ` 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=20221109152809.2026484-1-vfialko@marvell.com \
    --to=vfialko@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=raveendra.padasalagi@broadcom.com \
    --cc=ravi1.kumar@amd.com \
    --cc=royzhang1980@gmail.com \
    --cc=sameh.gobriel@intel.com \
    --cc=vikas.gupta@broadcom.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@intel.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).