diff options
author | lloyd <[email protected]> | 2012-08-01 13:46:46 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-08-01 13:46:46 +0000 |
commit | afaac2c3668f0a0fced85649651d3d2ee9101a67 (patch) | |
tree | 8e012510e22065832af086b3c70973fe0820c988 | |
parent | 943c647e7d049a9b00261bbf34aa1443bca0ab02 (diff) |
Rename the version of BigInt::data returning a mutable pointer
to BigInt::mutable_data. Update callers.
-rw-r--r-- | src/math/bigint/big_ops2.cpp | 24 | ||||
-rw-r--r-- | src/math/bigint/big_ops3.cpp | 26 | ||||
-rw-r--r-- | src/math/bigint/bigint.h | 12 | ||||
-rw-r--r-- | src/math/ec_gfp/point_gfp.cpp | 5 | ||||
-rw-r--r-- | src/math/numbertheory/mp_numth.cpp | 9 |
5 files changed, 38 insertions, 38 deletions
diff --git a/src/math/bigint/big_ops2.cpp b/src/math/bigint/big_ops2.cpp index ec5197090..f47cbb4e8 100644 --- a/src/math/bigint/big_ops2.cpp +++ b/src/math/bigint/big_ops2.cpp @@ -23,7 +23,7 @@ BigInt& BigInt::operator+=(const BigInt& y) grow_to(reg_size); if(sign() == y.sign()) - bigint_add2(data(), reg_size - 1, y.data(), y_sw); + bigint_add2(mutable_data(), reg_size - 1, y.data(), y_sw); else { s32bit relative_size = bigint_cmp(data(), x_sw, y.data(), y_sw); @@ -41,7 +41,7 @@ BigInt& BigInt::operator+=(const BigInt& y) set_sign(Positive); } else if(relative_size > 0) - bigint_sub2(data(), x_sw, y.data(), y_sw); + bigint_sub2(mutable_data(), x_sw, y.data(), y_sw); } return (*this); @@ -62,9 +62,9 @@ BigInt& BigInt::operator-=(const BigInt& y) if(relative_size < 0) { if(sign() == y.sign()) - bigint_sub2_rev(data(), y.data(), y_sw); + bigint_sub2_rev(mutable_data(), y.data(), y_sw); else - bigint_add2(data(), reg_size - 1, y.data(), y_sw); + bigint_add2(mutable_data(), reg_size - 1, y.data(), y_sw); set_sign(y.reverse_sign()); } @@ -76,14 +76,14 @@ BigInt& BigInt::operator-=(const BigInt& y) set_sign(Positive); } else - bigint_shl1(data(), x_sw, 0, 1); + bigint_shl1(mutable_data(), x_sw, 0, 1); } else if(relative_size > 0) { if(sign() == y.sign()) - bigint_sub2(data(), x_sw, y.data(), y_sw); + bigint_sub2(mutable_data(), x_sw, y.data(), y_sw); else - bigint_add2(data(), reg_size - 1, y.data(), y_sw); + bigint_add2(mutable_data(), reg_size - 1, y.data(), y_sw); } return (*this); @@ -105,12 +105,12 @@ BigInt& BigInt::operator*=(const BigInt& y) else if(x_sw == 1 && y_sw) { grow_to(y_sw + 2); - bigint_linmul3(data(), y.data(), y_sw, word_at(0)); + bigint_linmul3(mutable_data(), y.data(), y_sw, word_at(0)); } else if(y_sw == 1 && x_sw) { grow_to(x_sw + 2); - bigint_linmul2(data(), x_sw, y.word_at(0)); + bigint_linmul2(mutable_data(), x_sw, y.word_at(0)); } else { @@ -119,7 +119,7 @@ BigInt& BigInt::operator*=(const BigInt& y) secure_vector<word> z(data(), data() + x_sw); secure_vector<word> workspace(size()); - bigint_mul(data(), size(), &workspace[0], + bigint_mul(mutable_data(), size(), &workspace[0], &z[0], z.size(), x_sw, y.data(), y.size(), y_sw); } @@ -192,7 +192,7 @@ BigInt& BigInt::operator<<=(size_t shift) words = sig_words(); grow_to(words + shift_words + (shift_bits ? 1 : 0)); - bigint_shl1(data(), words, shift_words, shift_bits); + bigint_shl1(mutable_data(), words, shift_words, shift_bits); } return (*this); @@ -208,7 +208,7 @@ BigInt& BigInt::operator>>=(size_t shift) const size_t shift_words = shift / MP_WORD_BITS, shift_bits = shift % MP_WORD_BITS; - bigint_shr1(data(), sig_words(), shift_words, shift_bits); + bigint_shr1(mutable_data(), sig_words(), shift_words, shift_bits); if(is_zero()) set_sign(Positive); diff --git a/src/math/bigint/big_ops3.cpp b/src/math/bigint/big_ops3.cpp index a33b32bb7..acd139716 100644 --- a/src/math/bigint/big_ops3.cpp +++ b/src/math/bigint/big_ops3.cpp @@ -23,20 +23,20 @@ BigInt operator+(const BigInt& x, const BigInt& y) BigInt z(x.sign(), std::max(x_sw, y_sw) + 1); if((x.sign() == y.sign())) - bigint_add3(z.data(), x.data(), x_sw, y.data(), y_sw); + bigint_add3(z.mutable_data(), x.data(), x_sw, y.data(), y_sw); else { s32bit relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw); if(relative_size < 0) { - bigint_sub3(z.data(), y.data(), y_sw, x.data(), x_sw); + bigint_sub3(z.mutable_data(), y.data(), y_sw, x.data(), x_sw); z.set_sign(y.sign()); } else if(relative_size == 0) z.set_sign(BigInt::Positive); else if(relative_size > 0) - bigint_sub3(z.data(), x.data(), x_sw, y.data(), y_sw); + bigint_sub3(z.mutable_data(), x.data(), x_sw, y.data(), y_sw); } return z; @@ -56,22 +56,22 @@ BigInt operator-(const BigInt& x, const BigInt& y) if(relative_size < 0) { if(x.sign() == y.sign()) - bigint_sub3(z.data(), y.data(), y_sw, x.data(), x_sw); + bigint_sub3(z.mutable_data(), y.data(), y_sw, x.data(), x_sw); else - bigint_add3(z.data(), x.data(), x_sw, y.data(), y_sw); + bigint_add3(z.mutable_data(), x.data(), x_sw, y.data(), y_sw); z.set_sign(y.reverse_sign()); } else if(relative_size == 0) { if(x.sign() != y.sign()) - bigint_shl2(z.data(), x.data(), x_sw, 0, 1); + bigint_shl2(z.mutable_data(), x.data(), x_sw, 0, 1); } else if(relative_size > 0) { if(x.sign() == y.sign()) - bigint_sub3(z.data(), x.data(), x_sw, y.data(), y_sw); + bigint_sub3(z.mutable_data(), x.data(), x_sw, y.data(), y_sw); else - bigint_add3(z.data(), x.data(), x_sw, y.data(), y_sw); + bigint_add3(z.mutable_data(), x.data(), x_sw, y.data(), y_sw); z.set_sign(x.sign()); } return z; @@ -87,13 +87,13 @@ BigInt operator*(const BigInt& x, const BigInt& y) BigInt z(BigInt::Positive, x.size() + y.size()); if(x_sw == 1 && y_sw) - bigint_linmul3(z.data(), y.data(), y_sw, x.word_at(0)); + bigint_linmul3(z.mutable_data(), y.data(), y_sw, x.word_at(0)); else if(y_sw == 1 && x_sw) - bigint_linmul3(z.data(), x.data(), x_sw, y.word_at(0)); + bigint_linmul3(z.mutable_data(), x.data(), x_sw, y.word_at(0)); else if(x_sw && y_sw) { secure_vector<word> workspace(z.size()); - bigint_mul(z.data(), z.size(), &workspace[0], + bigint_mul(z.mutable_data(), z.size(), &workspace[0], x.data(), x.size(), x_sw, y.data(), y.size(), y_sw); } @@ -164,7 +164,7 @@ BigInt operator<<(const BigInt& x, size_t shift) const size_t x_sw = x.sig_words(); BigInt y(x.sign(), x_sw + shift_words + (shift_bits ? 1 : 0)); - bigint_shl2(y.data(), x.data(), x_sw, shift_words, shift_bits); + bigint_shl2(y.mutable_data(), x.data(), x_sw, shift_words, shift_bits); return y; } @@ -183,7 +183,7 @@ BigInt operator>>(const BigInt& x, size_t shift) x_sw = x.sig_words(); BigInt y(x.sign(), x_sw - shift_words); - bigint_shr2(y.data(), x.data(), x_sw, shift_words, shift_bits); + bigint_shr2(y.mutable_data(), x.data(), x_sw, shift_words, shift_bits); return y; } diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h index baf2bfc71..f026e67f1 100644 --- a/src/math/bigint/bigint.h +++ b/src/math/bigint/bigint.h @@ -311,16 +311,14 @@ class BOTAN_DLL BigInt size_t bits() const; /** - * Return a pointer to the big integer word register - * @result a pointer to the start of the internal register of - * the integer value + * Return a mutable pointer to the register + * @result a pointer to the start of the internal register */ - word* data() { return &m_reg[0]; } + word* mutable_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 + * Return a const pointer to the register + * @result a pointer to the start of the internal register */ const word* data() const { return &m_reg[0]; } diff --git a/src/math/ec_gfp/point_gfp.cpp b/src/math/ec_gfp/point_gfp.cpp index fd42ccd16..9cd5a2aaf 100644 --- a/src/math/ec_gfp/point_gfp.cpp +++ b/src/math/ec_gfp/point_gfp.cpp @@ -50,8 +50,7 @@ void PointGFp::monty_mult(BigInt& z, const BigInt& x, const BigInt& y) const z.grow_to(output_size); z.clear(); - - bigint_monty_mul(z.data(), output_size, + bigint_monty_mul(z.mutable_data(), output_size, x.data(), x.size(), x.sig_words(), y.data(), y.size(), y.sig_words(), p.data(), p_size, p_dash, @@ -78,7 +77,7 @@ void PointGFp::monty_sqr(BigInt& z, const BigInt& x) const z.grow_to(output_size); z.clear(); - bigint_monty_sqr(z.data(), output_size, + bigint_monty_sqr(z.mutable_data(), output_size, x.data(), x.size(), x.sig_words(), p.data(), p_size, p_dash, &ws[0]); diff --git a/src/math/numbertheory/mp_numth.cpp b/src/math/numbertheory/mp_numth.cpp index b10fe2639..e6826b9dd 100644 --- a/src/math/numbertheory/mp_numth.cpp +++ b/src/math/numbertheory/mp_numth.cpp @@ -22,7 +22,8 @@ BigInt square(const BigInt& x) BigInt z(BigInt::Positive, round_up<size_t>(2*x_sw, 16)); secure_vector<word> workspace(z.size()); - bigint_sqr(z.data(), z.size(), &workspace[0], + bigint_sqr(z.mutable_data(), z.size(), + &workspace[0], x.data(), x.size(), x_sw); return z; } @@ -46,11 +47,13 @@ BigInt mul_add(const BigInt& a, const BigInt& b, const BigInt& c) BigInt r(sign, std::max(a.size() + b.size(), c_sw) + 1); secure_vector<word> workspace(r.size()); - bigint_mul(r.data(), r.size(), &workspace[0], + bigint_mul(r.mutable_data(), r.size(), + &workspace[0], a.data(), a.size(), a_sw, b.data(), b.size(), b_sw); + const size_t r_size = std::max(r.sig_words(), c_sw); - bigint_add2(r.data(), r_size, c.data(), c_sw); + bigint_add2(r.mutable_data(), r_size, c.data(), c_sw); return r; } |