mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Add mbedtls_mpi_core_ct_uint_table_lookup tests
Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
@ -941,3 +941,40 @@ exit:
|
||||
mbedtls_mpi_free( &RR_REF );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mpi_core_ct_uint_table_lookup( int bitlen, int window_size )
|
||||
{
|
||||
size_t limbs = BITS_TO_LIMBS( bitlen );
|
||||
size_t count = ( (size_t) 1 ) << window_size;
|
||||
|
||||
mbedtls_mpi_uint *table = NULL;
|
||||
ASSERT_ALLOC( table, limbs * count );
|
||||
|
||||
mbedtls_mpi_uint *dest = NULL;
|
||||
ASSERT_ALLOC( dest, limbs );
|
||||
|
||||
/*
|
||||
* Fill the table with a unique counter so that differences are easily
|
||||
* detected. (And have their relationship to the index relatively non-trivial just
|
||||
* to be sure.)
|
||||
*/
|
||||
for( size_t i = 0; i < count * limbs; i++ )
|
||||
{
|
||||
table[i] = ~i - 1;
|
||||
}
|
||||
|
||||
for( size_t i = 0; i < count; i++ )
|
||||
{
|
||||
memset( dest, 0x00, limbs * sizeof( *dest ) );
|
||||
mbedtls_mpi_core_ct_uint_table_lookup( dest, table, limbs, count, i );
|
||||
|
||||
mbedtls_mpi_uint *current = table + i * limbs;
|
||||
ASSERT_COMPARE( dest, limbs * sizeof( *dest ),
|
||||
current, limbs * sizeof( *current ) );
|
||||
}
|
||||
|
||||
exit:
|
||||
;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
Reference in New Issue
Block a user