mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
Add mbedtls_mpi_core_ct_uint_table_lookup
This will be needed for extracting modular exponentiation from the prototype. The function signature is kept aligned to the prototype, but the implementation is new. (The implementation of this function in the prototype has further optimisations which are out of scope for now.) The function is not reused in the bignum counterpart as it will become redundant soon. This function is meant to be static, but doesn't have the qualifier as it is not used yet and would cause compiler warnings. The MBEDTLS_STATIC_TESTABLE macro will be added in a later commit. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
@@ -540,4 +540,18 @@ cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
void mbedtls_mpi_core_ct_uint_table_lookup( mbedtls_mpi_uint *dest,
|
||||
const mbedtls_mpi_uint *table,
|
||||
size_t limbs,
|
||||
size_t count,
|
||||
size_t index )
|
||||
{
|
||||
for( size_t i = 0; i < count; i++ )
|
||||
{
|
||||
unsigned char assign = mbedtls_ct_size_bool_eq( i, index );
|
||||
const mbedtls_mpi_uint *current = table + i * limbs;
|
||||
mbedtls_mpi_core_cond_assign( dest, current, limbs, assign );
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_BIGNUM_C */
|
||||
|
Reference in New Issue
Block a user