Skip to main content

psa_random_deplete

Function psa_random_deplete 

Source
pub unsafe extern "C" fn psa_random_deplete() -> psa_status_t
Expand description

Force a reseed of the PSA random generator the next time it is used.

The entropy source(s) are the ones configured at compile time.

The random generator is always seeded automatically before use, and it is reseeded as needed based on the configured policy, so most applications do not need to call this function.

This function has a similar purpose as psa_random_reseed(), but the reseed will happen the next time the random generator is used. The advantage of this function is that it does not fail unless the system is in an unintended state, so it can be used in contexts where propagating errors is difficult.

\note This function has no effect when #MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled.

\note If prediction resistance is enabled (either explicitly, or because the reseed interval is set to 1), calling this function is unnecessary since the random generator will always reseed anyway.

\retval #PSA_SUCCESS The reseed succeeded. \retval #PSA_ERROR_BAD_STATE The PSA random generator is not active. \retval #PSA_ERROR_NOT_SUPPORTED PSA uses an external random generator because the compilation option #MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled. This configuration does not support explicit reseeding.