Merge remote-tracking branch 'upstream/pr/2945' into baremetal

* upstream/pr/2945:
  Rename macro MBEDTLS_MAX_RAND_DELAY
  Update signature of mbedtls_platform_random_delay
  Replace mbedtls_platform_enforce_volatile_reads 2
  Replace mbedtls_platform_enforce_volatile_reads
  Add more variation to random delay countermeasure
  Add random  delay to enforce_volatile_reads
  Update comments of mbedtls_platform_random_delay
  Follow Mbed TLS coding style
  Add random delay function to platform_utils
This commit is contained in:
Arto Kinnunen 2020-01-17 11:21:16 +02:00
commit 10a2ffde5d
10 changed files with 72 additions and 43 deletions

View file

@ -239,11 +239,18 @@ int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num );
uint32_t mbedtls_platform_random_in_range( size_t num );
/**
* \brief This function does nothing, but can be inserted between
* successive reads to a volatile local variable to prevent
* compilers from optimizing them away.
* \brief Random delay function.
*
* Function implements a random delay by incrementing a local
* variable randomized number of times (busy-looping).
*
* Duration of the delay is random as number of variable increments
* is randomized.
*
* \note Currently the function is dependent of hardware providing an
* rng with MBEDTLS_ENTROPY_HARDWARE_ALT.
*/
void mbedtls_platform_enforce_volatile_reads( void );
void mbedtls_platform_random_delay( void );
#if defined(MBEDTLS_HAVE_TIME_DATE)
/**