Test when all three inputs to mbedtls_mpi_core_sub() are aliased
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
diff --git a/tests/suites/test_suite_mpi.function b/tests/suites/test_suite_mpi.function
index 0cf961b..60000d3 100644
--- a/tests/suites/test_suite_mpi.function
+++ b/tests/suites/test_suite_mpi.function
@@ -1911,6 +1911,14 @@
/* 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 );