Skip to content

Commit 8b42439

Browse files
mbedtls_hmac_drbg_set_entropy_len() only matters when reseeding
The documentation of HMAC_DRBG erroneously claimed that mbedtls_hmac_drbg_set_entropy_len() had an impact on the initial seeding. This is in fact not the case: mbedtls_hmac_drbg_seed() forces the entropy length to its chosen value. Fix the documentation.
1 parent cc74872 commit 8b42439

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

include/mbedtls/hmac_drbg.h

+14-11
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ void mbedtls_hmac_drbg_init( mbedtls_hmac_drbg_context *ctx );
139139
* Note that SHA-256 is just as efficient as SHA-224.
140140
* The security strength can be reduced if a smaller
141141
* entropy length is set with
142-
* mbedtls_hmac_drbg_set_entropy_len().
142+
* mbedtls_hmac_drbg_set_entropy_len() afterwards.
143143
*
144-
* \note The default entropy length is the security strength
145-
* (converted from bits to bytes). You can override
146-
* it mbedtls_hmac_drbg_set_entropy_len().
147-
* \p f_entropy is always called with a length that is
148-
* less than or equal to the entropy length.
144+
* \note The entropy length for the initial seeding is
145+
* the security strength (converted from bits to bytes).
146+
* You can set a different entropy length for subsequent
147+
* seeding by calling mbedtls_hmac_drbg_set_entropy_len()
148+
* after this function.
149149
*
150150
* \note During the initial seeding, this function calls
151151
* the entropy source to obtain a nonce
@@ -156,6 +156,8 @@ void mbedtls_hmac_drbg_init( mbedtls_hmac_drbg_context *ctx );
156156
* \param f_entropy The entropy callback, taking as arguments the
157157
* \p p_entropy context, the buffer to fill, and the
158158
* length of the buffer.
159+
* \p f_entropy is always called with a length that is
160+
* less than or equal to the entropy length.
159161
* \param p_entropy The entropy context to pass to \p f_entropy.
160162
* \param custom The personalization string.
161163
* This can be \c NULL, in which case the personalization
@@ -222,13 +224,14 @@ void mbedtls_hmac_drbg_set_prediction_resistance( mbedtls_hmac_drbg_context *ctx
222224

223225
/**
224226
* \brief This function sets the amount of entropy grabbed on each
225-
* seed or reseed.
227+
* reseed.
226228
*
227-
* During the initial seeding, mbedtls_hmac_drbg_seed() additionally grabs
228-
* half this amount to create the nonce.
229+
* The default value is set by mbedtls_hmac_drbg_seed().
229230
*
230-
* The default value is given by the security strength, which depends on the
231-
* hash used. See the documentation of mbedtls_hmac_drbg_seed() for details.
231+
* \note mbedtls_hmac_drbg_seed() always sets the entropy length
232+
* to the default value based on the chosen MD algorithm,
233+
* so this function only has an effect if it is called
234+
* after mbedtls_hmac_drbg_seed().
232235
*
233236
* \param ctx The HMAC_DRBG context.
234237
* \param len The amount of entropy to grab, in bytes.

0 commit comments

Comments
 (0)