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>
diff --git a/library/platform_util.c b/library/platform_util.c
index 641172a..3fa9437 100644
--- a/library/platform_util.c
+++ b/library/platform_util.c
@@ -255,6 +255,7 @@
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 @@
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)