Test for all alignment combinations

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
Dave Rodgman 2022-11-23 16:11:04 +00:00
parent 3c8eb7e990
commit 15531bc6d2

View file

@ -68,14 +68,19 @@ void mbedtls_xor( int len )
mbedtls_xor( r2, r2, r2, n );
ASSERT_COMPARE( r1, n, r2, n );
/* Test non-word-aligned buffers */
fill_arrays( a + 1, b + 1, r1 + 1, r2 + 1, n );
for ( size_t i = 0; i < n; i++ )
/* Test non-word-aligned buffers, for all combinations of alignedness */
for ( int i = 0; i < 7; i++ )
{
r1[i + 1] = a[i + 1] ^ b[i + 1];
int r_off = i & 1, a_off = (i & 2) >> 1, b_off = (i & 4) >> 2;
fill_arrays( a, b, r1, r2, n + 1 );
for ( size_t i = 0; i < n; i++ )
{
r1[i + r_off] = a[i + a_off] ^ b[i + b_off];
}
mbedtls_xor( r2 + r_off, a + a_off, b + b_off, n );
ASSERT_COMPARE( r1 + r_off, n, r2 + r_off, n );
}
mbedtls_xor( r2 + 1, a + 1, b + 1, n );
ASSERT_COMPARE( r1 + 1, n, r2 + 1, n );
exit:
if ( a != NULL ) mbedtls_free( a );
if ( a != NULL ) mbedtls_free( b );