mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 22:15:45 +01:00
Add block sizes to HMAC metadata validation tests
This commit is contained in:
parent
d9c8260f23
commit
3052f53c37
@ -58,6 +58,9 @@
|
||||
* should be the maximum size of a hash supported by the implementation,
|
||||
* in bytes, and must be no smaller than this maximum.
|
||||
*/
|
||||
/* Note: for HMAC-SHA-3, the block size is 144 bytes for HMAC-SHA3-226,
|
||||
* 136 bytes for HMAC-SHA3-256, 104 bytes for SHA3-384, 72 bytes for
|
||||
* HMAC-SHA3-512. */
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#define PSA_HASH_MAX_SIZE 64
|
||||
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
|
||||
|
@ -60,63 +60,63 @@ hash_algorithm:PSA_ALG_SHA3_512:64
|
||||
|
||||
MAC: HMAC-MD2
|
||||
depends_on:MBEDTLS_MD2_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_MD2 ):ALG_IS_HMAC:16:PSA_KEY_TYPE_HMAC:128
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_MD2 ):16:64
|
||||
|
||||
MAC: HMAC-MD4
|
||||
depends_on:MBEDTLS_MD4_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_MD4 ):ALG_IS_HMAC:16:PSA_KEY_TYPE_HMAC:128
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_MD4 ):16:64
|
||||
|
||||
MAC: HMAC-MD5
|
||||
depends_on:MBEDTLS_MD5_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_MD5 ):ALG_IS_HMAC:16:PSA_KEY_TYPE_HMAC:128
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_MD5 ):16:64
|
||||
|
||||
MAC: HMAC-RIPEMD160
|
||||
depends_on:MBEDTLS_RIPEMD160_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_RIPEMD160 ):ALG_IS_HMAC:20:PSA_KEY_TYPE_HMAC:160
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_RIPEMD160 ):20:64
|
||||
|
||||
MAC: HMAC-SHA-1
|
||||
depends_on:MBEDTLS_SHA1_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_1 ):ALG_IS_HMAC:20:PSA_KEY_TYPE_HMAC:160
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_1 ):20:64
|
||||
|
||||
MAC: HMAC-SHA-224
|
||||
depends_on:MBEDTLS_SHA256_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_224 ):ALG_IS_HMAC:28:PSA_KEY_TYPE_HMAC:224
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_224 ):28:64
|
||||
|
||||
MAC: HMAC-SHA-256
|
||||
depends_on:MBEDTLS_SHA256_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_256 ):ALG_IS_HMAC:32:PSA_KEY_TYPE_HMAC:256
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_256 ):32:64
|
||||
|
||||
MAC: HMAC-SHA-384
|
||||
depends_on:MBEDTLS_SHA512_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_384 ):ALG_IS_HMAC:48:PSA_KEY_TYPE_HMAC:384
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_384 ):48:128
|
||||
|
||||
MAC: HMAC-SHA-512
|
||||
depends_on:MBEDTLS_SHA512_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_512 ):ALG_IS_HMAC:64:PSA_KEY_TYPE_HMAC:512
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_512 ):64:128
|
||||
|
||||
MAC: HMAC-SHA-512/224
|
||||
depends_on:MBEDTLS_SHA512_C:MBEDTLS_SHA512_256
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_512_224 ):ALG_IS_HMAC:28:PSA_KEY_TYPE_HMAC:224
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_512_224 ):28:128
|
||||
|
||||
MAC: HMAC-SHA-512/256
|
||||
depends_on:MBEDTLS_SHA512_C:MBEDTLS_SHA512_256
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_512_256 ):ALG_IS_HMAC:32:PSA_KEY_TYPE_HMAC:256
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA_512_256 ):32:128
|
||||
|
||||
MAC: HMAC-SHA3-224
|
||||
depends_on:MBEDTLS_SHA3_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_224 ):ALG_IS_HMAC:28:PSA_KEY_TYPE_HMAC:224
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_224 ):28:144
|
||||
|
||||
MAC: HMAC-SHA3-256
|
||||
depends_on:MBEDTLS_SHA3_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_256 ):ALG_IS_HMAC:32:PSA_KEY_TYPE_HMAC:256
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_256 ):32:136
|
||||
|
||||
MAC: HMAC-SHA3-384
|
||||
depends_on:MBEDTLS_SHA3_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_384 ):ALG_IS_HMAC:48:PSA_KEY_TYPE_HMAC:384
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_384 ):48:104
|
||||
|
||||
MAC: HMAC-SHA3-512
|
||||
depends_on:MBEDTLS_SHA3_C
|
||||
mac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_512 ):ALG_IS_HMAC:64:PSA_KEY_TYPE_HMAC:512
|
||||
hmac_algorithm:PSA_ALG_HMAC( PSA_ALG_SHA3_512 ):64:72
|
||||
|
||||
MAC: CBC_MAC-AES-128
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_C
|
||||
|
@ -138,7 +138,7 @@ void hash_algorithm( int alg_arg, int length_arg )
|
||||
TEST_ASSERT( PSA_ALG_RSA_OAEP_GET_HASH( rsa_oaep_alg ) == alg );
|
||||
TEST_ASSERT( PSA_ALG_HKDF_GET_HASH( hkdf_alg ) == alg );
|
||||
|
||||
/* Hash length and block size */
|
||||
/* Hash length */
|
||||
TEST_ASSERT( length == PSA_HASH_SIZE( alg ) );
|
||||
TEST_ASSERT( length <= PSA_HASH_MAX_SIZE );
|
||||
}
|
||||
@ -171,6 +171,25 @@ void mac_algorithm( int alg_arg, int classification_flags,
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void hmac_algorithm( int alg_arg,
|
||||
int length_arg,
|
||||
int block_size_arg )
|
||||
{
|
||||
psa_algorithm_t alg = alg_arg;
|
||||
psa_algorithm_t hash_alg = PSA_ALG_HMAC_GET_HASH( alg );
|
||||
size_t block_size = block_size_arg;
|
||||
|
||||
TEST_ASSERT( PSA_ALG_IS_HASH( hash_alg ) );
|
||||
TEST_ASSERT( PSA_ALG_HMAC( hash_alg ) == alg );
|
||||
|
||||
TEST_ASSERT( block_size <= PSA_HMAC_MAX_HASH_BLOCK_SIZE );
|
||||
|
||||
test_mac_algorithm( alg_arg, ALG_IS_HMAC, length_arg,
|
||||
PSA_KEY_TYPE_HMAC, PSA_BYTES_TO_BITS( length_arg ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void cipher_algorithm( int alg_arg, int classification_flags )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user