mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 03:35:35 +00:00
mpi_shrink test: just set the top bit
No need to bypass the API to fill limbs. It's a better test to just set the top bit that we want to have set, and it's one less bypass of the API. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
3f1c3c9605
commit
e109175d05
@ -630,11 +630,14 @@ void mbedtls_mpi_shrink( int before, int used, int min, int after )
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_grow( &X, before ) == 0 );
|
||||
TEST_ASSERT( used <= before );
|
||||
if( before > 0 )
|
||||
memset( X.p, 0x2a, used * sizeof( mbedtls_mpi_uint ) );
|
||||
if( used > 0 )
|
||||
{
|
||||
size_t used_bit_count = used * 8 * sizeof( mbedtls_mpi_uint );
|
||||
TEST_ASSERT( mbedtls_mpi_set_bit( &X, used_bit_count - 1, 1 ) == 0 );
|
||||
}
|
||||
TEST_EQUAL( X.n, (size_t) before );
|
||||
TEST_ASSERT( mbedtls_mpi_shrink( &X, min ) == 0 );
|
||||
TEST_ASSERT( X.n == (size_t) after );
|
||||
TEST_EQUAL( X.n, (size_t) after );
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_free( &X );
|
||||
|
Loading…
x
Reference in New Issue
Block a user