Skip to content

Commit 7654161

Browse files
committed
psa: Add NV seed as an entropy source when needed
When MBEDTLS_PSA_INJECT_ENTROPY is used, we now require also defining MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES. When MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES is defined, we do not add entropy sources by default. This includes the NV seed entropy source, which the PSA entropy injection API is built upon. The PSA entropy injection feature depends on using NV seed as an entropy source. Add NV seed as an entropy source for PSA entropy injection. Fixes e3dbdd8 ("Gate entropy injection through a dedicated configuration option")
1 parent d5072d1 commit 7654161

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/psa_crypto.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4639,6 +4639,15 @@ psa_status_t psa_crypto_init( void )
46394639

46404640
/* Initialize the random generator. */
46414641
global_data.entropy_init( &global_data.entropy );
4642+
#if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \
4643+
defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES)
4644+
/* The PSA entropy injection feature depends on using NV seed as an entropy
4645+
* source. Add NV seed as an entropy source for PSA entropy injection. */
4646+
mbedtls_entropy_add_source( &global_data.entropy,
4647+
mbedtls_nv_seed_poll, NULL,
4648+
MBEDTLS_ENTROPY_BLOCK_SIZE,
4649+
MBEDTLS_ENTROPY_SOURCE_STRONG );
4650+
#endif
46424651
mbedtls_ctr_drbg_init( &global_data.ctr_drbg );
46434652
global_data.rng_state = RNG_INITIALIZED;
46444653
status = mbedtls_to_psa_error(

0 commit comments

Comments
 (0)