diff options
author | lloyd <[email protected]> | 2010-09-13 12:28:27 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-13 12:28:27 +0000 |
commit | 27d79c87365105d6128afe9eaf8a82383976ed44 (patch) | |
tree | 9a4f0e1d5ae7ecd5c058c0293d9b546191990cdb /src/math | |
parent | 9acfc3a50b31044e48d8dee5fc8030ad7f4518d4 (diff) |
Anywhere where we use MemoryRegion::begin to get access to the raw pointer
representation (rather than in an interator context), instead use &buf[0],
which works for both MemoryRegion and std::vector
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/bigint/big_io.cpp | 2 | ||||
-rw-r--r-- | src/math/bigint/big_ops2.cpp | 2 | ||||
-rw-r--r-- | src/math/bigint/bigint.h | 4 | ||||
-rw-r--r-- | src/math/numbertheory/point_gfp.cpp | 14 | ||||
-rw-r--r-- | src/math/numbertheory/powm_mnt.cpp | 10 |
5 files changed, 16 insertions, 16 deletions
diff --git a/src/math/bigint/big_io.cpp b/src/math/bigint/big_io.cpp index b50fcceff..f3e7fb861 100644 --- a/src/math/bigint/big_io.cpp +++ b/src/math/bigint/big_io.cpp @@ -31,7 +31,7 @@ std::ostream& operator<<(std::ostream& stream, const BigInt& n) u32bit skip = 0; while(buffer[skip] == '0' && skip < buffer.size()) ++skip; - stream.write(reinterpret_cast<const char*>(buffer.begin()) + skip, + stream.write(reinterpret_cast<const char*>(&buffer[0]) + skip, buffer.size() - skip); } if(!stream.good()) diff --git a/src/math/bigint/big_ops2.cpp b/src/math/bigint/big_ops2.cpp index 193c00e32..554fb1793 100644 --- a/src/math/bigint/big_ops2.cpp +++ b/src/math/bigint/big_ops2.cpp @@ -32,7 +32,7 @@ BigInt& BigInt::operator+=(const BigInt& y) { SecureVector<word> z(reg_size - 1); bigint_sub3(z, y.data(), reg_size - 1, data(), x_sw); - copy_mem(get_reg().begin(), z.begin(), z.size()); + copy_mem(®[0], &z[0], z.size()); set_sign(y.sign()); } else if(relative_size == 0) diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h index 9ce71aeca..cd6997698 100644 --- a/src/math/bigint/bigint.h +++ b/src/math/bigint/bigint.h @@ -291,7 +291,7 @@ class BOTAN_DLL BigInt */ u32bit sig_words() const { - const word* x = reg.begin(); + const word* x = ®[0]; u32bit sig = reg.size(); while(sig && (x[sig-1] == 0)) @@ -316,7 +316,7 @@ class BOTAN_DLL BigInt * @result a pointer to the start of the internal register of * the integer value */ - const word* data() const { return reg.begin(); } + const word* data() const { return ®[0]; } /** * return a reference to the internal register containing the value diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp index 93e3392ea..b593443f7 100644 --- a/src/math/numbertheory/point_gfp.cpp +++ b/src/math/numbertheory/point_gfp.cpp @@ -56,7 +56,7 @@ void PointGFp::monty_mult(BigInt& z, p.data(), p_size, p_dash); z.get_reg().resize(p_size); - copy_mem(z.get_reg().begin(), &workspace[p_size], p_size); + copy_mem(&z.get_reg()[0], &workspace[p_size], p_size); } // Montgomery squaring @@ -82,7 +82,7 @@ void PointGFp::monty_sqr(BigInt& z, const BigInt& x, p.data(), p_size, p_dash); z.get_reg().resize(p_size); - copy_mem(z.get_reg().begin(), &workspace[p_size], p_size); + copy_mem(&z.get_reg()[0], &workspace[p_size], p_size); } // Point addition @@ -475,8 +475,8 @@ SecureVector<byte> EC2OSP(const PointGFp& point, byte format) SecureVector<byte> result(2*p_bytes+1); result[0] = 4; - result.copy(1, bX.begin(), p_bytes); - result.copy(p_bytes+1, bY.begin(), p_bytes); + result.copy(1, &bX[0], p_bytes); + result.copy(p_bytes+1, &bY[0], p_bytes); return result; } else if(format == PointGFp::COMPRESSED) @@ -484,7 +484,7 @@ SecureVector<byte> EC2OSP(const PointGFp& point, byte format) SecureVector<byte> result(p_bytes+1); result[0] = 2; - result.copy(1, bX.begin(), bX.size()); + result.copy(1, &bX[0], bX.size()); if(y.get_bit(0)) result[0] |= 1; @@ -496,8 +496,8 @@ SecureVector<byte> EC2OSP(const PointGFp& point, byte format) SecureVector<byte> result(2*p_bytes+1); result[0] = 6; - result.copy(1, bX.begin(), bX.size()); - result.copy(p_bytes+1, bY.begin(), bY.size()); + result.copy(1, &bX[0], bX.size()); + result.copy(p_bytes+1, &bY[0], bY.size()); if(y.get_bit(0)) result[0] |= 1; diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp index 80582eaa8..b565d7a21 100644 --- a/src/math/numbertheory/powm_mnt.cpp +++ b/src/math/numbertheory/powm_mnt.cpp @@ -20,7 +20,7 @@ inline void montgomery_reduce(BigInt& out, MemoryRegion<word>& z_buf, const BigInt& x_bn, u32bit x_size, word u) { const word* x = x_bn.data(); - word* z = z_buf.begin(); + word* z = &z_buf[0]; u32bit z_size = z_buf.size(); bigint_monty_redc(z, z_size, x, x_size, u); @@ -52,7 +52,7 @@ void Montgomery_Exponentiator::set_base(const BigInt& base) SecureVector<word> workspace(z.size()); g[0] = (base >= modulus) ? (base % modulus) : base; - bigint_mul(z.begin(), z.size(), workspace, + bigint_mul(&z[0], z.size(), workspace, g[0].data(), g[0].size(), g[0].sig_words(), R2.data(), R2.size(), R2.sig_words()); @@ -67,7 +67,7 @@ void Montgomery_Exponentiator::set_base(const BigInt& base) const u32bit y_sig = y.sig_words(); zeroise(z); - bigint_mul(z.begin(), z.size(), workspace, + bigint_mul(&z[0], z.size(), workspace, x.data(), x.size(), x_sig, y.data(), y.size(), y_sig); @@ -91,7 +91,7 @@ BigInt Montgomery_Exponentiator::execute() const for(u32bit k = 0; k != window_bits; ++k) { zeroise(z); - bigint_sqr(z.begin(), z.size(), workspace, + bigint_sqr(&z[0], z.size(), workspace, x.data(), x.size(), x.sig_words()); montgomery_reduce(x, z, modulus, mod_words, mod_prime); @@ -103,7 +103,7 @@ BigInt Montgomery_Exponentiator::execute() const const BigInt& y = g[nibble-1]; zeroise(z); - bigint_mul(z.begin(), z.size(), workspace, + bigint_mul(&z[0], z.size(), workspace, x.data(), x.size(), x.sig_words(), y.data(), y.size(), y.sig_words()); |