Skip to content

Commit 07ebf57

Browse files
Note that mbedtls_ctr_drbg_seed() must not be called twice
You can't reuse a CTR_DRBG context without free()ing it. This generally happened to work, but was never guaranteed. It could have failed with alternative implementations of the AES module because mbedtls_ctr_drbg_seed() calls mbedtls_aes_init() on a context which is already initialized if mbedtls_ctr_drbg_seed() hasn't been called before, plausibly causing a memory leak. Since the addition of mbedtls_ctr_drbg_set_nonce_len(), the second call to mbedtls_ctr_drbg_seed() uses a nonsensical value as the entropy nonce length.
1 parent 1fce687 commit 07ebf57

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/mbedtls/ctr_drbg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx );
278278
* (maximum achievable strength when using AES-256).
279279
*
280280
* \param ctx The CTR_DRBG context to seed.
281+
* It must have been initialized with
282+
* mbedtls_ctr_drbg_init().
283+
* After a successful call to mbedtls_ctr_drbg_seed(),
284+
* you may not call mbedtls_ctr_drbg_seed() again on
285+
* the same context unless you call
286+
* mbedtls_ctr_drbg_free() first.
281287
* \param f_entropy The entropy callback, taking as arguments the
282288
* \p p_entropy context, the buffer to fill, and the
283289
* length of the buffer.

0 commit comments

Comments
 (0)