diff options
author | Jack Lloyd <[email protected]> | 2018-03-01 16:54:27 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-01 16:54:27 -0500 |
commit | 2bea955063e1df520531339a9f7e39531f68a2ca (patch) | |
tree | ea31f94d7091dc334363171287370a519375bdff /src/lib/math/bigint | |
parent | 03e3d3dac4b50a6da3cfec2971460c1182cebd9d (diff) |
Remove MP_WORD_BITS constant
Use the BOTAN_MP_WORD_BITS consistently
Diffstat (limited to 'src/lib/math/bigint')
-rw-r--r-- | src/lib/math/bigint/big_ops2.cpp | 8 | ||||
-rw-r--r-- | src/lib/math/bigint/big_ops3.cpp | 8 | ||||
-rw-r--r-- | src/lib/math/bigint/bigint.cpp | 12 | ||||
-rw-r--r-- | src/lib/math/bigint/divide.cpp | 6 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp index 233a3ed19..9277834ba 100644 --- a/src/lib/math/bigint/big_ops2.cpp +++ b/src/lib/math/bigint/big_ops2.cpp @@ -255,8 +255,8 @@ BigInt& BigInt::operator<<=(size_t shift) { if(shift) { - const size_t shift_words = shift / MP_WORD_BITS, - shift_bits = shift % MP_WORD_BITS, + const size_t shift_words = shift / BOTAN_MP_WORD_BITS, + shift_bits = shift % BOTAN_MP_WORD_BITS, words = sig_words(); /* @@ -282,8 +282,8 @@ BigInt& BigInt::operator>>=(size_t shift) { if(shift) { - const size_t shift_words = shift / MP_WORD_BITS, - shift_bits = shift % MP_WORD_BITS; + const size_t shift_words = shift / BOTAN_MP_WORD_BITS, + shift_bits = shift % BOTAN_MP_WORD_BITS; bigint_shr1(mutable_data(), sig_words(), shift_words, shift_bits); diff --git a/src/lib/math/bigint/big_ops3.cpp b/src/lib/math/bigint/big_ops3.cpp index db11eeea9..ce9047b15 100644 --- a/src/lib/math/bigint/big_ops3.cpp +++ b/src/lib/math/bigint/big_ops3.cpp @@ -169,8 +169,8 @@ BigInt operator<<(const BigInt& x, size_t shift) if(shift == 0) return x; - const size_t shift_words = shift / MP_WORD_BITS, - shift_bits = shift % MP_WORD_BITS; + const size_t shift_words = shift / BOTAN_MP_WORD_BITS, + shift_bits = shift % BOTAN_MP_WORD_BITS; const size_t x_sw = x.sig_words(); @@ -189,8 +189,8 @@ BigInt operator>>(const BigInt& x, size_t shift) if(x.bits() <= shift) return 0; - const size_t shift_words = shift / MP_WORD_BITS, - shift_bits = shift % MP_WORD_BITS, + const size_t shift_words = shift / BOTAN_MP_WORD_BITS, + shift_bits = shift % BOTAN_MP_WORD_BITS, x_sw = x.sig_words(); BigInt y(x.sign(), x_sw - shift_words); diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp index c21ce89fc..a722e0e4b 100644 --- a/src/lib/math/bigint/bigint.cpp +++ b/src/lib/math/bigint/bigint.cpp @@ -30,7 +30,7 @@ BigInt::BigInt(uint64_t n) m_reg.resize(limbs_needed); for(size_t i = 0; i != limbs_needed; ++i) - m_reg[i] = ((n >> (i*MP_WORD_BITS)) & MP_WORD_MASK); + m_reg[i] = ((n >> (i*BOTAN_MP_WORD_BITS)) & MP_WORD_MASK); } /* @@ -160,8 +160,8 @@ uint32_t BigInt::to_u32bit() const */ void BigInt::set_bit(size_t n) { - const size_t which = n / MP_WORD_BITS; - const word mask = static_cast<word>(1) << (n % MP_WORD_BITS); + const size_t which = n / BOTAN_MP_WORD_BITS; + const word mask = static_cast<word>(1) << (n % BOTAN_MP_WORD_BITS); if(which >= size()) grow_to(which + 1); m_reg[which] |= mask; } @@ -171,8 +171,8 @@ void BigInt::set_bit(size_t n) */ void BigInt::clear_bit(size_t n) { - const size_t which = n / MP_WORD_BITS; - const word mask = static_cast<word>(1) << (n % MP_WORD_BITS); + const size_t which = n / BOTAN_MP_WORD_BITS; + const word mask = static_cast<word>(1) << (n % BOTAN_MP_WORD_BITS); if(which < size()) m_reg[which] &= ~mask; } @@ -193,7 +193,7 @@ size_t BigInt::bits() const return 0; const size_t full_words = words - 1; - return (full_words * MP_WORD_BITS + high_bit(word_at(full_words))); + return (full_words * BOTAN_MP_WORD_BITS + high_bit(word_at(full_words))); } /* diff --git a/src/lib/math/bigint/divide.cpp b/src/lib/math/bigint/divide.cpp index 13696d6d3..63326d655 100644 --- a/src/lib/math/bigint/divide.cpp +++ b/src/lib/math/bigint/divide.cpp @@ -101,7 +101,7 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r) return; } - BigInt temp = y << (MP_WORD_BITS * (n-t)); + BigInt temp = y << (BOTAN_MP_WORD_BITS * (n-t)); while(r >= temp) { r -= temp; q_words[n-t] += 1; } @@ -123,11 +123,11 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r) q_words[j-t-1] -= 1; } - r -= (q_words[j-t-1] * y) << (MP_WORD_BITS * (j-t-1)); + r -= (q_words[j-t-1] * y) << (BOTAN_MP_WORD_BITS * (j-t-1)); if(r.is_negative()) { - r += y << (MP_WORD_BITS * (j-t-1)); + r += y << (BOTAN_MP_WORD_BITS * (j-t-1)); q_words[j-t-1] -= 1; } } |