Add test cases for SHA3 hash family for Digest and Digest-Verify. Signed-off-by: Volodymyr Fialko <vfia...@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