mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-08 13:03:39 +00:00
Test subtraction if the parameters are aliased to each other
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
4d3f3c5430
commit
b3b3466657
@ -314,9 +314,29 @@ void mpi_mod_raw_sub( char * input_A,
|
||||
MBEDTLS_MPI_MOD_REP_MONTGOMERY ), 0 );
|
||||
|
||||
mbedtls_mpi_mod_raw_sub( X, A, B, &m );
|
||||
|
||||
ASSERT_COMPARE( X, bytes, res, bytes );
|
||||
|
||||
/* alias X to A */
|
||||
memcpy( X, A, bytes );
|
||||
mbedtls_mpi_mod_raw_sub( X, X, B, &m );
|
||||
ASSERT_COMPARE( X, bytes, res, bytes );
|
||||
|
||||
/* alias X to B */
|
||||
memcpy( X, B, bytes );
|
||||
mbedtls_mpi_mod_raw_sub( X, A, X, &m );
|
||||
ASSERT_COMPARE( X, bytes, res, bytes );
|
||||
|
||||
/* A == B: alias A and B */
|
||||
if( memcmp( A, B, bytes ) == 0 )
|
||||
{
|
||||
mbedtls_mpi_mod_raw_sub( X, A, A, &m );
|
||||
ASSERT_COMPARE( X, bytes, res, bytes );
|
||||
|
||||
/* X, A, B all aliased together */
|
||||
memcpy( X, A, bytes );
|
||||
mbedtls_mpi_mod_raw_sub( X, X, X, &m );
|
||||
ASSERT_COMPARE( X, bytes, res, bytes );
|
||||
}
|
||||
exit:
|
||||
mbedtls_free( A );
|
||||
mbedtls_free( B );
|
||||
|
Loading…
Reference in New Issue
Block a user