Fix CI failure.

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 <piotr.nowicki@arm.com>
This commit is contained in:
Piotr Nowicki 2020-08-11 13:58:47 +02:00
parent 057daa3b28
commit 26c33692b0

View File

@ -269,8 +269,8 @@ void mbedtls_platform_random_delay( void )
i++; i++;
/* Dummy calculations to increase the time between iterations and /* Dummy calculations to increase the time between iterations and
* make side channel attack more difficult by reducing predictability * make side channel attack more difficult by reducing predictability
* of its behaviour */ * of its behaviour. */
shift = rn_2 & 0x07; shift = ( rn_2 & 0x07 ) + 1;
if ( i % 2 ) if ( i % 2 )
rn_2 = ( rn_2 >> shift ) | ( rn_2 << ( 32 - shift ) ); rn_2 = ( rn_2 >> shift ) | ( rn_2 << ( 32 - shift ) );
else else