Test when all three inputs to mbedtls_mpi_core_sub() are aliased

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
Tom Cosgrove 2022-09-20 09:08:31 +01:00
parent 3bd7bc3add
commit f2b3818a69

View File

@ -1911,6 +1911,14 @@ void mpi_core_sub( char * input_A, char * input_B,
/* 3b) r = a - b => we should get the correct result */
ASSERT_COMPARE( r, bytes, x, bytes );
/* 4 tests "r may be aliased to [...] both" */
if ( A.n == B.n && memcmp( A.p, B.p, bytes ) == 0 )
{
memcpy( r, b, bytes );
TEST_EQUAL( carry, mbedtls_mpi_core_sub( r, r, r, limbs ) );
ASSERT_COMPARE( r, bytes, x, bytes );
}
exit:
mbedtls_free( a );
mbedtls_free( b );