aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorDaniel Seither <[email protected]>2015-06-20 18:27:06 +0200
committerDaniel Seither <[email protected]>2015-06-20 19:05:07 +0200
commitf19604516c0138ffc240388073af2ce0735c48aa (patch)
tree007b800a51542e11dabcc72250d9c5ee2d56d9f2 /src/lib
parentde51fccc5ad04ca734ee91a829298ee06ee948f4 (diff)
lib/math: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/math/bigint/big_code.cpp12
-rw-r--r--src/lib/math/bigint/big_io.cpp2
-rw-r--r--src/lib/math/bigint/big_ops2.cpp6
-rw-r--r--src/lib/math/bigint/big_ops3.cpp2
-rw-r--r--src/lib/math/bigint/big_rand.cpp2
-rw-r--r--src/lib/math/bigint/bigint.h12
-rw-r--r--src/lib/math/ec_gfp/curve_gfp.cpp4
-rw-r--r--src/lib/math/ec_gfp/curve_nistp.cpp10
-rw-r--r--src/lib/math/ec_gfp/point_gfp.h2
-rw-r--r--src/lib/math/numbertheory/dsa_gen.cpp2
-rw-r--r--src/lib/math/numbertheory/mp_numth.cpp4
-rw-r--r--src/lib/math/numbertheory/powm_mnt.cpp12
12 files changed, 35 insertions, 35 deletions
diff --git a/src/lib/math/bigint/big_code.cpp b/src/lib/math/bigint/big_code.cpp
index 17bb0bb54..299fdc246 100644
--- a/src/lib/math/bigint/big_code.cpp
+++ b/src/lib/math/bigint/big_code.cpp
@@ -24,10 +24,10 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
else if(base == Hexadecimal)
{
secure_vector<byte> binary(n.encoded_size(Binary));
- n.binary_encode(&binary[0]);
+ n.binary_encode(binary.data());
hex_encode(reinterpret_cast<char*>(output),
- &binary[0], binary.size());
+ binary.data(), binary.size());
}
else if(base == Decimal)
{
@@ -54,7 +54,7 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
std::vector<byte> BigInt::encode(const BigInt& n, Base base)
{
std::vector<byte> output(n.encoded_size(base));
- encode(&output[0], n, base);
+ encode(output.data(), n, base);
if(base != Binary)
for(size_t j = 0; j != output.size(); ++j)
if(output[j] == 0)
@@ -68,7 +68,7 @@ std::vector<byte> BigInt::encode(const BigInt& n, Base base)
secure_vector<byte> BigInt::encode_locked(const BigInt& n, Base base)
{
secure_vector<byte> output(n.encoded_size(base));
- encode(&output[0], n, base);
+ encode(output.data(), n, base);
if(base != Binary)
for(size_t j = 0; j != output.size(); ++j)
if(output[j] == 0)
@@ -82,7 +82,7 @@ secure_vector<byte> BigInt::encode_locked(const BigInt& n, Base base)
secure_vector<byte> BigInt::encode_1363(const BigInt& n, size_t bytes)
{
secure_vector<byte> output(bytes);
- BigInt::encode_1363(&output[0], output.size(), n);
+ BigInt::encode_1363(output.data(), output.size(), n);
return output;
}
@@ -125,7 +125,7 @@ BigInt BigInt::decode(const byte buf[], size_t length, Base base)
binary = hex_decode_locked(reinterpret_cast<const char*>(buf),
length, false);
- r.binary_decode(&binary[0], binary.size());
+ r.binary_decode(binary.data(), binary.size());
}
else if(base == Decimal)
{
diff --git a/src/lib/math/bigint/big_io.cpp b/src/lib/math/bigint/big_io.cpp
index 9cd0a2cef..3e66f788d 100644
--- a/src/lib/math/bigint/big_io.cpp
+++ b/src/lib/math/bigint/big_io.cpp
@@ -31,7 +31,7 @@ std::ostream& operator<<(std::ostream& stream, const BigInt& n)
size_t skip = 0;
while(skip < buffer.size() && buffer[skip] == '0')
++skip;
- stream.write(reinterpret_cast<const char*>(&buffer[0]) + skip,
+ stream.write(reinterpret_cast<const char*>(buffer.data()) + skip,
buffer.size() - skip);
}
if(!stream.good())
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp
index bd74b8b0d..9a3408247 100644
--- a/src/lib/math/bigint/big_ops2.cpp
+++ b/src/lib/math/bigint/big_ops2.cpp
@@ -31,7 +31,7 @@ BigInt& BigInt::operator+=(const BigInt& y)
if(relative_size < 0)
{
secure_vector<word> z(reg_size - 1);
- bigint_sub3(&z[0], y.data(), reg_size - 1, data(), x_sw);
+ bigint_sub3(z.data(), y.data(), reg_size - 1, data(), x_sw);
std::swap(m_reg, z);
set_sign(y.sign());
}
@@ -119,8 +119,8 @@ BigInt& BigInt::operator*=(const BigInt& y)
secure_vector<word> z(data(), data() + x_sw);
secure_vector<word> workspace(size());
- bigint_mul(mutable_data(), size(), &workspace[0],
- &z[0], z.size(), x_sw,
+ bigint_mul(mutable_data(), size(), workspace.data(),
+ z.data(), z.size(), x_sw,
y.data(), y.size(), y_sw);
}
diff --git a/src/lib/math/bigint/big_ops3.cpp b/src/lib/math/bigint/big_ops3.cpp
index 35633ee27..6cf837020 100644
--- a/src/lib/math/bigint/big_ops3.cpp
+++ b/src/lib/math/bigint/big_ops3.cpp
@@ -93,7 +93,7 @@ BigInt operator*(const BigInt& x, const BigInt& y)
else if(x_sw && y_sw)
{
secure_vector<word> workspace(z.size());
- bigint_mul(z.mutable_data(), z.size(), &workspace[0],
+ bigint_mul(z.mutable_data(), z.size(), workspace.data(),
x.data(), x.size(), x_sw,
y.data(), y.size(), y_sw);
}
diff --git a/src/lib/math/bigint/big_rand.cpp b/src/lib/math/bigint/big_rand.cpp
index 7a843acd5..ab66c6cdd 100644
--- a/src/lib/math/bigint/big_rand.cpp
+++ b/src/lib/math/bigint/big_rand.cpp
@@ -27,7 +27,7 @@ void BigInt::randomize(RandomNumberGenerator& rng,
if(bitsize % 8)
array[0] &= 0xFF >> (8 - (bitsize % 8));
array[0] |= 0x80 >> ((bitsize % 8) ? (8 - bitsize % 8) : 0);
- binary_decode(&array[0], array.size());
+ binary_decode(array.data(), array.size());
}
}
diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h
index ba5d7198f..3f329c451 100644
--- a/src/lib/math/bigint/bigint.h
+++ b/src/lib/math/bigint/bigint.h
@@ -384,7 +384,7 @@ class BOTAN_DLL BigInt
*/
size_t sig_words() const
{
- const word* x = &m_reg[0];
+ const word* x = m_reg.data();
size_t sig = m_reg.size();
while(sig && (x[sig-1] == 0))
@@ -408,13 +408,13 @@ class BOTAN_DLL BigInt
* Return a mutable pointer to the register
* @result a pointer to the start of the internal register
*/
- word* mutable_data() { return &m_reg[0]; }
+ word* mutable_data() { return m_reg.data(); }
/**
* 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]; }
+ const word* data() const { return m_reg.data(); }
secure_vector<word>& get_word_vector() { return m_reg; }
const secure_vector<word>& get_word_vector() const { return m_reg; }
@@ -455,7 +455,7 @@ class BOTAN_DLL BigInt
*/
void binary_decode(const secure_vector<byte>& buf)
{
- binary_decode(&buf[0], buf.size());
+ binary_decode(buf.data(), buf.size());
}
/**
@@ -531,7 +531,7 @@ class BOTAN_DLL BigInt
static BigInt decode(const secure_vector<byte>& buf,
Base base = Binary)
{
- return BigInt::decode(&buf[0], buf.size(), base);
+ return BigInt::decode(buf.data(), buf.size(), base);
}
/**
@@ -543,7 +543,7 @@ class BOTAN_DLL BigInt
static BigInt decode(const std::vector<byte>& buf,
Base base = Binary)
{
- return BigInt::decode(&buf[0], buf.size(), base);
+ return BigInt::decode(buf.data(), buf.size(), base);
}
/**
diff --git a/src/lib/math/ec_gfp/curve_gfp.cpp b/src/lib/math/ec_gfp/curve_gfp.cpp
index cb21dd04e..64d45572d 100644
--- a/src/lib/math/ec_gfp/curve_gfp.cpp
+++ b/src/lib/math/ec_gfp/curve_gfp.cpp
@@ -90,7 +90,7 @@ void CurveGFp_Montgomery::curve_mul(BigInt& z, const BigInt& x, const BigInt& y,
x.data(), x.size(), x.sig_words(),
y.data(), y.size(), y.sig_words(),
m_p.data(), m_p_words, m_p_dash,
- &ws[0]);
+ ws.data());
}
void CurveGFp_Montgomery::curve_sqr(BigInt& z, const BigInt& x,
@@ -112,7 +112,7 @@ void CurveGFp_Montgomery::curve_sqr(BigInt& z, const BigInt& x,
bigint_monty_sqr(z.mutable_data(), output_size,
x.data(), x.size(), x.sig_words(),
m_p.data(), m_p_words, m_p_dash,
- &ws[0]);
+ ws.data());
}
}
diff --git a/src/lib/math/ec_gfp/curve_nistp.cpp b/src/lib/math/ec_gfp/curve_nistp.cpp
index f3ac39aa1..002cf2d47 100644
--- a/src/lib/math/ec_gfp/curve_nistp.cpp
+++ b/src/lib/math/ec_gfp/curve_nistp.cpp
@@ -26,7 +26,7 @@ void CurveGFp_NIST::curve_mul(BigInt& z, const BigInt& x, const BigInt& y,
z.grow_to(output_size);
z.clear();
- bigint_mul(z.mutable_data(), output_size, &ws[0],
+ bigint_mul(z.mutable_data(), output_size, ws.data(),
x.data(), x.size(), x.sig_words(),
y.data(), y.size(), y.sig_words());
@@ -50,7 +50,7 @@ void CurveGFp_NIST::curve_sqr(BigInt& z, const BigInt& x,
z.grow_to(output_size);
z.clear();
- bigint_sqr(z.mutable_data(), output_size, &ws[0],
+ bigint_sqr(z.mutable_data(), output_size, ws.data(),
x.data(), x.size(), x.sig_words());
this->redc(z, ws);
@@ -80,12 +80,12 @@ void CurveGFp_P521::redc(BigInt& x, secure_vector<word>& ws) const
if(ws.size() < p_words + 1)
ws.resize(p_words + 1);
- clear_mem(&ws[0], ws.size());
- bigint_shr2(&ws[0], x.data(), x_sw, shift_words, shift_bits);
+ clear_mem(ws.data(), ws.size());
+ bigint_shr2(ws.data(), x.data(), x_sw, shift_words, shift_bits);
x.mask_bits(521);
- bigint_add3(x.mutable_data(), x.data(), p_words, &ws[0], p_words);
+ bigint_add3(x.mutable_data(), x.data(), p_words, ws.data(), p_words);
normalize(x, ws, max_redc_subtractions());
}
diff --git a/src/lib/math/ec_gfp/point_gfp.h b/src/lib/math/ec_gfp/point_gfp.h
index 8cbb59370..813ead81e 100644
--- a/src/lib/math/ec_gfp/point_gfp.h
+++ b/src/lib/math/ec_gfp/point_gfp.h
@@ -268,7 +268,7 @@ PointGFp BOTAN_DLL OS2ECP(const byte data[], size_t data_len,
template<typename Alloc>
PointGFp OS2ECP(const std::vector<byte, Alloc>& data, const CurveGFp& curve)
- { return OS2ECP(&data[0], data.size(), curve); }
+ { return OS2ECP(data.data(), data.size(), curve); }
}
diff --git a/src/lib/math/numbertheory/dsa_gen.cpp b/src/lib/math/numbertheory/dsa_gen.cpp
index e28873550..bd3c0e4a1 100644
--- a/src/lib/math/numbertheory/dsa_gen.cpp
+++ b/src/lib/math/numbertheory/dsa_gen.cpp
@@ -120,7 +120,7 @@ std::vector<byte> generate_dsa_primes(RandomNumberGenerator& rng,
while(true)
{
std::vector<byte> seed(qbits / 8);
- rng.randomize(&seed[0], seed.size());
+ rng.randomize(seed.data(), seed.size());
if(generate_dsa_primes(rng, p, q, pbits, qbits, seed))
return seed;
diff --git a/src/lib/math/numbertheory/mp_numth.cpp b/src/lib/math/numbertheory/mp_numth.cpp
index 724f0c774..fafc6b03f 100644
--- a/src/lib/math/numbertheory/mp_numth.cpp
+++ b/src/lib/math/numbertheory/mp_numth.cpp
@@ -23,7 +23,7 @@ BigInt square(const BigInt& x)
secure_vector<word> workspace(z.size());
bigint_sqr(z.mutable_data(), z.size(),
- &workspace[0],
+ workspace.data(),
x.data(), x.size(), x_sw);
return z;
}
@@ -48,7 +48,7 @@ BigInt mul_add(const BigInt& a, const BigInt& b, const BigInt& c)
secure_vector<word> workspace(r.size());
bigint_mul(r.mutable_data(), r.size(),
- &workspace[0],
+ workspace.data(),
a.data(), a.size(), a_sw,
b.data(), b.size(), b_sw);
diff --git a/src/lib/math/numbertheory/powm_mnt.cpp b/src/lib/math/numbertheory/powm_mnt.cpp
index 5e797b195..5c441db3a 100644
--- a/src/lib/math/numbertheory/powm_mnt.cpp
+++ b/src/lib/math/numbertheory/powm_mnt.cpp
@@ -38,7 +38,7 @@ void Montgomery_Exponentiator::set_base(const BigInt& base)
m_g[0].data(), m_g[0].size(), m_g[0].sig_words(),
m_R2_mod.data(), m_R2_mod.size(), m_R2_mod.sig_words(),
m_modulus.data(), m_mod_words, m_mod_prime,
- &workspace[0]);
+ workspace.data());
m_g[0] = z;
@@ -48,7 +48,7 @@ void Montgomery_Exponentiator::set_base(const BigInt& base)
m_g[1].data(), m_g[1].size(), m_g[1].sig_words(),
m_R2_mod.data(), m_R2_mod.size(), m_R2_mod.sig_words(),
m_modulus.data(), m_mod_words, m_mod_prime,
- &workspace[0]);
+ workspace.data());
m_g[1] = z;
@@ -64,7 +64,7 @@ void Montgomery_Exponentiator::set_base(const BigInt& base)
x.data(), x.size(), x_sig,
y.data(), y.size(), y_sig,
m_modulus.data(), m_mod_words, m_mod_prime,
- &workspace[0]);
+ workspace.data());
m_g[i] = z;
}
@@ -91,7 +91,7 @@ BigInt Montgomery_Exponentiator::execute() const
bigint_monty_sqr(z.mutable_data(), z_size,
x.data(), x.size(), x.sig_words(),
m_modulus.data(), m_mod_words, m_mod_prime,
- &workspace[0]);
+ workspace.data());
x = z;
}
@@ -104,7 +104,7 @@ BigInt Montgomery_Exponentiator::execute() const
x.data(), x.size(), x.sig_words(),
y.data(), y.size(), y.sig_words(),
m_modulus.data(), m_mod_words, m_mod_prime,
- &workspace[0]);
+ workspace.data());
x = z;
}
@@ -113,7 +113,7 @@ BigInt Montgomery_Exponentiator::execute() const
bigint_monty_redc(x.mutable_data(),
m_modulus.data(), m_mod_words, m_mod_prime,
- &workspace[0]);
+ workspace.data());
return x;
}