mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-25 20:46:57 +00:00
Random delay can be disabled in configuration
Use random delay depending on whether MBEDTLS_FI_COUNTERMEASURES is defined Signed-off-by: Piotr Nowicki <piotr.nowicki@arm.com>
This commit is contained in:
parent
77b7a7754c
commit
057daa3b28
|
@ -262,6 +262,10 @@ uint32_t mbedtls_platform_random_in_range( uint32_t num );
|
|||
*
|
||||
* Duration of the delay is random as number of variable increments
|
||||
* is randomized.
|
||||
*
|
||||
* \note This function works only if the MBEDTLS_FI_COUNTERMEASURES flag
|
||||
* is defined in the configuration. Otherwise, the function does
|
||||
* nothing.
|
||||
*/
|
||||
void mbedtls_platform_random_delay( void );
|
||||
|
||||
|
|
|
@ -255,6 +255,7 @@ uint32_t mbedtls_platform_random_in_range( uint32_t num )
|
|||
|
||||
void mbedtls_platform_random_delay( void )
|
||||
{
|
||||
#if defined(MBEDTLS_FI_COUNTERMEASURES)
|
||||
uint32_t rn_1, rn_2, rn_3;
|
||||
volatile size_t i = 0;
|
||||
uint8_t shift;
|
||||
|
@ -276,6 +277,9 @@ void mbedtls_platform_random_delay( void )
|
|||
rn_3 = ( rn_3 << shift ) | ( rn_3 >> ( 32 - shift ) );
|
||||
rn_2 ^= rn_3;
|
||||
} while( i < rn_1 || rn_2 == 0 || rn_3 == 0 );
|
||||
|
||||
#endif /* MBEDTLS_FI_COUNTERMEASURES */
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
|
|
Loading…
Reference in a new issue