mbedtls_ctr_drbg_random_with_add() function
This function updates a CTR_DRBG instance with additional data and uses it to generate random data. This function automatically reseeds if the reseed counter is exceeded or prediction resistance is enabled.
Arguments
p_rng
The CTR_DRBG context. This must be a pointer to a #mbedtls_ctr_drbg_context structure.
output
The buffer to fill.
output_len
The length of the buffer in bytes.
additional
Additional data to update. Can be \c NULL, in which case the additional data is empty regardless of the value of \p add_len.
add_len
The length of the additional data if \p additional is not \c NULL. This must be less than #MBEDTLS_CTR_DRBG_MAX_INPUT and less than #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - \c entropy_len where \c entropy_len is the entropy length configured for the context.
Return value
\c 0 on success. #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure.
Notes
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.
mbedtls_ctr_drbg_random_with_add() is called by 1 function and calls 7 functions:
![]()
mbedtls_ctr_drbg_random_with_add()
mbedtls_ctr_drbg_random_with_add() reads 6 variables and writes 1 variable:
![]()
mbedtls_ctr_drbg_random_with_add()