mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 17:05:42 +01:00
Add a test case for MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED
This commit is contained in:
parent
ed04a676ee
commit
7f246510d0
@ -7,6 +7,9 @@ entropy_seed_file:"data_files/entropy_seed":0
|
||||
Entropy write/update seed file: nonexistent
|
||||
entropy_seed_file:"no_such_dir/file":MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR
|
||||
|
||||
Entropy no sources
|
||||
entropy_no_sources:
|
||||
|
||||
Entropy too many sources
|
||||
entropy_too_many_sources:
|
||||
|
||||
|
@ -45,7 +45,6 @@ static int entropy_dummy_source( void *arg, unsigned char *output,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
/*
|
||||
* Ability to clear entropy sources to allow testing with just predefined
|
||||
* entropy sources. This function or tests depending on it might break if there
|
||||
@ -57,11 +56,12 @@ static int entropy_dummy_source( void *arg, unsigned char *output,
|
||||
* This might break memory checks in the future if sources need 'free-ing' then
|
||||
* as well.
|
||||
*/
|
||||
void entropy_clear_sources( mbedtls_entropy_context *ctx )
|
||||
static void entropy_clear_sources( mbedtls_entropy_context *ctx )
|
||||
{
|
||||
ctx->source_count = 0;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
/*
|
||||
* NV seed read/write functions that use a buffer instead of a file
|
||||
*/
|
||||
@ -148,6 +148,22 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void entropy_no_sources( )
|
||||
{
|
||||
mbedtls_entropy_context ctx;
|
||||
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
|
||||
|
||||
mbedtls_entropy_init( &ctx );
|
||||
entropy_clear_sources( &ctx );
|
||||
TEST_EQUAL( mbedtls_entropy_func( &ctx, buf, sizeof( buf ) ),
|
||||
MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED );
|
||||
|
||||
exit:
|
||||
mbedtls_entropy_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void entropy_too_many_sources( )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user