regression 4002: add tests for HMAC-SHA-3 algorithms
Adds test for HMAC_SHA3_{224,256,384,512}.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/host/xtest/regression_4000.c b/host/xtest/regression_4000.c
index c9a2fe0..505c981 100644
--- a/host/xtest/regression_4000.c
+++ b/host/xtest/regression_4000.c
@@ -1311,6 +1311,18 @@
XTEST_MAC_CASE(TEE_ALG_HMAC_SHA512, TEE_TYPE_HMAC_SHA512,
mac_data_sha512_key1,
13, mac_data_sha512_in1, mac_data_sha512_out1),
+ XTEST_MAC_CASE(TEE_ALG_HMAC_SHA3_224, TEE_TYPE_HMAC_SHA3_224,
+ mac_data_sha3_224_key1,
+ 13, mac_data_sha3_224_in1, mac_data_sha3_224_out1),
+ XTEST_MAC_CASE(TEE_ALG_HMAC_SHA3_256, TEE_TYPE_HMAC_SHA3_256,
+ mac_data_sha3_256_key1,
+ 13, mac_data_sha3_256_in1, mac_data_sha3_256_out1),
+ XTEST_MAC_CASE(TEE_ALG_HMAC_SHA3_384, TEE_TYPE_HMAC_SHA3_384,
+ mac_data_sha3_384_key1,
+ 13, mac_data_sha3_384_in1, mac_data_sha3_384_out1),
+ XTEST_MAC_CASE(TEE_ALG_HMAC_SHA3_512, TEE_TYPE_HMAC_SHA3_512,
+ mac_data_sha3_512_key1,
+ 13, mac_data_sha3_512_in1, mac_data_sha3_512_out1),
XTEST_MAC_CBC_CASE(TEE_ALG_AES_CBC_MAC_NOPAD, TEE_TYPE_AES, vect1, 14),
XTEST_MAC_CBC_CASE(TEE_ALG_DES_CBC_MAC_NOPAD, TEE_TYPE_DES, vect2, 16),
diff --git a/host/xtest/regression_4000_data.h b/host/xtest/regression_4000_data.h
index 238dffd..c1e9b1d 100644
--- a/host/xtest/regression_4000_data.h
+++ b/host/xtest/regression_4000_data.h
@@ -8113,6 +8113,114 @@
};
/*
+ * First example from
+ * https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/HMAC_SHA3-224.pdf
+ */
+static const uint8_t mac_data_sha3_224_key1[28] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b,
+};
+static const uint8_t mac_data_sha3_224_in1[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e,
+};
+static const uint8_t mac_data_sha3_224_out1[] = {
+ 0x33, 0x2c, 0xfd, 0x59, 0x34, 0x7f, 0xdb, 0x8e,
+ 0x57, 0x6e, 0x77, 0x26, 0x0b, 0xe4, 0xab, 0xa2,
+ 0xd6, 0xdc, 0x53, 0x11, 0x7b, 0x3b, 0xfb, 0x52,
+ 0xc6, 0xd1, 0x8c, 0x04,
+};
+
+/*
+ * First example from
+ * https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/HMAC_SHA3-256.pdf
+ */
+static const uint8_t mac_data_sha3_256_key1[32] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+};
+static const uint8_t mac_data_sha3_256_in1[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e,
+};
+static const uint8_t mac_data_sha3_256_out1[] = {
+ 0x4f, 0xe8, 0xe2, 0x02, 0xc4, 0xf0, 0x58, 0xe8,
+ 0xdd, 0xdc, 0x23, 0xd8, 0xc3, 0x4e, 0x46, 0x73,
+ 0x43, 0xe2, 0x35, 0x55, 0xe2, 0x4f, 0xc2, 0xf0,
+ 0x25, 0xd5, 0x98, 0xf5, 0x58, 0xf6, 0x72, 0x05,
+};
+
+/*
+ * First example from
+ * https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/HMAC_SHA3-384.pdf
+ */
+static const uint8_t mac_data_sha3_384_key1[48] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+};
+static const uint8_t mac_data_sha3_384_in1[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e,
+};
+static const uint8_t mac_data_sha3_384_out1[] = {
+ 0xd5, 0x88, 0xa3, 0xc5, 0x1f, 0x3f, 0x2d, 0x90,
+ 0x6e, 0x82, 0x98, 0xc1, 0x19, 0x9a, 0xa8, 0xff,
+ 0x62, 0x96, 0x21, 0x81, 0x27, 0xf6, 0xb3, 0x8a,
+ 0x90, 0xb6, 0xaf, 0xe2, 0xc5, 0x61, 0x77, 0x25,
+ 0xbc, 0x99, 0x98, 0x7f, 0x79, 0xb2, 0x2a, 0x55,
+ 0x7b, 0x65, 0x20, 0xdb, 0x71, 0x0b, 0x7f, 0x42,
+};
+
+/*
+ * First example from
+ * https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/HMAC_SHA3-512.pdf
+ */
+static const uint8_t mac_data_sha3_512_key1[64] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+};
+static const uint8_t mac_data_sha3_512_in1[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e,
+};
+static const uint8_t mac_data_sha3_512_out1[] = {
+ 0x4e, 0xfd, 0x62, 0x9d, 0x6c, 0x71, 0xbf, 0x86,
+ 0x16, 0x26, 0x58, 0xf2, 0x99, 0x43, 0xb1, 0xc3,
+ 0x08, 0xce, 0x27, 0xcd, 0xfa, 0x6d, 0xb0, 0xd9,
+ 0xc3, 0xce, 0x81, 0x76, 0x3f, 0x9c, 0xbc, 0xe5,
+ 0xf7, 0xeb, 0xe9, 0x86, 0x80, 0x31, 0xdb, 0x1a,
+ 0x8f, 0x8e, 0xb7, 0xb6, 0xb9, 0x5e, 0x5c, 0x5e,
+ 0x3f, 0x65, 0x7a, 0x89, 0x96, 0xc8, 0x6a, 0x2f,
+ 0x65, 0x27, 0xe3, 0x07, 0xf0, 0x21, 0x31, 0x96,
+};
+
+/*
* SM3 HMAC
* GM/T 0042-2015
* Section D.3 Test vector 1