From 105fb962ae525428c2385098abdf20bbf4382353 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 26 Jun 2015 11:30:15 +0200 Subject: lib/base: Convert &vec[0] to vec.data() --- src/lib/base/buf_comp.h | 12 ++++++------ src/lib/base/sym_algo.h | 2 +- src/lib/base/symkey.cpp | 10 +++++----- src/lib/base/symkey.h | 2 +- src/lib/base/transform.h | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib/base/buf_comp.h b/src/lib/base/buf_comp.h index 564da2262..30e30c71c 100644 --- a/src/lib/base/buf_comp.h +++ b/src/lib/base/buf_comp.h @@ -39,7 +39,7 @@ class BOTAN_DLL Buffered_Computation */ void update(const secure_vector& in) { - add_data(&in[0], in.size()); + add_data(in.data(), in.size()); } /** @@ -48,7 +48,7 @@ class BOTAN_DLL Buffered_Computation */ void update(const std::vector& in) { - add_data(&in[0], in.size()); + add_data(in.data(), in.size()); } /** @@ -97,7 +97,7 @@ class BOTAN_DLL Buffered_Computation secure_vector final() { secure_vector output(output_length()); - final_result(&output[0]); + final_result(output.data()); return output; } @@ -105,7 +105,7 @@ class BOTAN_DLL Buffered_Computation void final(std::vector& out) { out.resize(output_length()); - final_result(&out[0]); + final_result(out.data()); } /** @@ -129,7 +129,7 @@ class BOTAN_DLL Buffered_Computation */ secure_vector process(const secure_vector& in) { - add_data(&in[0], in.size()); + add_data(in.data(), in.size()); return final(); } @@ -141,7 +141,7 @@ class BOTAN_DLL Buffered_Computation */ secure_vector process(const std::vector& in) { - add_data(&in[0], in.size()); + add_data(in.data(), in.size()); return final(); } diff --git a/src/lib/base/sym_algo.h b/src/lib/base/sym_algo.h index 7c37b2a47..ee6eb5f4a 100644 --- a/src/lib/base/sym_algo.h +++ b/src/lib/base/sym_algo.h @@ -68,7 +68,7 @@ class BOTAN_DLL SymmetricAlgorithm template void set_key(const std::vector& key) { - set_key(&key[0], key.size()); + set_key(key.data(), key.size()); } /** diff --git a/src/lib/base/symkey.cpp b/src/lib/base/symkey.cpp index 0cb0d9e35..88642747b 100644 --- a/src/lib/base/symkey.cpp +++ b/src/lib/base/symkey.cpp @@ -28,7 +28,7 @@ OctetString::OctetString(RandomNumberGenerator& rng, OctetString::OctetString(const std::string& hex_string) { bits.resize(1 + hex_string.length() / 2); - bits.resize(hex_decode(&bits[0], hex_string)); + bits.resize(hex_decode(bits.data(), hex_string)); } /* @@ -77,7 +77,7 @@ void OctetString::set_odd_parity() */ std::string OctetString::as_string() const { - return hex_encode(&bits[0], bits.size()); + return hex_encode(bits.data(), bits.size()); } /* @@ -86,7 +86,7 @@ std::string OctetString::as_string() const OctetString& OctetString::operator^=(const OctetString& k) { if(&k == this) { zeroise(bits); return (*this); } - xor_buf(&bits[0], k.begin(), std::min(length(), k.length())); + xor_buf(bits.data(), k.begin(), std::min(length(), k.length())); return (*this); } @@ -124,8 +124,8 @@ OctetString operator^(const OctetString& k1, const OctetString& k2) { secure_vector ret(std::max(k1.length(), k2.length())); - copy_mem(&ret[0], k1.begin(), k1.length()); - xor_buf(&ret[0], k2.begin(), k2.length()); + copy_mem(ret.data(), k1.begin(), k1.length()); + xor_buf(ret.data(), k2.begin(), k2.length()); return OctetString(ret); } diff --git a/src/lib/base/symkey.h b/src/lib/base/symkey.h index c837e8ca5..23b7d030b 100644 --- a/src/lib/base/symkey.h +++ b/src/lib/base/symkey.h @@ -33,7 +33,7 @@ class BOTAN_DLL OctetString /** * @return start of this string */ - const byte* begin() const { return &bits[0]; } + const byte* begin() const { return bits.data(); } /** * @return end of this string diff --git a/src/lib/base/transform.h b/src/lib/base/transform.h index 75bd5004a..b5916a3a4 100644 --- a/src/lib/base/transform.h +++ b/src/lib/base/transform.h @@ -33,7 +33,7 @@ class BOTAN_DLL Transform template secure_vector start(const std::vector& nonce) { - return start(&nonce[0], nonce.size()); + return start(nonce.data(), nonce.size()); } /** @@ -44,7 +44,7 @@ class BOTAN_DLL Transform BOTAN_DEPRECATED("Use Transform::start") secure_vector start_vec(const std::vector& nonce) { - return start(&nonce[0], nonce.size()); + return start(nonce.data(), nonce.size()); } /** @@ -147,7 +147,7 @@ class BOTAN_DLL Keyed_Transform : public Transform template void set_key(const std::vector& key) { - set_key(&key[0], key.size()); + set_key(key.data(), key.size()); } void set_key(const SymmetricKey& key) -- cgit v1.2.3