From 7cc8229d80110c4664306d6bc728727c035e7858 Mon Sep 17 00:00:00 2001 From: avolinski Date: Tue, 20 Nov 2018 15:52:25 +0200 Subject: [PATCH] Replace MBED_RANDOM_SEED_ITS_UID with MBEDTLS_RANDOM_SEED_ITS_UID Update mbedtls_psa_inject_entropy function documentation --- include/psa/crypto_extra.h | 12 ++++++------ library/psa_crypto.c | 4 ++-- tests/suites/test_suite_psa_crypto_entropy.function | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h index 13134926f..880e09c24 100644 --- a/include/psa/crypto_extra.h +++ b/include/psa/crypto_extra.h @@ -35,7 +35,7 @@ extern "C" { #endif /* UID for secure storage seed */ -#define MBED_RANDOM_SEED_ITS_UID 0xFFFFFF52 +#define MBEDTLS_RANDOM_SEED_ITS_UID 0xFFFFFF52 /** * \brief Library deinitialization. @@ -91,11 +91,11 @@ void mbedtls_psa_crypto_free( void ); * * \param seed[in] Buffer containing the seed value to inject. * \param seed_size Size of the \p seed buffer. - * The size of the seed must be equal or larger than any - * of the values defined both in - * #MBEDTLS_ENTROPY_MIN_PLATFORM - * and in the #MBEDTLS_ENTROPY_BLOCK_SIZE defines - * and at most #MBEDTLS_ENTROPY_MAX_SEED_SIZE bytes. + * The size of the seed in bytes must be greater + * or equal to both #MBEDTLS_ENTROPY_MIN_PLATFORM + * and #MBEDTLS_ENTROPY_BLOCK_SIZE. + * It must be less or equal to + * #MBEDTLS_ENTROPY_MAX_SEED_SIZE. * * \retval #PSA_SUCCESS * The seed value was injected successfully. The random generator diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 26bea1980..fe73d1d35 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -4240,10 +4240,10 @@ psa_status_t mbedtls_psa_inject_entropy( const unsigned char *seed, ( seed_size > MBEDTLS_ENTROPY_MAX_SEED_SIZE ) ) return( PSA_ERROR_INVALID_ARGUMENT ); - status = psa_its_get_info( MBED_RANDOM_SEED_ITS_UID, &p_info ); + status = psa_its_get_info( MBEDTLS_RANDOM_SEED_ITS_UID, &p_info ); if( PSA_ITS_ERROR_KEY_NOT_FOUND == status ) /* No seed exists */ { - status = psa_its_set( MBED_RANDOM_SEED_ITS_UID, seed_size, seed, 0 ); + status = psa_its_set( MBEDTLS_RANDOM_SEED_ITS_UID, seed_size, seed, 0 ); } else if( PSA_ITS_SUCCESS == status ) { diff --git a/tests/suites/test_suite_psa_crypto_entropy.function b/tests/suites/test_suite_psa_crypto_entropy.function index 1cb58b9a2..4be2c5a34 100644 --- a/tests/suites/test_suite_psa_crypto_entropy.function +++ b/tests/suites/test_suite_psa_crypto_entropy.function @@ -40,7 +40,7 @@ void validate_entropy_seed_injection( int seed_length_a, { seed[i] = i; } - its_status = psa_its_remove(MBED_RANDOM_SEED_ITS_UID); + its_status = psa_its_remove(MBEDTLS_RANDOM_SEED_ITS_UID); TEST_ASSERT( (its_status == PSA_ITS_SUCCESS) || (its_status == PSA_ITS_ERROR_KEY_NOT_FOUND) ); status = mbedtls_psa_inject_entropy( seed, seed_length_a ); TEST_ASSERT( status == expected_status_a ); @@ -51,7 +51,7 @@ void validate_entropy_seed_injection( int seed_length_a, TEST_ASSERT( memcmp( output , zeros, sizeof( output ) ) != 0 ); exit: mbedtls_free( seed ); - psa_its_remove(MBED_RANDOM_SEED_ITS_UID); + psa_its_remove(MBEDTLS_RANDOM_SEED_ITS_UID); mbedtls_psa_crypto_free( ); } /* END_CASE */ @@ -68,11 +68,11 @@ void run_entropy_inject_with_crypto_init( ) { seed[i] = i; } - its_status = psa_its_remove(MBED_RANDOM_SEED_ITS_UID); + its_status = psa_its_remove(MBEDTLS_RANDOM_SEED_ITS_UID); TEST_ASSERT( (its_status == PSA_ITS_SUCCESS) || (its_status == PSA_ITS_ERROR_KEY_NOT_FOUND) ); status = mbedtls_psa_inject_entropy( seed, MBEDTLS_ENTROPY_BLOCK_SIZE ); TEST_ASSERT( status == PSA_SUCCESS ); - its_status = psa_its_remove(MBED_RANDOM_SEED_ITS_UID); + its_status = psa_its_remove(MBEDTLS_RANDOM_SEED_ITS_UID); TEST_ASSERT( its_status == PSA_ITS_SUCCESS ); TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS ); status = mbedtls_psa_inject_entropy( seed, MBEDTLS_ENTROPY_BLOCK_SIZE ); @@ -82,7 +82,7 @@ void run_entropy_inject_with_crypto_init( ) status = mbedtls_psa_inject_entropy( seed, MBEDTLS_ENTROPY_BLOCK_SIZE ); TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED ); exit: - psa_its_remove(MBED_RANDOM_SEED_ITS_UID); + psa_its_remove(MBEDTLS_RANDOM_SEED_ITS_UID); mbedtls_psa_crypto_free( ); } /* END_CASE */