diff options
author | lloyd <[email protected]> | 2015-05-15 03:31:56 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-05-15 03:31:56 +0000 |
commit | a4e88fa2610da732ea1125b1ed970baed6d286bb (patch) | |
tree | 10e422f42bcf419bbcec835feb4f41c590286bbe /src/lib/math/numbertheory | |
parent | 12eea2e817528e7d1a85e5e80b360eead6e5d206 (diff) |
Fix various bugs found by Coverity scanner.
Uninitialized variables, missing divide by zero checks, missing
virtual destructor, etc. Only thing serious is bug in TLS maximum
fragment decoder; missing breaks in switch statement meant receiver
would treat any negotiated max frament as 4k limit.
Diffstat (limited to 'src/lib/math/numbertheory')
-rw-r--r-- | src/lib/math/numbertheory/numthry.cpp | 3 | ||||
-rw-r--r-- | src/lib/math/numbertheory/powm_mnt.cpp | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/math/numbertheory/numthry.cpp b/src/lib/math/numbertheory/numthry.cpp index fe943cc6b..900e61724 100644 --- a/src/lib/math/numbertheory/numthry.cpp +++ b/src/lib/math/numbertheory/numthry.cpp @@ -176,6 +176,9 @@ BigInt inverse_mod(const BigInt& n, const BigInt& mod) word monty_inverse(word input) { + if(input == 0) + throw std::runtime_error("monty_inverse: divide by zero"); + word b = input; word x2 = 1, x1 = 0, y2 = 0, y1 = 1; diff --git a/src/lib/math/numbertheory/powm_mnt.cpp b/src/lib/math/numbertheory/powm_mnt.cpp index c8bf0928c..5e797b195 100644 --- a/src/lib/math/numbertheory/powm_mnt.cpp +++ b/src/lib/math/numbertheory/powm_mnt.cpp @@ -137,6 +137,7 @@ Montgomery_Exponentiator::Montgomery_Exponentiator(const BigInt& mod, const BigInt r = BigInt::power_of_2(m_mod_words * BOTAN_MP_WORD_BITS); m_R_mod = r % m_modulus; m_R2_mod = (m_R_mod * m_R_mod) % m_modulus; + m_exp_bits = 0; } } |