mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-02 10:01:07 +00:00
entropy_nv_seed: clean up properly
Call mbedtls_entropy_free on test failure. Restore the previous NV seed functions which the call to mbedtls_platform_set_nv_seed() changed. This didn't break anything, but only because the NV seed functions used for these tests happened to work for the tests that got executed later in the .data file.
This commit is contained in:
parent
9891124ac0
commit
923f7f9637
|
@ -305,6 +305,10 @@ void entropy_nv_seed( char *read_seed_str )
|
|||
{
|
||||
mbedtls_sha512_context accumulator;
|
||||
mbedtls_entropy_context ctx;
|
||||
int (*original_mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ) =
|
||||
mbedtls_nv_seed_read;
|
||||
int (*original_mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ) =
|
||||
mbedtls_nv_seed_write;
|
||||
|
||||
unsigned char header[2];
|
||||
unsigned char entropy[MBEDTLS_ENTROPY_BLOCK_SIZE];
|
||||
|
@ -373,7 +377,10 @@ void entropy_nv_seed( char *read_seed_str )
|
|||
TEST_ASSERT( memcmp( check_seed, buffer_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
|
||||
TEST_ASSERT( memcmp( check_entropy, entropy, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_entropy_free( &ctx );
|
||||
mbedtls_nv_seed_read = original_mbedtls_nv_seed_read;
|
||||
mbedtls_nv_seed_write = original_mbedtls_nv_seed_write;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
|
Loading…
Reference in a new issue