mpi_core_exp_mod: fix local variable type
On platforms with size_t different from int, mismatch between size_t and
mpi_uint can cause incorrect results or complaints from the compiler.
Signed-off-by: Janos Follath <janos.follath@arm.com>
mpi_core_exp_mod: Cast local variable explicitly
Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum_core.c b/library/bignum_core.c
index 227351b..3b660d0 100644
--- a/library/bignum_core.c
+++ b/library/bignum_core.c
@@ -618,7 +618,7 @@
E += E_len; /* Skip to end of exponent buffer */
wsize = mpi_exp_mod_get_window_size( E_len * biL );
- welem = 1 << wsize;
+ welem = ( (size_t) 1 ) << wsize;
/* Allocate memory pool and set pointers to parts of it */
const size_t table_limbs = welem * n;
@@ -663,8 +663,8 @@
memcpy( X, Wtbl, n * ciL );
size_t limb_bits_remaining = 0;
- mbedtls_mpi_uint window = 0;
- size_t window_bits = 0, cur_limb;
+ mbedtls_mpi_uint cur_limb, window = 0;
+ size_t window_bits = 0;
while( 1 )
{
size_t window_bits_missing = wsize - window_bits;