/* BEGIN_HEADER */ #include #if defined(MBEDTLS_PSA_CRYPTO_SPM) #include "spm/psa_defs.h" #endif #include "psa/crypto.h" /* END_HEADER */ /* BEGIN_DEPENDENCIES * depends_on:MBEDTLS_PSA_CRYPTO_C * END_DEPENDENCIES */ /* BEGIN_CASE */ void init_deinit( int count ) { psa_status_t status; int i; for( i = 0; i < count; i++ ) { status = psa_crypto_init( ); TEST_ASSERT( status == PSA_SUCCESS ); status = psa_crypto_init( ); TEST_ASSERT( status == PSA_SUCCESS ); mbedtls_psa_crypto_free( ); } } /* END_CASE */ /* BEGIN_CASE */ void validate_module_init_generate_random( int count ) { psa_status_t status; uint8_t random[10] = { 0 }; int i; for( i = 0; i < count; i++ ) { status = psa_crypto_init( ); TEST_ASSERT( status == PSA_SUCCESS ); mbedtls_psa_crypto_free( ); } status = psa_generate_random( random, sizeof( random ) ); TEST_ASSERT( status == PSA_ERROR_BAD_STATE ); } /* END_CASE */ /* BEGIN_CASE */ void validate_module_init_key_based( int count ) { psa_status_t status; uint8_t data[10] = { 0 }; int i; for( i = 0; i < count; i++ ) { status = psa_crypto_init( ); TEST_ASSERT( status == PSA_SUCCESS ); mbedtls_psa_crypto_free( ); } status = psa_import_key( 1, PSA_KEY_TYPE_RAW_DATA, data, sizeof( data ) ); TEST_ASSERT( status == PSA_ERROR_BAD_STATE ); } /* END_CASE */