mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-05 06:26:52 +00:00
Add mbedtls_mpi_core_ct_uint_table_lookup tests
Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
e50f2f1a8e
commit
032924f297
2 changed files with 75 additions and 0 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue