Test for all alignment combinations
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/tests/suites/test_suite_common.function b/tests/suites/test_suite_common.function
index 8412e60..6c0d4af 100644
--- a/tests/suites/test_suite_common.function
+++ b/tests/suites/test_suite_common.function
@@ -68,14 +68,19 @@
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 );