Add entropy safety switch.
Add a switch that turns entropy collecting off entirely, but enables mbed TLS to run in an entirely unsafe mode. Enables to test mbed TLS on platforms that don't have their entropy sources integrated yet.
This commit is contained in:
parent
184eea6aa0
commit
53de78444c
6 changed files with 65 additions and 0 deletions
|
@ -73,6 +73,11 @@ void mbedtls_entropy_init( mbedtls_entropy_context *ctx )
|
|||
mbedtls_havege_init( &ctx->havege_data );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_WO_ENTROPY)
|
||||
mbedtls_entropy_add_source( ctx, mbedtls_zero_entropy_poll, NULL,
|
||||
1, MBEDTLS_ENTROPY_SOURCE_STRONG );
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES)
|
||||
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
mbedtls_entropy_add_source( ctx, mbedtls_platform_entropy_poll, NULL,
|
||||
|
|
|
@ -188,6 +188,22 @@ int mbedtls_platform_entropy_poll( void *data,
|
|||
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
#endif /* !MBEDTLS_NO_PLATFORM_ENTROPY */
|
||||
|
||||
#if defined(MBEDTLS_TEST_WO_ENTROPY)
|
||||
int mbedtls_zero_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
((void) data);
|
||||
*olen = 0;
|
||||
|
||||
if( len < sizeof(unsigned char) )
|
||||
return( 0 );
|
||||
|
||||
*olen = sizeof(unsigned char);
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
int mbedtls_hardclock_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue