File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -243,13 +243,12 @@ int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx,
243
243
return ( MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA );
244
244
#endif
245
245
246
+ if ( ( ret = mbedtls_md_hmac_starts ( ctx , password , plen ) ) != 0 )
247
+ return ( ret );
246
248
while ( key_length )
247
249
{
248
250
// U1 ends up in work
249
251
//
250
- if ( ( ret = mbedtls_md_hmac_starts ( ctx , password , plen ) ) != 0 )
251
- return ( ret );
252
-
253
252
if ( ( ret = mbedtls_md_hmac_update ( ctx , salt , slen ) ) != 0 )
254
253
return ( ret );
255
254
@@ -259,21 +258,24 @@ int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx,
259
258
if ( ( ret = mbedtls_md_hmac_finish ( ctx , work ) ) != 0 )
260
259
return ( ret );
261
260
261
+ if ( ( ret = mbedtls_md_hmac_reset ( ctx ) ) != 0 )
262
+ return ( ret );
263
+
262
264
memcpy ( md1 , work , md_size );
263
265
264
266
for ( i = 1 ; i < iteration_count ; i ++ )
265
267
{
266
268
// U2 ends up in md1
267
269
//
268
- if ( ( ret = mbedtls_md_hmac_starts ( ctx , password , plen ) ) != 0 )
269
- return ( ret );
270
-
271
270
if ( ( ret = mbedtls_md_hmac_update ( ctx , md1 , md_size ) ) != 0 )
272
271
return ( ret );
273
272
274
273
if ( ( ret = mbedtls_md_hmac_finish ( ctx , md1 ) ) != 0 )
275
274
return ( ret );
276
275
276
+ if ( ( ret = mbedtls_md_hmac_reset ( ctx ) ) != 0 )
277
+ return ( ret );
278
+
277
279
// U1 xor U2
278
280
//
279
281
for ( j = 0 ; j < md_size ; j ++ )
You can’t perform that action at this time.
0 commit comments