Move wildcard-to-exercisable conversion to exercise_key in test suite

Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
Steven Cooreman 2021-02-23 14:37:38 +01:00
parent 7e39f05929
commit fb9cb92055
2 changed files with 12 additions and 13 deletions

View File

@ -122,6 +122,12 @@ static int exercise_mac_key( mbedtls_svc_key_id_t key,
unsigned char mac[PSA_MAC_MAX_SIZE] = {0};
size_t mac_length = sizeof( mac );
/* Convert wildcard algorithm to exercisable algorithm */
if( alg & PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG )
{
alg = PSA_ALG_TRUNCATED_MAC( alg, PSA_MAC_TRUNCATED_LENGTH( alg ) );
}
if( usage & PSA_KEY_USAGE_SIGN_HASH )
{
PSA_ASSERT( psa_mac_sign_setup( &operation, key, alg ) );
@ -236,6 +242,12 @@ static int exercise_aead_key( mbedtls_svc_key_id_t key,
size_t ciphertext_length = sizeof( ciphertext );
size_t plaintext_length = sizeof( ciphertext );
/* Convert wildcard algorithm to exercisable algorithm */
if( alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG )
{
alg = PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, PSA_ALG_AEAD_GET_TAG_LENGTH( alg ) );
}
/* Default IV length for AES-GCM is 12 bytes */
if( PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, 0 ) ==
PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ) )

View File

@ -1338,19 +1338,6 @@ void copy_success( int source_usage_arg,
export_buffer, length );
}
/* Convert wildcard algorithm to exercisable algorithm */
if( PSA_ALG_IS_WILDCARD( expected_alg ) )
{
if( PSA_ALG_IS_MAC( expected_alg ) )
expected_alg = PSA_ALG_TRUNCATED_MAC(
expected_alg,
PSA_MAC_TRUNCATED_LENGTH( expected_alg ) );
if( PSA_ALG_IS_AEAD( expected_alg ) )
expected_alg = PSA_ALG_AEAD_WITH_SHORTENED_TAG(
expected_alg,
PSA_ALG_AEAD_GET_TAG_LENGTH( expected_alg ) );
}
if( ! mbedtls_test_psa_exercise_key( target_key, expected_usage, expected_alg ) )
goto exit;
if( ! mbedtls_test_psa_exercise_key( target_key, expected_usage, expected_alg2 ) )