aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/bigint
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-08-01 13:46:46 +0000
committerlloyd <[email protected]>2012-08-01 13:46:46 +0000
commitafaac2c3668f0a0fced85649651d3d2ee9101a67 (patch)
tree8e012510e22065832af086b3c70973fe0820c988 /src/math/bigint
parent943c647e7d049a9b00261bbf34aa1443bca0ab02 (diff)
Rename the version of BigInt::data returning a mutable pointer
to BigInt::mutable_data. Update callers.
Diffstat (limited to 'src/math/bigint')
-rw-r--r--src/math/bigint/big_ops2.cpp24
-rw-r--r--src/math/bigint/big_ops3.cpp26
-rw-r--r--src/math/bigint/bigint.h12
3 files changed, 30 insertions, 32 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]; }