mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-16 07:09:56 +00:00
Add internal function to reseed PSA RNG
Not applicable to an external RNG. Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -100,6 +100,8 @@ static inline void mbedtls_psa_drbg_free(mbedtls_psa_drbg_context_t *p_rng)
|
|||||||
|
|
||||||
/** Seed the PSA DRBG.
|
/** Seed the PSA DRBG.
|
||||||
*
|
*
|
||||||
|
* \param drbg_ctx The DRBG context to seed.
|
||||||
|
* It must be initialized but not active.
|
||||||
* \param entropy An entropy context to read the seed from.
|
* \param entropy An entropy context to read the seed from.
|
||||||
* \param custom The personalization string.
|
* \param custom The personalization string.
|
||||||
* This can be \c NULL, in which case the personalization
|
* This can be \c NULL, in which case the personalization
|
||||||
@@ -121,6 +123,28 @@ static inline int mbedtls_psa_drbg_seed(mbedtls_psa_drbg_context_t *drbg_ctx,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Reseed the PSA DRBG.
|
||||||
|
*
|
||||||
|
* \param drbg_ctx The DRBG context to reseed.
|
||||||
|
* It must be active.
|
||||||
|
* \param additional Additional data to inject.
|
||||||
|
* \param len The length of \p additional in bytes.
|
||||||
|
* This can be 0 to simply reseed from the entropy source.
|
||||||
|
*
|
||||||
|
* \return \c 0 on success.
|
||||||
|
* \return An Mbed TLS error code (\c MBEDTLS_ERR_xxx) on failure.
|
||||||
|
*/
|
||||||
|
static inline int mbedtls_psa_drbg_reseed(mbedtls_psa_drbg_context_t *drbg_ctx,
|
||||||
|
const unsigned char *additional,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
|
return mbedtls_ctr_drbg_reseed(drbg_ctx, additional, len);
|
||||||
|
#elif defined(MBEDTLS_HMAC_DRBG_C)
|
||||||
|
return mbedtls_hmac_drbg_reseed(drbg_ctx, additional, len);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
||||||
|
|
||||||
#endif /* PSA_CRYPTO_RANDOM_IMPL_H */
|
#endif /* PSA_CRYPTO_RANDOM_IMPL_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user