Make timing selftest less sensitive
- allow up to 12.5% security/error margin
- use larger delays
- this avoid the security/error margin being too low
The test used to fail about 1 out of 6 times on some buildbots VMs, but never
failed on the physical machines used for development.
diff --git a/library/timing.c b/library/timing.c
index a8c1371..aee9dd4 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -429,25 +429,25 @@
if( verbose != 0 )
mbedtls_printf( " TIMING test #2 (set/get_delay ): " );
- for( a = 100; a <= 200; a += 100 )
+ for( a = 200; a <= 400; a += 200 )
{
- for( b = 100; b <= 200; b += 100 )
+ for( b = 200; b <= 400; b += 200 )
{
mbedtls_timing_set_delay( &ctx, a, a + b );
- busy_msleep( a - a / 10 );
+ busy_msleep( a - a / 8 );
if( mbedtls_timing_get_delay( &ctx ) != 0 )
FAIL;
- busy_msleep( a / 5 );
+ busy_msleep( a / 4 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;
- busy_msleep( b - a / 5 );
+ busy_msleep( b - a / 8 - b / 8 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;
- busy_msleep( b / 5 );
+ busy_msleep( b / 4 );
if( mbedtls_timing_get_delay( &ctx ) != 2 )
FAIL;
}