mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-18 05:42:35 +00:00
Clean up initialization in _core_exp_mod()
Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
8786dd79f7
commit
afb2079652
@ -765,11 +765,21 @@ static inline void exp_mod_calc_first_bit_optionally_safe(const mbedtls_mpi_uint
|
|||||||
size_t *E_bit_index)
|
size_t *E_bit_index)
|
||||||
{
|
{
|
||||||
if (E_public == MBEDTLS_MPI_IS_PUBLIC) {
|
if (E_public == MBEDTLS_MPI_IS_PUBLIC) {
|
||||||
|
/*
|
||||||
|
* Skip leading zero bits.
|
||||||
|
*/
|
||||||
size_t E_bits = mbedtls_mpi_core_bitlen(E, E_limbs);
|
size_t E_bits = mbedtls_mpi_core_bitlen(E, E_limbs);
|
||||||
if (E_bits != 0) {
|
if (E_bits == 0) {
|
||||||
*E_limb_index = E_bits / biL;
|
/*
|
||||||
*E_bit_index = E_bits % biL;
|
* If E is 0 mbedtls_mpi_core_bitlen() returns 0. Even if that is the case, we will want
|
||||||
|
* to represent it as a single 0 bit and as such the bitlength will be 1.
|
||||||
|
*/
|
||||||
|
E_bits = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*E_limb_index = E_bits / biL;
|
||||||
|
*E_bit_index = E_bits % biL;
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
|
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
|
||||||
mbedtls_mpi_optionally_safe_codepath = MBEDTLS_MPI_IS_PUBLIC;
|
mbedtls_mpi_optionally_safe_codepath = MBEDTLS_MPI_IS_PUBLIC;
|
||||||
#endif
|
#endif
|
||||||
@ -847,8 +857,8 @@ static void mbedtls_mpi_core_exp_mod_optionally_safe(mbedtls_mpi_uint *X,
|
|||||||
/* We'll process the bits of E from most significant
|
/* We'll process the bits of E from most significant
|
||||||
* (limb_index=E_limbs-1, E_bit_index=biL-1) to least significant
|
* (limb_index=E_limbs-1, E_bit_index=biL-1) to least significant
|
||||||
* (limb_index=0, E_bit_index=0). */
|
* (limb_index=0, E_bit_index=0). */
|
||||||
size_t E_limb_index = E_limbs;
|
size_t E_limb_index;
|
||||||
size_t E_bit_index = 0;
|
size_t E_bit_index;
|
||||||
exp_mod_calc_first_bit_optionally_safe(E, E_limbs, E_public,
|
exp_mod_calc_first_bit_optionally_safe(E, E_limbs, E_public,
|
||||||
&E_limb_index, &E_bit_index);
|
&E_limb_index, &E_bit_index);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user