mbed-os5 only for TYBLE16
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
Diff: features/mbedtls/mbed-crypto/src/pkcs5.c
- Revision:
- 1:9db0e321a9f4
- Parent:
- 0:5b88d5760320
diff -r 5b88d5760320 -r 9db0e321a9f4 features/mbedtls/mbed-crypto/src/pkcs5.c --- a/features/mbedtls/mbed-crypto/src/pkcs5.c Tue Dec 17 23:23:45 2019 +0000 +++ b/features/mbedtls/mbed-crypto/src/pkcs5.c Tue Dec 31 06:02:27 2019 +0000 @@ -243,13 +243,12 @@ return( MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA ); #endif + if( ( ret = mbedtls_md_hmac_starts( ctx, password, plen ) ) != 0 ) + return( ret ); while( key_length ) { // U1 ends up in work // - if( ( ret = mbedtls_md_hmac_starts( ctx, password, plen ) ) != 0 ) - return( ret ); - if( ( ret = mbedtls_md_hmac_update( ctx, salt, slen ) ) != 0 ) return( ret ); @@ -259,21 +258,24 @@ if( ( ret = mbedtls_md_hmac_finish( ctx, work ) ) != 0 ) return( ret ); + if( ( ret = mbedtls_md_hmac_reset( ctx ) ) != 0 ) + return( ret ); + memcpy( md1, work, md_size ); for( i = 1; i < iteration_count; i++ ) { // U2 ends up in md1 // - if( ( ret = mbedtls_md_hmac_starts( ctx, password, plen ) ) != 0 ) - return( ret ); - if( ( ret = mbedtls_md_hmac_update( ctx, md1, md_size ) ) != 0 ) return( ret ); if( ( ret = mbedtls_md_hmac_finish( ctx, md1 ) ) != 0 ) return( ret ); + if( ( ret = mbedtls_md_hmac_reset( ctx ) ) != 0 ) + return( ret ); + // U1 xor U2 // for( j = 0; j < md_size; j++ )