From f2b3818a69eafdc0575511bcb1687a9535ad9bae Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Tue, 20 Sep 2022 09:08:31 +0100 Subject: [PATCH] Test when all three inputs to mbedtls_mpi_core_sub() are aliased Signed-off-by: Tom Cosgrove --- tests/suites/test_suite_mpi.function | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/suites/test_suite_mpi.function b/tests/suites/test_suite_mpi.function index 0cf961b85..60000d322 100644 --- a/tests/suites/test_suite_mpi.function +++ b/tests/suites/test_suite_mpi.function @@ -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 );