mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-24 19:38:21 +00:00
Zeroize tmp bufs in hmac_drbg.c functions
This commit is contained in:
parent
1adcd95a25
commit
3fee7593a9
1 changed files with 10 additions and 5 deletions
|
@ -364,11 +364,14 @@ int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const cha
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
mbedtls_zeroize( buf, sizeof( buf ) );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path )
|
int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path )
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
size_t n;
|
size_t n;
|
||||||
unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ];
|
unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ];
|
||||||
|
@ -387,15 +390,17 @@ int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fread( buf, 1, n, f ) != n )
|
if( fread( buf, 1, n, f ) != n )
|
||||||
{
|
ret = MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR;
|
||||||
fclose( f );
|
else
|
||||||
return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR );
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose( f );
|
|
||||||
|
|
||||||
mbedtls_hmac_drbg_update( ctx, buf, n );
|
mbedtls_hmac_drbg_update( ctx, buf, n );
|
||||||
|
|
||||||
|
fclose( f );
|
||||||
|
|
||||||
|
mbedtls_zeroize( buf, sizeof( buf ) );
|
||||||
|
|
||||||
|
if( ret != 0 )
|
||||||
|
return( ret );
|
||||||
|
|
||||||
return( mbedtls_hmac_drbg_write_seed_file( ctx, path ) );
|
return( mbedtls_hmac_drbg_write_seed_file( ctx, path ) );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_FS_IO */
|
#endif /* MBEDTLS_FS_IO */
|
||||||
|
|
Loading…
Reference in a new issue