1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

psa: Initialize crypto in tests that need to

Don't unconditionally enable PSA Crypto for all tests. Only enable it in
tests that require it. This allows crypto tests to check that
psa_crypto_init() fails when it is supposed to fail, since we want to
perform some action in a test, and then call psa_crypto_init() and check
the result without it having been called previously.
This commit is contained in:
Jaeden Amero
2019-02-13 11:30:22 +00:00
committed by Andrzej Kurek
parent 08b807a161
commit 3ea2687053
4 changed files with 21 additions and 14 deletions

View File

@@ -962,6 +962,8 @@ void auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
#else
if( use_psa == 1 )
{
TEST_ASSERT( psa_crypto_init() == 0 );
/* PSA requires that the tag immediately follows the ciphertext. */
tmp_cipher = mbedtls_calloc( 1, cipher->len + tag->len );
TEST_ASSERT( tmp_cipher != NULL );
@@ -1104,6 +1106,7 @@ void test_vec_crypt( int cipher_id, int operation, char *hex_key,
#else
if( use_psa == 1 )
{
TEST_ASSERT( psa_crypto_init() == 0 );
TEST_ASSERT( 0 == mbedtls_cipher_setup_psa( &ctx,
mbedtls_cipher_info_from_type( cipher_id ), 0 ) );
}