Skip to content

Commit cad1223

Browse files
authored
Merge pull request #138 from Patater/add-entropy-injection-source
psa: Add NV seed as an entropy source when needed
2 parents d5072d1 + 7654161 commit cad1223

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)