Setup / deinitialize PSA in pk tests only if no MD is used
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
3d0dfb99c9
commit
7a32072038
3 changed files with 16 additions and 14 deletions
|
@ -276,15 +276,17 @@ psa_key_usage_t mbedtls_test_update_key_usage_flags( psa_key_usage_t usage_flags
|
|||
} \
|
||||
} \
|
||||
while( 0 )
|
||||
#else
|
||||
/* Define empty macros so that we can use them in the preamble and teardown
|
||||
* of every test function that uses PSA conditionally based on
|
||||
* MBEDTLS_PSA_CRYPTO_C. */
|
||||
#define PSA_INIT( ) ( (void) 0 )
|
||||
#define PSA_DONE( ) ( (void) 0 )
|
||||
|
||||
#if !defined(MBEDTLS_MD_C)
|
||||
#define PSA_INIT_IF_NO_MD( ) PSA_INIT( )
|
||||
#define PSA_DONE_IF_NO_MD( ) PSA_DONE( )
|
||||
#endif
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
|
||||
#if defined(MBEDTLS_MD_C)
|
||||
#define PSA_INIT_IF_NO_MD( ) ( (void) 0 )
|
||||
#define PSA_DONE_IF_NO_MD( ) ( (void) 0 )
|
||||
#endif
|
||||
/** \def USE_PSA_INIT
|
||||
*
|
||||
* Call this macro to initialize the PSA subsystem if #MBEDTLS_USE_PSA_CRYPTO
|
||||
|
|
|
@ -14,14 +14,14 @@ void pbkdf2_hmac( int hash, data_t * pw_str, data_t * salt_str,
|
|||
{
|
||||
unsigned char key[100];
|
||||
|
||||
PSA_INIT();
|
||||
PSA_INIT_IF_NO_MD();
|
||||
TEST_ASSERT( mbedtls_pkcs5_pbkdf2_hmac_ext( hash, pw_str->x, pw_str->len,
|
||||
salt_str->x, salt_str->len,
|
||||
it_cnt, key_len, key ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( key, result_key_string->x,
|
||||
key_len, result_key_string->len ) == 0 );
|
||||
PSA_DONE();
|
||||
PSA_DONE_IF_NO_MD();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
@ -33,7 +33,7 @@ void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw,
|
|||
mbedtls_asn1_buf params;
|
||||
unsigned char *my_out = NULL;
|
||||
|
||||
PSA_INIT();
|
||||
PSA_INIT_IF_NO_MD();
|
||||
|
||||
params.tag = params_tag;
|
||||
params.p = params_hex->x;
|
||||
|
@ -50,7 +50,7 @@ void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw,
|
|||
|
||||
exit:
|
||||
mbedtls_free( my_out );
|
||||
PSA_DONE();
|
||||
PSA_DONE_IF_NO_MD();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ void pk_parse_keyfile_rsa( char * key_file, char * password, int result )
|
|||
int res;
|
||||
char *pwd = password;
|
||||
|
||||
PSA_INIT();
|
||||
PSA_INIT_IF_NO_MD();
|
||||
mbedtls_pk_init( &ctx );
|
||||
|
||||
if( strcmp( pwd, "NULL" ) == 0 )
|
||||
|
@ -38,7 +38,7 @@ void pk_parse_keyfile_rsa( char * key_file, char * password, int result )
|
|||
|
||||
exit:
|
||||
mbedtls_pk_free( &ctx );
|
||||
PSA_DONE();
|
||||
PSA_DONE_IF_NO_MD();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
@ -48,7 +48,7 @@ void pk_parse_public_keyfile_rsa( char * key_file, int result )
|
|||
mbedtls_pk_context ctx;
|
||||
int res;
|
||||
|
||||
PSA_INIT();
|
||||
PSA_INIT_IF_NO_MD();
|
||||
mbedtls_pk_init( &ctx );
|
||||
|
||||
res = mbedtls_pk_parse_public_keyfile( &ctx, key_file );
|
||||
|
@ -65,7 +65,7 @@ void pk_parse_public_keyfile_rsa( char * key_file, int result )
|
|||
|
||||
exit:
|
||||
mbedtls_pk_free( &ctx );
|
||||
PSA_DONE();
|
||||
PSA_DONE_IF_NO_MD();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
|
Loading…
Reference in a new issue