mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-21 16:27:42 +00:00
Zeroize tmp bufs in hmac_drbg.c functions
This commit is contained in:
parent
fa6fa6850e
commit
beb42837ac
|
@ -342,11 +342,14 @@ int hmac_drbg_write_seed_file( hmac_drbg_context *ctx, const char *path )
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
polarssl_zeroize( buf, sizeof( buf ) );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
int hmac_drbg_update_seed_file( hmac_drbg_context *ctx, const char *path )
|
int hmac_drbg_update_seed_file( hmac_drbg_context *ctx, const char *path )
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
size_t n;
|
size_t n;
|
||||||
unsigned char buf[ POLARSSL_HMAC_DRBG_MAX_INPUT ];
|
unsigned char buf[ POLARSSL_HMAC_DRBG_MAX_INPUT ];
|
||||||
|
@ -365,14 +368,16 @@ int hmac_drbg_update_seed_file( hmac_drbg_context *ctx, const char *path )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fread( buf, 1, n, f ) != n )
|
if( fread( buf, 1, n, f ) != n )
|
||||||
{
|
ret = POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR;
|
||||||
fclose( f );
|
else
|
||||||
return( POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR );
|
hmac_drbg_update( ctx, buf, n );
|
||||||
}
|
|
||||||
|
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
|
||||||
hmac_drbg_update( ctx, buf, n );
|
polarssl_zeroize( buf, sizeof( buf ) );
|
||||||
|
|
||||||
|
if( ret != 0 )
|
||||||
|
return( ret );
|
||||||
|
|
||||||
return( hmac_drbg_write_seed_file( ctx, path ) );
|
return( hmac_drbg_write_seed_file( ctx, path ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue