- The \p custom string. In addition, if you do not pass a nonce in \p custom, the sum of the entropy length and the entropy nonce length must be: - at least 24 bytes for a 128-bit strength (maximum achievable strength when using AES-128); - at least 48 bytes for a 256-bit strength (maximum achievable strength when using AES-256).
The CTR_DRBG context to seed. It must have been initialized with mbedtls_ctr_drbg_init(). After a successful call to mbedtls_ctr_drbg_seed(), you may not call mbedtls_ctr_drbg_seed() again on the same context unless you call mbedtls_ctr_drbg_free() and mbedtls_ctr_drbg_init() again first. After a failed call to mbedtls_ctr_drbg_seed(), you must call mbedtls_ctr_drbg_free().
f_entropy
int(*)(void*,unsignedchar*,size_t)
The entropy callback, taking as arguments the \p p_entropy context, the buffer to fill, and the length of the buffer. \p f_entropy is always called with a buffer size less than or equal to the entropy length.
p_entropy
void*
The entropy context to pass to \p f_entropy.
custom
constunsignedchar*
The personalization string. This can be \c NULL, in which case the personalization string is empty regardless of the value of \p len.
len
size_t
The length of the personalization string. This must be at most #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - #MBEDTLS_CTR_DRBG_ENTROPY_LEN.
Return value
\c 0 on success. #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure.
Notes
To achieve the nominal security strength permitted by CTR_DRBG, the entropy length must be: - at least 16 bytes for a 128-bit strength (maximum achievable strength when using AES-128); - at least 32 bytes for a 256-bit strength (maximum achievable strength when using AES-256).
This function sets the amount of entropy grabbed as a nonce for the initial seeding. Call this function before calling mbedtls_ctr_drbg_seed() to read a nonce from the entropy source during the initial seeding.
This function sets the reseed interval. The reseed interval is the number of calls to mbedtls_ctr_drbg_random() or mbedtls_ctr_drbg_random_with_add() after which the entropy function is called again. The default value is #MBEDTLS_CTR_DRBG_RESEED_INTERVAL.