From 26c33692b0acae11ab260277713d5fabf950e658 Mon Sep 17 00:00:00 2001 From: Piotr Nowicki Date: Tue, 11 Aug 2020 13:58:47 +0200 Subject: [PATCH] Fix CI failure. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For ASanDbg tests of the earlier implementation of the mbedtls_platform_random_in_range(), there was no case where ‘shift’ value was zero. Such a case generated a bit shift of 32, which is treated as an error by ASanDbg. Increasing the ‘shift’ value by one ensures that it will always be non-zero. Signed-off-by: Piotr Nowicki --- library/platform_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/platform_util.c b/library/platform_util.c index 3fa943738f..5e938f9c93 100644 --- a/library/platform_util.c +++ b/library/platform_util.c @@ -269,8 +269,8 @@ void mbedtls_platform_random_delay( void ) i++; /* Dummy calculations to increase the time between iterations and * make side channel attack more difficult by reducing predictability - * of its behaviour */ - shift = rn_2 & 0x07; + * of its behaviour. */ + shift = ( rn_2 & 0x07 ) + 1; if ( i % 2 ) rn_2 = ( rn_2 >> shift ) | ( rn_2 << ( 32 - shift ) ); else