diff options
author | lloyd <[email protected]> | 2012-07-31 22:54:50 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-07-31 22:54:50 +0000 |
commit | 759a5cc81a59c5315144c332aea412213fc58960 (patch) | |
tree | 7071f13709e5b00415eae5e0e062a6dd548bd42a | |
parent | e74d42c531be30652920f955d7713174f2cb9f7d (diff) |
m_ namespace BigInt members
-rw-r--r-- | src/math/bigint/big_ops2.cpp | 10 | ||||
-rw-r--r-- | src/math/bigint/bigint.cpp | 32 | ||||
-rw-r--r-- | src/math/bigint/bigint.h | 38 |
3 files changed, 40 insertions, 40 deletions
diff --git a/src/math/bigint/big_ops2.cpp b/src/math/bigint/big_ops2.cpp index ea2bdc961..d00d1995d 100644 --- a/src/math/bigint/big_ops2.cpp +++ b/src/math/bigint/big_ops2.cpp @@ -32,12 +32,12 @@ BigInt& BigInt::operator+=(const BigInt& y) { secure_vector<word> z(reg_size - 1); bigint_sub3(&z[0], y.data(), reg_size - 1, data(), x_sw); - copy_mem(®[0], &z[0], z.size()); + copy_mem(&m_reg[0], &z[0], z.size()); set_sign(y.sign()); } else if(relative_size == 0) { - zeroise(reg); + zeroise(m_reg); set_sign(Positive); } else if(relative_size > 0) @@ -159,7 +159,7 @@ word BigInt::operator%=(word mod) word result = (word_at(0) & (mod - 1)); clear(); grow_to(2); - reg[0] = result; + m_reg[0] = result; return result; } @@ -171,9 +171,9 @@ word BigInt::operator%=(word mod) grow_to(2); if(remainder && sign() == BigInt::Negative) - reg[0] = mod - remainder; + m_reg[0] = mod - remainder; else - reg[0] = remainder; + m_reg[0] = remainder; set_sign(BigInt::Positive); diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp index 6afcf72cf..8669beea3 100644 --- a/src/math/bigint/bigint.cpp +++ b/src/math/bigint/bigint.cpp @@ -25,9 +25,9 @@ BigInt::BigInt(u64bit n) const size_t limbs_needed = sizeof(u64bit) / sizeof(word); - reg.resize(4*limbs_needed); + m_reg.resize(4*limbs_needed); for(size_t i = 0; i != limbs_needed; ++i) - reg[i] = ((n >> (i*MP_WORD_BITS)) & MP_WORD_MASK); + m_reg[i] = ((n >> (i*MP_WORD_BITS)) & MP_WORD_MASK); } /* @@ -35,8 +35,8 @@ BigInt::BigInt(u64bit n) */ BigInt::BigInt(Sign s, size_t size) { - reg.resize(round_up<size_t>(size, 8)); - signedness = s; + m_reg.resize(round_up<size_t>(size, 8)); + m_signedness = s; } /* @@ -44,7 +44,7 @@ BigInt::BigInt(Sign s, size_t size) */ BigInt::BigInt(const BigInt& b) { - reg = b.get_reg(); + m_reg = b.get_reg(); set_sign(b.sign()); } @@ -95,7 +95,7 @@ BigInt::BigInt(RandomNumberGenerator& rng, size_t bits) void BigInt::grow_to(size_t n) { if(n > size()) - reg.resize(round_up<size_t>(n, 8)); + m_reg.resize(round_up<size_t>(n, 8)); } /* @@ -123,7 +123,7 @@ byte BigInt::byte_at(size_t n) const if(word_num >= size()) return 0; else - return get_byte(WORD_BYTES - byte_num - 1, reg[word_num]); + return get_byte(WORD_BYTES - byte_num - 1, m_reg[word_num]); } /* @@ -179,7 +179,7 @@ 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); if(which >= size()) grow_to(which + 1); - reg[which] |= mask; + m_reg[which] |= mask; } /* @@ -190,7 +190,7 @@ 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); if(which < size()) - reg[which] &= ~mask; + m_reg[which] &= ~mask; } /* @@ -205,9 +205,9 @@ void BigInt::mask_bits(size_t n) const word mask = (static_cast<word>(1) << (n % MP_WORD_BITS)) - 1; if(top_word < size()) - clear_mem(®[top_word+1], size() - (top_word + 1)); + clear_mem(&m_reg[top_word+1], size() - (top_word + 1)); - reg[top_word] &= mask; + m_reg[top_word] &= mask; } /* @@ -262,9 +262,9 @@ size_t BigInt::encoded_size(Base base) const void BigInt::set_sign(Sign s) { if(is_zero()) - signedness = Positive; + m_signedness = Positive; else - signedness = s; + m_signedness = s; } /* @@ -323,17 +323,17 @@ void BigInt::binary_decode(const byte buf[], size_t length) const size_t WORD_BYTES = sizeof(word); clear(); - reg.resize(round_up<size_t>((length / WORD_BYTES) + 1, 8)); + m_reg.resize(round_up<size_t>((length / WORD_BYTES) + 1, 8)); for(size_t i = 0; i != length / WORD_BYTES; ++i) { const size_t top = length - WORD_BYTES*i; for(size_t j = WORD_BYTES; j > 0; --j) - reg[i] = (reg[i] << 8) | buf[top - j]; + m_reg[i] = (m_reg[i] << 8) | buf[top - j]; } for(size_t i = 0; i != length % WORD_BYTES; ++i) - reg[length / WORD_BYTES] = (reg[length / WORD_BYTES] << 8) | buf[i]; + m_reg[length / WORD_BYTES] = (m_reg[length / WORD_BYTES] << 8) | buf[i]; } } diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h index e23df571b..26cfe91e1 100644 --- a/src/math/bigint/bigint.h +++ b/src/math/bigint/bigint.h @@ -128,19 +128,19 @@ class BOTAN_DLL BigInt * @param i a word index * @return the word at index i */ - word& operator[](size_t i) { return reg[i]; } + word& operator[](size_t i) { return m_reg[i]; } /** * [] operator (array access) * @param i a word index * @return the word at index i */ - const word& operator[](size_t i) const { return reg[i]; } + const word& operator[](size_t i) const { return m_reg[i]; } /** * Zeroize the BigInt */ - void clear() { zeroise(reg); } + void clear() { zeroise(m_reg); } /** * Compare this to another BigInt @@ -178,7 +178,7 @@ class BOTAN_DLL BigInt const size_t sw = sig_words(); for(size_t i = 0; i != sw; ++i) - if(reg[i]) + if(m_reg[i]) return false; return true; } @@ -236,7 +236,7 @@ class BOTAN_DLL BigInt * @return value at position n */ word word_at(size_t n) const - { return ((n < size()) ? reg[n] : 0); } + { return ((n < size()) ? m_reg[n] : 0); } /** * Tests if the sign of the integer is negative @@ -254,7 +254,7 @@ class BOTAN_DLL BigInt * Return the sign of the integer * @result the sign of the integer */ - Sign sign() const { return (signedness); } + Sign sign() const { return (m_signedness); } /** * @result the opposite sign of the represented integer value @@ -289,8 +289,8 @@ class BOTAN_DLL BigInt */ size_t sig_words() const { - const word* x = ®[0]; - size_t sig = reg.size(); + const word* x = &m_reg[0]; + size_t sig = m_reg.size(); while(sig && (x[sig-1] == 0)) sig--; @@ -314,14 +314,14 @@ class BOTAN_DLL BigInt * @result a pointer to the start of the internal register of * the integer value */ - word* data() { return ®[0]; } + word* data() { return &m_reg[0]; } /** * Return a pointer to the big integer word register * @result a pointer to the start of the internal register of * the integer value */ - const word* data() const { return ®[0]; } + const word* data() const { return &m_reg[0]; } /** * return a reference to the internal register containing the value @@ -329,22 +329,22 @@ class BOTAN_DLL BigInt * with the internal register value (containing the integer * value) */ - secure_vector<word>& get_reg() { return reg; } + secure_vector<word>& get_reg() { return m_reg; } /** * return a const reference to the internal register containing the value * @result a const reference to the word-array (secure_vector<word>) * with the internal register value (containing the integer value) */ - const secure_vector<word>& get_reg() const { return reg; } + const secure_vector<word>& get_reg() const { return m_reg; } /** * Assign using a plain word array */ void assign(const word x[], size_t length) { - reg.resize(length); - copy_mem(®[0], x, length); + m_reg.resize(length); + copy_mem(&m_reg[0], x, length); } /** @@ -472,14 +472,14 @@ class BOTAN_DLL BigInt */ void swap(BigInt& other) { - reg.swap(other.reg); - std::swap(signedness, other.signedness); + m_reg.swap(other.m_reg); + std::swap(m_signedness, other.m_signedness); } /** * Create empty BigInt */ - BigInt() { signedness = Positive; } + BigInt() { m_signedness = Positive; } /** * Create BigInt from 64 bit integer @@ -560,8 +560,8 @@ class BOTAN_DLL BigInt */ BigInt& operator=(const BigInt&) = default; private: - secure_vector<word> reg; - Sign signedness; + secure_vector<word> m_reg; + Sign m_signedness; }; /* |