From patchwork Wed Nov 9 15:28:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Fialko X-Patchwork-Id: 119617 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6DF0DA034C; Wed, 9 Nov 2022 16:29:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 14F1A400EF; Wed, 9 Nov 2022 16:29:02 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A4DFB400D4 for ; Wed, 9 Nov 2022 16:29:00 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2A96iuqJ014380; Wed, 9 Nov 2022 07:28:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Ovqa+BN7/+DgkTotE5iCLt63AAxw0lKif4drG7hsYcA=; b=CKPri183GjHawCiEm4XwRQ+PtRexP0zoDd9vWHV/LIpTL52Ow/v+UaRWZtV8uVbk361t 87LzGkfSoJzFJQwxr7OQsVb5aevaF9GeEKX1MEBzXVHZ2OhQy8CeZgdp+XaKR24nAr9N BHZ0Yk6+21L1wzn9IOigNWkKC2FKD/dQAeKwZ8EXkA/zpxtznIqnJwpW/Z5OY1HzVcJe owRLuXdasJSUQ9dx2Y5Db0l1PinZYfAZ/sus5nWMKcV7fX0romV5SPENkDYLV17pkz0D MAMwGV0bd+bXEjYsw9aLeCBqhUtl0zNpKf19Lb2avj99AUAq+H1mJgTPUei94Ty8vh6G QQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kr774sphp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 09 Nov 2022 07:28:58 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Nov 2022 07:28:56 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 9 Nov 2022 07:28:56 -0800 Received: from localhost.localdomain (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 1BA113F7045; Wed, 9 Nov 2022 07:28:51 -0800 (PST) From: Volodymyr Fialko To: , Akhil Goyal , Fan Zhang , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin CC: , , , , , Volodymyr Fialko Subject: [PATCH] app/test: add SHA3 test cases Date: Wed, 9 Nov 2022 16:28:09 +0100 Message-ID: <20221109152809.2026484-1-vfialko@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: wyzksARcy7ETkEHEd9xzupywAe2LD68p X-Proofpoint-ORIG-GUID: wyzksARcy7ETkEHEd9xzupywAe2LD68p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-09_06,2022-11-09_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add test cases for SHA3 hash family for Digest and Digest-Verify. Signed-off-by: Volodymyr Fialko 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. Acked-by: Ciara Power --- 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,