diff options
author | Jack Lloyd <[email protected]> | 2018-12-07 12:09:50 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-07 12:09:50 -0500 |
commit | 9ea9ebe5cb72656717eea35836b0fb827a5cee86 (patch) | |
tree | 6cef2e3d7896dd7506bf9dc157cc0e0c4708089f | |
parent | 63fefbcc6ea922bdd14909e025ded5322bdb9578 (diff) |
Avoid early exit
-rw-r--r-- | src/lib/math/mp/mp_core.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/math/mp/mp_core.h b/src/lib/math/mp/mp_core.h index 9caacf9fb..1ac6f7173 100644 --- a/src/lib/math/mp/mp_core.h +++ b/src/lib/math/mp/mp_core.h @@ -467,16 +467,15 @@ inline void bigint_shl2(word y[], const word x[], size_t x_size, inline void bigint_shr2(word y[], const word x[], size_t x_size, size_t word_shift, size_t bit_shift) { - if(x_size < word_shift) // XXX - return; + const size_t new_size = x_size < word_shift ? 0 : (x_size - word_shift); - copy_mem(y, x + word_shift, x_size - word_shift); + copy_mem(y, x + word_shift, new_size); const auto carry_mask = CT::Mask<word>::expand(bit_shift); const size_t carry_shift = carry_mask.if_set_return(BOTAN_MP_WORD_BITS - bit_shift); word carry = 0; - for(size_t i = x_size - word_shift; i > 0; --i) + for(size_t i = new_size; i > 0; --i) { word w = y[i-1]; y[i-1] = (w >> bit_shift) | carry; |