mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 22:35:43 +01:00
Add a platform function to return a random uint32_t
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
7e6075b7fd
commit
189ee74a82
@ -231,6 +231,18 @@ int mbedtls_platform_memmove( void *dst, const void *src, size_t num );
|
||||
*/
|
||||
int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num );
|
||||
|
||||
/**
|
||||
* \brief RNG-function for getting a random 32-bit integer.
|
||||
*
|
||||
*
|
||||
* \note Currently the function is dependent of hardware providing an
|
||||
* rng with MBEDTLS_ENTROPY_HARDWARE_ALT. By default, 0 is
|
||||
* returned.
|
||||
*
|
||||
* \return The generated random number.
|
||||
*/
|
||||
uint32_t mbedtls_platform_random_uint32( void );
|
||||
|
||||
/**
|
||||
* \brief RNG-function for getting a random in given range.
|
||||
*
|
||||
|
@ -172,6 +172,20 @@ int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num )
|
||||
return( (int) diff | (int) ( flow_counter ^ num ) );
|
||||
}
|
||||
|
||||
uint32_t mbedtls_platform_random_uint32( )
|
||||
{
|
||||
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||
return 0;
|
||||
#else
|
||||
uint32_t result = 0;
|
||||
size_t olen = 0;
|
||||
|
||||
mbedtls_hardware_poll( NULL, (unsigned char *) &result, sizeof( result ),
|
||||
&olen );
|
||||
return( result );
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t mbedtls_platform_random_in_range( size_t num )
|
||||
{
|
||||
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||
|
Loading…
Reference in New Issue
Block a user