Add test for unaligned buffers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
c36a56e890
commit
8c18baf8c1
1 changed files with 13 additions and 4 deletions
|
@ -18,10 +18,10 @@ void mbedtls_xor( int len )
|
|||
{
|
||||
size_t n = (size_t) len;
|
||||
unsigned char *a = NULL, *b = NULL, *r1 = NULL, *r2 = NULL;
|
||||
ASSERT_ALLOC( a, n );
|
||||
ASSERT_ALLOC( b, n );
|
||||
ASSERT_ALLOC( r1, n );
|
||||
ASSERT_ALLOC( r2, n );
|
||||
ASSERT_ALLOC( a, n + 1 );
|
||||
ASSERT_ALLOC( b, n + 1 );
|
||||
ASSERT_ALLOC( r1, n + 1 );
|
||||
ASSERT_ALLOC( r2, n + 1 );
|
||||
|
||||
/* Test non-overlapping */
|
||||
fill_arrays( a, b, r1, r2, n );
|
||||
|
@ -67,6 +67,15 @@ 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++ )
|
||||
{
|
||||
r1[i + 1] = a[i + 1] ^ b[i + 1];
|
||||
}
|
||||
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 );
|
||||
|
|
Loading…
Reference in a new issue