Use MBEDTLS_ENTROPY_HARDWARE_ALT
Use MBEDTLS_ENTROPY_HARDWARE_ALT instead of a new global RNG flag. When this flag is enabled, the platform provides the RNG. When running unit tests, rnd_std_rand should be used by overriding the mbedtls_hardware_poll.
This commit is contained in:
parent
51f65e4b86
commit
e29e8a49b8
3 changed files with 13 additions and 18 deletions
|
@ -38,6 +38,10 @@
|
|||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/threading.h"
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -135,13 +139,20 @@ int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num )
|
|||
return( diff );
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_PLATFORM_GLOBAL_RNG)
|
||||
uint32_t mbedtls_platform_random_in_range( size_t num )
|
||||
{
|
||||
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||
(void) num;
|
||||
return 0;
|
||||
#else
|
||||
uint32_t result = 0;
|
||||
size_t olen = 0;
|
||||
|
||||
mbedtls_hardware_poll( NULL, (unsigned char *) &result, sizeof( result ),
|
||||
&olen );
|
||||
return( result % num );
|
||||
#endif
|
||||
}
|
||||
#endif /* !MBEDTLS_PLATFORM_GLOBAL_RNG */
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
#include <time.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue