aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <jack@randombit.net>2020-03-08 08:05:24 -0400
committerJack Lloyd <jack@randombit.net>2020-03-08 08:05:24 -0400
commit41b0d9a178df3b734e5a88c2be0f2c8e549dfda4 (patch)
tree93eab9043cf910e6cfb6944e20589489c5cea642
parent9999cf59c604cef4bbebda3048c53732627fe851 (diff)
Prevent reallocations in X
Due to progressively setting higher bits as the computation proceeds.
-rw-r--r--src/lib/math/numbertheory/mod_inv.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/lib/math/numbertheory/mod_inv.cpp b/src/lib/math/numbertheory/mod_inv.cpp
index ce8afb893..013b5bdc5 100644
--- a/src/lib/math/numbertheory/mod_inv.cpp
+++ b/src/lib/math/numbertheory/mod_inv.cpp
@@ -221,6 +221,7 @@ BigInt inverse_mod_pow2(const BigInt& a1, size_t k)
const size_t a_words = a.sig_words();
+ X.grow_to(round_up(k, BOTAN_MP_WORD_BITS) / BOTAN_MP_WORD_BITS);
b.grow_to(a_words);
/*