mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 13:25:41 +01:00
Document thread safety for CTR_DRBG
random(), and only this function, is thread-safe. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com> Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
parent
2ecc0b89f3
commit
831956980c
@ -284,6 +284,15 @@ void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx );
|
|||||||
* device.
|
* device.
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
|
/**
|
||||||
|
* \note When Mbed TLS is built with threading support,
|
||||||
|
* after this function returns successfully,
|
||||||
|
* it is safe to call mbedtls_ctr_drbg_random()
|
||||||
|
* from multiple threads. Other operations, including
|
||||||
|
* reseeding, are not thread-safe.
|
||||||
|
*/
|
||||||
|
#endif /* MBEDTLS_THREADING_C */
|
||||||
/**
|
/**
|
||||||
* \param ctx The CTR_DRBG context to seed.
|
* \param ctx The CTR_DRBG context to seed.
|
||||||
* It must have been initialized with
|
* It must have been initialized with
|
||||||
@ -293,6 +302,8 @@ void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx );
|
|||||||
* the same context unless you call
|
* the same context unless you call
|
||||||
* mbedtls_ctr_drbg_free() and mbedtls_ctr_drbg_init()
|
* mbedtls_ctr_drbg_free() and mbedtls_ctr_drbg_init()
|
||||||
* again first.
|
* again first.
|
||||||
|
* After a failed call to mbedtls_ctr_drbg_seed(),
|
||||||
|
* you must call mbedtls_ctr_drbg_free().
|
||||||
* \param f_entropy The entropy callback, taking as arguments the
|
* \param f_entropy The entropy callback, taking as arguments the
|
||||||
* \p p_entropy context, the buffer to fill, and the
|
* \p p_entropy context, the buffer to fill, and the
|
||||||
* length of the buffer.
|
* length of the buffer.
|
||||||
@ -384,6 +395,11 @@ void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx,
|
|||||||
* \brief This function reseeds the CTR_DRBG context, that is
|
* \brief This function reseeds the CTR_DRBG context, that is
|
||||||
* extracts data from the entropy source.
|
* extracts data from the entropy source.
|
||||||
*
|
*
|
||||||
|
* \note This function is not thread-safe. It is not safe
|
||||||
|
* to call this function if another thread might be
|
||||||
|
* concurrently obtaining random numbers from the same
|
||||||
|
* context or updating or reseeding the same context.
|
||||||
|
*
|
||||||
* \param ctx The CTR_DRBG context.
|
* \param ctx The CTR_DRBG context.
|
||||||
* \param additional Additional data to add to the state. Can be \c NULL.
|
* \param additional Additional data to add to the state. Can be \c NULL.
|
||||||
* \param len The length of the additional data.
|
* \param len The length of the additional data.
|
||||||
@ -401,6 +417,11 @@ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
|
|||||||
/**
|
/**
|
||||||
* \brief This function updates the state of the CTR_DRBG context.
|
* \brief This function updates the state of the CTR_DRBG context.
|
||||||
*
|
*
|
||||||
|
* \note This function is not thread-safe. It is not safe
|
||||||
|
* to call this function if another thread might be
|
||||||
|
* concurrently obtaining random numbers from the same
|
||||||
|
* context or updating or reseeding the same context.
|
||||||
|
*
|
||||||
* \param ctx The CTR_DRBG context.
|
* \param ctx The CTR_DRBG context.
|
||||||
* \param additional The data to update the state with. This must not be
|
* \param additional The data to update the state with. This must not be
|
||||||
* \c NULL unless \p add_len is \c 0.
|
* \c NULL unless \p add_len is \c 0.
|
||||||
@ -424,6 +445,11 @@ int mbedtls_ctr_drbg_update_ret( mbedtls_ctr_drbg_context *ctx,
|
|||||||
* This function automatically reseeds if the reseed counter is exceeded
|
* This function automatically reseeds if the reseed counter is exceeded
|
||||||
* or prediction resistance is enabled.
|
* or prediction resistance is enabled.
|
||||||
*
|
*
|
||||||
|
* \note This function is not thread-safe. It is not safe
|
||||||
|
* to call this function if another thread might be
|
||||||
|
* concurrently obtaining random numbers from the same
|
||||||
|
* context or updating or reseeding the same context.
|
||||||
|
*
|
||||||
* \param p_rng The CTR_DRBG context. This must be a pointer to a
|
* \param p_rng The CTR_DRBG context. This must be a pointer to a
|
||||||
* #mbedtls_ctr_drbg_context structure.
|
* #mbedtls_ctr_drbg_context structure.
|
||||||
* \param output The buffer to fill.
|
* \param output The buffer to fill.
|
||||||
@ -452,8 +478,16 @@ int mbedtls_ctr_drbg_random_with_add( void *p_rng,
|
|||||||
*
|
*
|
||||||
* This function automatically reseeds if the reseed counter is exceeded
|
* This function automatically reseeds if the reseed counter is exceeded
|
||||||
* or prediction resistance is enabled.
|
* or prediction resistance is enabled.
|
||||||
*
|
*/
|
||||||
*
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
|
/**
|
||||||
|
* \note When Mbed TLS is built with threading support,
|
||||||
|
* it is safe to call mbedtls_ctr_drbg_random()
|
||||||
|
* from multiple threads. Other operations, including
|
||||||
|
* reseeding, are not thread-safe.
|
||||||
|
*/
|
||||||
|
#endif /* MBEDTLS_THREADING_C */
|
||||||
|
/**
|
||||||
* \param p_rng The CTR_DRBG context. This must be a pointer to a
|
* \param p_rng The CTR_DRBG context. This must be a pointer to a
|
||||||
* #mbedtls_ctr_drbg_context structure.
|
* #mbedtls_ctr_drbg_context structure.
|
||||||
* \param output The buffer to fill.
|
* \param output The buffer to fill.
|
||||||
|
Loading…
Reference in New Issue
Block a user