aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-08-01 14:13:49 +0000
committerlloyd <[email protected]>2012-08-01 14:13:49 +0000
commit3f7b562cd6a51cd796f3cb1c0151c45f2b24e2b0 (patch)
tree30efa6741faa24512014e4c08e261e717e4860cb
parentafaac2c3668f0a0fced85649651d3d2ee9101a67 (diff)
Remove BigInt::operator[] returning a mutable word reference
-rw-r--r--src/math/bigint/bigint.h7
-rw-r--r--src/math/bigint/divide.cpp13
-rw-r--r--src/math/numbertheory/powm_mnt.cpp2
3 files changed, 9 insertions, 13 deletions
diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h
index f026e67f1..6efe53e71 100644
--- a/src/math/bigint/bigint.h
+++ b/src/math/bigint/bigint.h
@@ -128,13 +128,6 @@ class BOTAN_DLL BigInt
* @param i a word index
* @return the word at index 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 m_reg[i]; }
/**
diff --git a/src/math/bigint/divide.cpp b/src/math/bigint/divide.cpp
index df72ec3a1..e6d768b1c 100644
--- a/src/math/bigint/divide.cpp
+++ b/src/math/bigint/divide.cpp
@@ -66,6 +66,9 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r)
throw Internal_Error("BigInt division word sizes");
q.grow_to(n - t + 1);
+
+ word* q_words = q.mutable_data();
+
if(n <= t)
{
while(r > y) { r -= y; ++q; }
@@ -76,7 +79,7 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r)
BigInt temp = y << (MP_WORD_BITS * (n-t));
- while(r >= temp) { r -= temp; ++q[n-t]; }
+ while(r >= temp) { r -= temp; q_words[n-t] += 1; }
for(size_t j = n; j != t; --j)
{
@@ -85,19 +88,19 @@ void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r)
const word y_t = y.word_at(t);
if(x_j0 == y_t)
- q[j-t-1] = MP_WORD_MAX;
+ q_words[j-t-1] = MP_WORD_MAX;
else
- q[j-t-1] = bigint_divop(x_j0, x_j1, y_t);
+ q_words[j-t-1] = bigint_divop(x_j0, x_j1, y_t);
while(bigint_divcore(q[j-t-1], y_t, y.word_at(t-1),
x_j0, x_j1, r.word_at(j-2)))
- --q[j-t-1];
+ q_words[j-t-1] -= 1;
r -= (q[j-t-1] * y) << (MP_WORD_BITS * (j-t-1));
if(r.is_negative())
{
r += y << (MP_WORD_BITS * (j-t-1));
- --q[j-t-1];
+ q_words[j-t-1] -= 1;
}
}
r >>= shifts;
diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp
index e565d9368..4ca0083a8 100644
--- a/src/math/numbertheory/powm_mnt.cpp
+++ b/src/math/numbertheory/powm_mnt.cpp
@@ -153,7 +153,7 @@ BigInt Montgomery_Exponentiator::execute() const
x.grow_to(2*m_mod_words + 1);
- bigint_monty_redc(&x[0], x.size(),
+ bigint_monty_redc(x.mutable_data(), x.size(),
m_modulus.data(), m_mod_words, m_mod_prime,
&workspace[0]);