aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/modes/aead/aead.h4
-rw-r--r--src/lib/modes/aead/ccm/ccm.cpp26
-rw-r--r--src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp12
-rw-r--r--src/lib/modes/aead/eax/eax.cpp12
-rw-r--r--src/lib/modes/aead/gcm/clmul/clmul.cpp6
-rw-r--r--src/lib/modes/aead/gcm/gcm.cpp34
-rw-r--r--src/lib/modes/aead/ocb/ocb.cpp46
-rw-r--r--src/lib/modes/aead/siv/siv.cpp18
-rw-r--r--src/lib/modes/cbc/cbc.cpp28
-rw-r--r--src/lib/modes/cbc/cbc.h2
-rw-r--r--src/lib/modes/cfb/cfb.cpp16
-rw-r--r--src/lib/modes/ecb/ecb.cpp8
-rw-r--r--src/lib/modes/xts/xts.cpp16
-rw-r--r--src/lib/modes/xts/xts.h2
-rw-r--r--src/lib/passhash/bcrypt/bcrypt.cpp8
-rw-r--r--src/lib/passhash/passhash9/passhash9.cpp6
-rw-r--r--src/lib/pbkdf/pbkdf.cpp4
-rw-r--r--src/lib/pbkdf/pbkdf.h4
-rw-r--r--src/lib/pbkdf/pbkdf1/pbkdf1.cpp4
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.cpp12
-rw-r--r--src/lib/pubkey/curve25519/curve25519.cpp2
-rw-r--r--src/lib/pubkey/dlies/dlies.cpp6
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.cpp4
-rw-r--r--src/lib/pubkey/mce/code_based_key_gen.cpp2
-rw-r--r--src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp2
-rw-r--r--src/lib/pubkey/mce/goppa_code.cpp6
-rw-r--r--src/lib/pubkey/mce/mce_kem.cpp6
-rw-r--r--src/lib/pubkey/mce/mce_kem.h2
-rw-r--r--src/lib/pubkey/mce/mceliece.cpp12
-rw-r--r--src/lib/pubkey/mce/mceliece.h18
-rw-r--r--src/lib/pubkey/mce/mceliece_key.cpp6
-rw-r--r--src/lib/pubkey/mceies/mceies.cpp8
-rw-r--r--src/lib/pubkey/pk_ops.cpp6
-rw-r--r--src/lib/pubkey/pubkey.cpp2
-rw-r--r--src/lib/pubkey/pubkey.h22
-rw-r--r--src/lib/pubkey/rfc6979/rfc6979.cpp8
36 files changed, 190 insertions, 190 deletions
diff --git a/src/lib/modes/aead/aead.h b/src/lib/modes/aead/aead.h
index 6bbb39dcb..1fff41f97 100644
--- a/src/lib/modes/aead/aead.h
+++ b/src/lib/modes/aead/aead.h
@@ -41,13 +41,13 @@ class BOTAN_DLL AEAD_Mode : public Cipher_Mode
template<typename Alloc>
void set_associated_data_vec(const std::vector<byte, Alloc>& ad)
{
- set_associated_data(&ad[0], ad.size());
+ set_associated_data(ad.data(), ad.size());
}
template<typename Alloc>
void set_ad(const std::vector<byte, Alloc>& ad)
{
- set_associated_data(&ad[0], ad.size());
+ set_associated_data(ad.data(), ad.size());
}
/**
diff --git a/src/lib/modes/aead/ccm/ccm.cpp b/src/lib/modes/aead/ccm/ccm.cpp
index cc692e364..b40e6e62b 100644
--- a/src/lib/modes/aead/ccm/ccm.cpp
+++ b/src/lib/modes/aead/ccm/ccm.cpp
@@ -106,7 +106,7 @@ void CCM_Mode::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_msg_buf.insert(m_msg_buf.end(), buf, buf + sz);
buffer.resize(offset); // truncate msg
@@ -138,7 +138,7 @@ secure_vector<byte> CCM_Mode::format_b0(size_t sz)
const byte b_flags = (m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1);
B0[0] = b_flags;
- copy_mem(&B0[1], &m_nonce[0], m_nonce.size());
+ copy_mem(&B0[1], m_nonce.data(), m_nonce.size());
encode_length(sz, &B0[m_nonce.size()+1]);
return B0;
@@ -151,7 +151,7 @@ secure_vector<byte> CCM_Mode::format_c0()
const byte a_flags = L()-1;
C[0] = a_flags;
- copy_mem(&C[1], &m_nonce[0], m_nonce.size());
+ copy_mem(&C[1], m_nonce.data(), m_nonce.size());
return C;
}
@@ -163,7 +163,7 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const secure_vector<byte>& ad = ad_buf();
BOTAN_ASSERT(ad.size() % BS == 0, "AD is block size multiple");
@@ -175,7 +175,7 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
for(size_t i = 0; i != ad.size(); i += BS)
{
- xor_buf(&T[0], &ad[i], BS);
+ xor_buf(T.data(), &ad[i], BS);
E.encrypt(T);
}
@@ -192,11 +192,11 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
{
const size_t to_proc = std::min<size_t>(BS, buf_end - buf);
- xor_buf(&T[0], buf, to_proc);
+ xor_buf(T.data(), buf, to_proc);
E.encrypt(T);
E.encrypt(C, X);
- xor_buf(buf, &X[0], to_proc);
+ xor_buf(buf, X.data(), to_proc);
inc(C);
buf += to_proc;
@@ -204,7 +204,7 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
T ^= S0;
- buffer += std::make_pair(&T[0], tag_size());
+ buffer += std::make_pair(T.data(), tag_size());
}
void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
@@ -214,7 +214,7 @@ void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
@@ -228,7 +228,7 @@ void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
for(size_t i = 0; i != ad.size(); i += BS)
{
- xor_buf(&T[0], &ad[i], BS);
+ xor_buf(T.data(), &ad[i], BS);
E.encrypt(T);
}
@@ -247,10 +247,10 @@ void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t to_proc = std::min<size_t>(BS, buf_end - buf);
E.encrypt(C, X);
- xor_buf(buf, &X[0], to_proc);
+ xor_buf(buf, X.data(), to_proc);
inc(C);
- xor_buf(&T[0], buf, to_proc);
+ xor_buf(T.data(), buf, to_proc);
E.encrypt(T);
buf += to_proc;
@@ -258,7 +258,7 @@ void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
T ^= S0;
- if(!same_mem(&T[0], buf_end, tag_size()))
+ if(!same_mem(T.data(), buf_end, tag_size()))
throw Integrity_Failure("CCM tag check failed");
buffer.resize(buffer.size() - tag_size());
diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
index 37e0ef96b..3dc9d7f6d 100644
--- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
+++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
@@ -63,7 +63,7 @@ secure_vector<byte> ChaCha20Poly1305_Mode::start_raw(const byte nonce[], size_t
secure_vector<byte> zeros(64);
m_chacha->encrypt(zeros);
- m_poly1305->set_key(&zeros[0], 32);
+ m_poly1305->set_key(zeros.data(), 32);
// Remainder of output is discard
m_poly1305->update(m_ad);
@@ -85,7 +85,7 @@ void ChaCha20Poly1305_Encryption::update(secure_vector<byte>& buffer, size_t off
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_chacha->cipher1(buf, sz);
m_poly1305->update(buf, sz); // poly1305 of ciphertext
@@ -104,7 +104,7 @@ void ChaCha20Poly1305_Encryption::finish(secure_vector<byte>& buffer, size_t off
update_len(m_ctext_len);
const secure_vector<byte> mac = m_poly1305->final();
- buffer += std::make_pair(&mac[0], tag_size());
+ buffer += std::make_pair(mac.data(), tag_size());
m_ctext_len = 0;
}
@@ -112,7 +112,7 @@ void ChaCha20Poly1305_Decryption::update(secure_vector<byte>& buffer, size_t off
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_poly1305->update(buf, sz); // poly1305 of ciphertext
m_chacha->cipher1(buf, sz);
@@ -123,7 +123,7 @@ void ChaCha20Poly1305_Decryption::finish(secure_vector<byte>& buffer, size_t off
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "Have the tag as part of final input");
@@ -150,7 +150,7 @@ void ChaCha20Poly1305_Decryption::finish(secure_vector<byte>& buffer, size_t off
m_ctext_len = 0;
- if(!same_mem(&mac[0], included_tag, tag_size()))
+ if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("ChaCha20Poly1305 tag check failed");
buffer.resize(offset + remaining);
}
diff --git a/src/lib/modes/aead/eax/eax.cpp b/src/lib/modes/aead/eax/eax.cpp
index 3b0c94416..22e772d75 100644
--- a/src/lib/modes/aead/eax/eax.cpp
+++ b/src/lib/modes/aead/eax/eax.cpp
@@ -100,7 +100,7 @@ secure_vector<byte> EAX_Mode::start_raw(const byte nonce[], size_t nonce_len)
m_nonce_mac = eax_prf(0, block_size(), *m_cmac, nonce, nonce_len);
- m_ctr->set_iv(&m_nonce_mac[0], m_nonce_mac.size());
+ m_ctr->set_iv(m_nonce_mac.data(), m_nonce_mac.size());
for(size_t i = 0; i != block_size() - 1; ++i)
m_cmac->update(0);
@@ -113,7 +113,7 @@ void EAX_Encryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_ctr->cipher(buf, buf, sz);
m_cmac->update(buf, sz);
@@ -127,14 +127,14 @@ void EAX_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
xor_buf(data_mac, m_nonce_mac, data_mac.size());
xor_buf(data_mac, m_ad_mac, data_mac.size());
- buffer += std::make_pair(&data_mac[0], tag_size());
+ buffer += std::make_pair(data_mac.data(), tag_size());
}
void EAX_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_cmac->update(buf, sz);
m_ctr->cipher(buf, buf, sz);
@@ -144,7 +144,7 @@ void EAX_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "Have the tag as part of final input");
@@ -162,7 +162,7 @@ void EAX_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
mac ^= m_nonce_mac;
mac ^= m_ad_mac;
- if(!same_mem(&mac[0], included_tag, tag_size()))
+ if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("EAX tag check failed");
buffer.resize(offset + remaining);
diff --git a/src/lib/modes/aead/gcm/clmul/clmul.cpp b/src/lib/modes/aead/gcm/clmul/clmul.cpp
index 4f7eb8dc0..6e1db7012 100644
--- a/src/lib/modes/aead/gcm/clmul/clmul.cpp
+++ b/src/lib/modes/aead/gcm/clmul/clmul.cpp
@@ -18,8 +18,8 @@ void gcm_multiply_clmul(byte x[16], const byte H[16])
*/
const __m128i BSWAP_MASK = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
- __m128i a = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&x[0]));
- __m128i b = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&H[0]));
+ __m128i a = _mm_loadu_si128(reinterpret_cast<const __m128i*>(x));
+ __m128i b = _mm_loadu_si128(reinterpret_cast<const __m128i*>(H));
a = _mm_shuffle_epi8(a, BSWAP_MASK);
b = _mm_shuffle_epi8(b, BSWAP_MASK);
@@ -71,7 +71,7 @@ void gcm_multiply_clmul(byte x[16], const byte H[16])
T3 = _mm_shuffle_epi8(T3, BSWAP_MASK);
- _mm_storeu_si128(reinterpret_cast<__m128i*>(&x[0]), T3);
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(x), T3);
}
}
diff --git a/src/lib/modes/aead/gcm/gcm.cpp b/src/lib/modes/aead/gcm/gcm.cpp
index 049df4686..130ff6aad 100644
--- a/src/lib/modes/aead/gcm/gcm.cpp
+++ b/src/lib/modes/aead/gcm/gcm.cpp
@@ -22,14 +22,14 @@ void GHASH::gcm_multiply(secure_vector<byte>& x) const
{
#if defined(BOTAN_HAS_GCM_CLMUL)
if(CPUID::has_clmul())
- return gcm_multiply_clmul(&x[0], &m_H[0]);
+ return gcm_multiply_clmul(x.data(), m_H.data());
#endif
static const u64bit R = 0xE100000000000000;
u64bit H[2] = {
- load_be<u64bit>(&m_H[0], 0),
- load_be<u64bit>(&m_H[0], 1)
+ load_be<u64bit>(m_H.data(), 0),
+ load_be<u64bit>(m_H.data(), 1)
};
u64bit Z[2] = { 0, 0 };
@@ -38,7 +38,7 @@ void GHASH::gcm_multiply(secure_vector<byte>& x) const
for(size_t i = 0; i != 2; ++i)
{
- const u64bit X = load_be<u64bit>(&x[0], i);
+ const u64bit X = load_be<u64bit>(x.data(), i);
for(size_t j = 0; j != 64; ++j)
{
@@ -55,7 +55,7 @@ void GHASH::gcm_multiply(secure_vector<byte>& x) const
}
}
- store_be<u64bit>(&x[0], Z[0], Z[1]);
+ store_be<u64bit>(x.data(), Z[0], Z[1]);
}
void GHASH::ghash_update(secure_vector<byte>& ghash,
@@ -71,7 +71,7 @@ void GHASH::ghash_update(secure_vector<byte>& ghash,
{
const size_t to_proc = std::min(length, BS);
- xor_buf(&ghash[0], &input[0], to_proc);
+ xor_buf(ghash.data(), input, to_proc);
gcm_multiply(ghash);
@@ -115,8 +115,8 @@ void GHASH::add_final_block(secure_vector<byte>& hash,
size_t ad_len, size_t text_len)
{
secure_vector<byte> final_block(16);
- store_be<u64bit>(&final_block[0], 8*ad_len, 8*text_len);
- ghash_update(hash, &final_block[0], final_block.size());
+ store_be<u64bit>(final_block.data(), 8*ad_len, 8*text_len);
+ ghash_update(hash, final_block.data(), final_block.size());
}
secure_vector<byte> GHASH::final()
@@ -195,7 +195,7 @@ void GCM_Mode::key_schedule(const byte key[], size_t keylen)
m_ctr->set_key(key, keylen);
const std::vector<byte> zeros(BS);
- m_ctr->set_iv(&zeros[0], zeros.size());
+ m_ctr->set_iv(zeros.data(), zeros.size());
secure_vector<byte> H(BS);
m_ctr->encipher(H);
@@ -216,7 +216,7 @@ secure_vector<byte> GCM_Mode::start_raw(const byte nonce[], size_t nonce_len)
if(nonce_len == 12)
{
- copy_mem(&y0[0], nonce, nonce_len);
+ copy_mem(y0.data(), nonce, nonce_len);
y0[15] = 1;
}
else
@@ -224,12 +224,12 @@ secure_vector<byte> GCM_Mode::start_raw(const byte nonce[], size_t nonce_len)
y0 = m_ghash->nonce_hash(nonce, nonce_len);
}
- m_ctr->set_iv(&y0[0], y0.size());
+ m_ctr->set_iv(y0.data(), y0.size());
secure_vector<byte> m_enc_y0(BS);
m_ctr->encipher(m_enc_y0);
- m_ghash->start(&m_enc_y0[0], m_enc_y0.size());
+ m_ghash->start(m_enc_y0.data(), m_enc_y0.size());
return secure_vector<byte>();
}
@@ -238,7 +238,7 @@ void GCM_Encryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_ctr->cipher(buf, buf, sz);
m_ghash->update(buf, sz);
@@ -248,14 +248,14 @@ void GCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
{
update(buffer, offset);
auto mac = m_ghash->final();
- buffer += std::make_pair(&mac[0], tag_size());
+ buffer += std::make_pair(mac.data(), tag_size());
}
void GCM_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_ghash->update(buf, sz);
m_ctr->cipher(buf, buf, sz);
@@ -265,7 +265,7 @@ void GCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "Have the tag as part of final input");
@@ -282,7 +282,7 @@ void GCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
const byte* included_tag = &buffer[remaining];
- if(!same_mem(&mac[0], included_tag, tag_size()))
+ if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("GCM tag check failed");
buffer.resize(offset + remaining);
diff --git a/src/lib/modes/aead/ocb/ocb.cpp b/src/lib/modes/aead/ocb/ocb.cpp
index 2ba6d3ee6..ee5583bea 100644
--- a/src/lib/modes/aead/ocb/ocb.cpp
+++ b/src/lib/modes/aead/ocb/ocb.cpp
@@ -41,7 +41,7 @@ class L_computer
for(size_t i = 0; i != blocks; ++i)
{ // could be done in parallel
offset ^= get(ctz(block_index + 1 + i));
- copy_mem(&m_offset_buf[BS*i], &offset[0], BS);
+ copy_mem(&m_offset_buf[BS*i], offset.data(), BS);
}
return m_offset_buf;
@@ -91,7 +91,7 @@ secure_vector<byte> ocb_hash(const L_computer& L,
offset ^= L(ctz(i+1));
buf = offset;
- xor_buf(&buf[0], &ad[BS*i], BS);
+ xor_buf(buf.data(), &ad[BS*i], BS);
cipher.encrypt(buf);
@@ -103,7 +103,7 @@ secure_vector<byte> ocb_hash(const L_computer& L,
offset ^= L.star();
buf = offset;
- xor_buf(&buf[0], &ad[BS*ad_blocks], ad_remainder);
+ xor_buf(buf.data(), &ad[BS*ad_blocks], ad_remainder);
buf[ad_len % BS] ^= 0x80;
cipher.encrypt(buf);
@@ -174,7 +174,7 @@ void OCB_Mode::key_schedule(const byte key[], size_t length)
void OCB_Mode::set_associated_data(const byte ad[], size_t ad_len)
{
BOTAN_ASSERT(m_L, "A key was set");
- m_ad_hash = ocb_hash(*m_L, *m_cipher, &ad[0], ad_len);
+ m_ad_hash = ocb_hash(*m_L, *m_cipher, ad, ad_len);
}
secure_vector<byte>
@@ -245,11 +245,11 @@ void OCB_Encryption::encrypt(byte buffer[], size_t blocks)
const auto& offsets = m_L->compute_offsets(m_offset, m_block_index, proc_blocks);
- xor_buf(&m_checksum[0], &buffer[0], proc_bytes);
+ xor_buf(m_checksum.data(), buffer, proc_bytes);
- xor_buf(&buffer[0], &offsets[0], proc_bytes);
- m_cipher->encrypt_n(&buffer[0], &buffer[0], proc_blocks);
- xor_buf(&buffer[0], &offsets[0], proc_bytes);
+ xor_buf(buffer, offsets.data(), proc_bytes);
+ m_cipher->encrypt_n(buffer, buffer, proc_blocks);
+ xor_buf(buffer, offsets.data(), proc_bytes);
buffer += proc_bytes;
blocks -= proc_blocks;
@@ -261,7 +261,7 @@ void OCB_Encryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz % BS() == 0, "Input length is an even number of blocks");
encrypt(buf, sz / BS());
@@ -271,7 +271,7 @@ void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
if(sz)
{
@@ -285,14 +285,14 @@ void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
BOTAN_ASSERT(remainder_bytes < BS(), "Only a partial block left");
byte* remainder = &buf[sz - remainder_bytes];
- xor_buf(&m_checksum[0], &remainder[0], remainder_bytes);
+ xor_buf(m_checksum.data(), remainder, remainder_bytes);
m_checksum[remainder_bytes] ^= 0x80;
m_offset ^= m_L->star(); // Offset_*
secure_vector<byte> zeros(BS());
m_cipher->encrypt(m_offset, zeros);
- xor_buf(&remainder[0], &zeros[0], remainder_bytes);
+ xor_buf(remainder, zeros.data(), remainder_bytes);
}
}
@@ -311,7 +311,7 @@ void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
mac ^= m_ad_hash;
- buffer += std::make_pair(&mac[0], tag_size());
+ buffer += std::make_pair(mac.data(), tag_size());
zeroise(m_checksum);
zeroise(m_offset);
@@ -333,11 +333,11 @@ void OCB_Decryption::decrypt(byte buffer[], size_t blocks)
const auto& offsets = m_L->compute_offsets(m_offset, m_block_index, proc_blocks);
- xor_buf(&buffer[0], &offsets[0], proc_bytes);
- m_cipher->decrypt_n(&buffer[0], &buffer[0], proc_blocks);
- xor_buf(&buffer[0], &offsets[0], proc_bytes);
+ xor_buf(buffer, offsets.data(), proc_bytes);
+ m_cipher->decrypt_n(buffer, buffer, proc_blocks);
+ xor_buf(buffer, offsets.data(), proc_bytes);
- xor_buf(&m_checksum[0], &buffer[0], proc_bytes);
+ xor_buf(m_checksum.data(), buffer, proc_bytes);
buffer += proc_bytes;
blocks -= proc_blocks;
@@ -349,7 +349,7 @@ void OCB_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz % BS() == 0, "Input length is an even number of blocks");
@@ -360,7 +360,7 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
@@ -371,7 +371,7 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t final_full_blocks = remaining / BS();
const size_t final_bytes = remaining - (final_full_blocks * BS());
- decrypt(&buf[0], final_full_blocks);
+ decrypt(buf, final_full_blocks);
if(final_bytes)
{
@@ -384,9 +384,9 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
secure_vector<byte> pad(BS());
m_cipher->encrypt(m_offset, pad); // P_*
- xor_buf(&remainder[0], &pad[0], final_bytes);
+ xor_buf(remainder, pad.data(), final_bytes);
- xor_buf(&m_checksum[0], &remainder[0], final_bytes);
+ xor_buf(m_checksum.data(), remainder, final_bytes);
m_checksum[final_bytes] ^= 0x80;
}
}
@@ -414,7 +414,7 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
// compare mac
const byte* included_tag = &buf[remaining];
- if(!same_mem(&mac[0], included_tag, tag_size()))
+ if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("OCB tag check failed");
// remove tag from end of message
diff --git a/src/lib/modes/aead/siv/siv.cpp b/src/lib/modes/aead/siv/siv.cpp
index c1416e209..5b22216cf 100644
--- a/src/lib/modes/aead/siv/siv.cpp
+++ b/src/lib/modes/aead/siv/siv.cpp
@@ -91,7 +91,7 @@ void SIV_Mode::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
m_msg_buf.insert(m_msg_buf.end(), buf, buf + sz);
buffer.resize(offset); // truncate msg
@@ -118,13 +118,13 @@ secure_vector<byte> SIV_Mode::S2V(const byte* text, size_t text_len)
if(text_len < 16)
{
V = CMAC::poly_double(V);
- xor_buf(&V[0], text, text_len);
+ xor_buf(V.data(), text, text_len);
V[text_len] ^= 0x80;
return m_cmac->process(V);
}
m_cmac->update(text, text_len - 16);
- xor_buf(&V[0], &text[text_len - 16], 16);
+ xor_buf(V.data(), &text[text_len - 16], 16);
m_cmac->update(V);
return m_cmac->final();
@@ -135,7 +135,7 @@ void SIV_Mode::set_ctr_iv(secure_vector<byte> V)
V[8] &= 0x7F;
V[12] &= 0x7F;
- ctr().set_iv(&V[0], V.size());
+ ctr().set_iv(V.data(), V.size());
}
void SIV_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
@@ -144,7 +144,7 @@ void SIV_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
- secure_vector<byte> V = S2V(&buffer[offset], buffer.size() - offset);
+ secure_vector<byte> V = S2V(buffer.data() + offset, buffer.size() - offset);
buffer.insert(buffer.begin() + offset, V.begin(), V.end());
@@ -162,15 +162,15 @@ void SIV_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
- secure_vector<byte> V(&buffer[offset], &buffer[offset + 16]);
+ secure_vector<byte> V(buffer.data() + offset, buffer.data() + offset + 16);
set_ctr_iv(V);
- ctr().cipher(&buffer[offset + V.size()],
- &buffer[offset],
+ ctr().cipher(buffer.data() + offset + V.size(),
+ buffer.data() + offset,
buffer.size() - offset - V.size());
- secure_vector<byte> T = S2V(&buffer[offset], buffer.size() - offset - V.size());
+ secure_vector<byte> T = S2V(buffer.data() + offset, buffer.size() - offset - V.size());
if(T != V)
throw Integrity_Failure("SIV tag check failed");
diff --git a/src/lib/modes/cbc/cbc.cpp b/src/lib/modes/cbc/cbc.cpp
index 7cee72081..27f2bce4a 100644
--- a/src/lib/modes/cbc/cbc.cpp
+++ b/src/lib/modes/cbc/cbc.cpp
@@ -112,7 +112,7 @@ void CBC_Encryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -168,7 +168,7 @@ size_t CTS_Encryption::output_length(size_t input_length) const
void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t sz = buffer.size() - offset;
const size_t BS = cipher().block_size();
@@ -194,8 +194,8 @@ void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer.resize(full_blocks + offset);
update(buffer, offset);
- xor_buf(&last[0], state_ptr(), BS);
- cipher().encrypt(&last[0]);
+ xor_buf(last.data(), state_ptr(), BS);
+ cipher().encrypt(last.data());
for(size_t i = 0; i != final_bytes - BS; ++i)
{
@@ -203,7 +203,7 @@ void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
last[i + BS] ^= last[i];
}
- cipher().encrypt(&last[0]);
+ cipher().encrypt(last.data());
buffer += last;
}
@@ -223,7 +223,7 @@ void CBC_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -234,13 +234,13 @@ void CBC_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
const size_t to_proc = std::min(BS * blocks, m_tempbuf.size());
- cipher().decrypt_n(buf, &m_tempbuf[0], to_proc / BS);
+ cipher().decrypt_n(buf, m_tempbuf.data(), to_proc / BS);
- xor_buf(&m_tempbuf[0], state_ptr(), BS);
+ xor_buf(m_tempbuf.data(), state_ptr(), BS);
xor_buf(&m_tempbuf[BS], buf, to_proc - BS);
copy_mem(state_ptr(), buf + (to_proc - BS), BS);
- copy_mem(buf, &m_tempbuf[0], to_proc);
+ copy_mem(buf, m_tempbuf.data(), to_proc);
buf += to_proc;
blocks -= to_proc / BS;
@@ -277,7 +277,7 @@ void CTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -303,15 +303,15 @@ void CTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer.resize(full_blocks + offset);
update(buffer, offset);
- cipher().decrypt(&last[0]);
+ cipher().decrypt(last.data());
- xor_buf(&last[0], &last[BS], final_bytes - BS);
+ xor_buf(last.data(), &last[BS], final_bytes - BS);
for(size_t i = 0; i != final_bytes - BS; ++i)
std::swap(last[i], last[i + BS]);
- cipher().decrypt(&last[0]);
- xor_buf(&last[0], state_ptr(), BS);
+ cipher().decrypt(last.data());
+ xor_buf(last.data(), state_ptr(), BS);
buffer += last;
}
diff --git a/src/lib/modes/cbc/cbc.h b/src/lib/modes/cbc/cbc.h
index 2de303da9..963e92666 100644
--- a/src/lib/modes/cbc/cbc.h
+++ b/src/lib/modes/cbc/cbc.h
@@ -44,7 +44,7 @@ class BOTAN_DLL CBC_Mode : public Cipher_Mode
secure_vector<byte>& state() { return m_state; }
- byte* state_ptr() { return &m_state[0]; }
+ byte* state_ptr() { return m_state.data(); }
private:
secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override;
diff --git a/src/lib/modes/cfb/cfb.cpp b/src/lib/modes/cfb/cfb.cpp
index c1fd98dfb..7e4048a2b 100644
--- a/src/lib/modes/cfb/cfb.cpp
+++ b/src/lib/modes/cfb/cfb.cpp
@@ -87,7 +87,7 @@ void CFB_Encryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -97,11 +97,11 @@ void CFB_Encryption::update(secure_vector<byte>& buffer, size_t offset)
while(sz)
{
const size_t took = std::min(shift, sz);
- xor_buf(&buf[0], &keystream_buf()[0], took);
+ xor_buf(buf, &keystream_buf()[0], took);
// Assumes feedback-sized block except for last input
- copy_mem(&state[0], &state[shift], BS - shift);
- copy_mem(&state[BS-shift], &buf[0], took);
+ copy_mem(state.data(), &state[shift], BS - shift);
+ copy_mem(&state[BS-shift], buf, took);
cipher().encrypt(state, keystream_buf());
buf += took;
@@ -118,7 +118,7 @@ void CFB_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -130,11 +130,11 @@ void CFB_Decryption::update(secure_vector<byte>& buffer, size_t offset)
const size_t took = std::min(shift, sz);
// first update shift register with ciphertext
- copy_mem(&state[0], &state[shift], BS - shift);
- copy_mem(&state[BS-shift], &buf[0], took);
+ copy_mem(state.data(), &state[shift], BS - shift);
+ copy_mem(&state[BS-shift], buf, took);
// then decrypt
- xor_buf(&buf[0], &keystream_buf()[0], took);
+ xor_buf(buf, &keystream_buf()[0], took);
// then update keystream
cipher().encrypt(state, keystream_buf());
diff --git a/src/lib/modes/ecb/ecb.cpp b/src/lib/modes/ecb/ecb.cpp
index eaab1810d..73a241394 100644
--- a/src/lib/modes/ecb/ecb.cpp
+++ b/src/lib/modes/ecb/ecb.cpp
@@ -90,14 +90,14 @@ void ECB_Encryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
BOTAN_ASSERT(sz % BS == 0, "ECB input is full blocks");
const size_t blocks = sz / BS;
- cipher().encrypt_n(&buf[0], &buf[0], blocks);
+ cipher().encrypt_n(buf, buf, blocks);
}
void ECB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
@@ -131,14 +131,14 @@ void ECB_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
BOTAN_ASSERT(sz % BS == 0, "Input is full blocks");
size_t blocks = sz / BS;
- cipher().decrypt_n(&buf[0], &buf[0], blocks);
+ cipher().decrypt_n(buf, buf, blocks);
}
void ECB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
diff --git a/src/lib/modes/xts/xts.cpp b/src/lib/modes/xts/xts.cpp
index b2b8386bb..cc0e6d54c 100644
--- a/src/lib/modes/xts/xts.cpp
+++ b/src/lib/modes/xts/xts.cpp
@@ -103,7 +103,7 @@ void XTS_Mode::key_schedule(const byte key[], size_t length)
if(length % 2 == 1 || !m_cipher->valid_keylength(key_half))
throw Invalid_Key_Length(name(), length);
- m_cipher->set_key(&key[0], key_half);
+ m_cipher->set_key(key, key_half);
m_tweak_cipher->set_key(&key[key_half], key_half);
}
@@ -112,8 +112,8 @@ secure_vector<byte> XTS_Mode::start_raw(const byte nonce[], size_t nonce_len)
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
- copy_mem(&m_tweak[0], nonce, nonce_len);
- m_tweak_cipher->encrypt(&m_tweak[0]);
+ copy_mem(m_tweak.data(), nonce, nonce_len);
+ m_tweak_cipher->encrypt(m_tweak.data());
update_tweak(0);
@@ -125,7 +125,7 @@ void XTS_Mode::update_tweak(size_t which)
const size_t BS = m_tweak_cipher->block_size();
if(which > 0)
- poly_double(&m_tweak[0], &m_tweak[(which-1)*BS], BS);
+ poly_double(m_tweak.data(), &m_tweak[(which-1)*BS], BS);
const size_t blocks_in_tweak = update_granularity() / BS;
@@ -142,7 +142,7 @@ void XTS_Encryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -171,7 +171,7 @@ void XTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= minimum_final_size(), "Have sufficient final input");
@@ -221,7 +221,7 @@ void XTS_Decryption::update(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
const size_t BS = cipher().block_size();
@@ -250,7 +250,7 @@ void XTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = &buffer[offset];
+ byte* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= minimum_final_size(), "Have sufficient final input");
diff --git a/src/lib/modes/xts/xts.h b/src/lib/modes/xts/xts.h
index 7e0a1f5c4..b0a46144f 100644
--- a/src/lib/modes/xts/xts.h
+++ b/src/lib/modes/xts/xts.h
@@ -35,7 +35,7 @@ class BOTAN_DLL XTS_Mode : public Cipher_Mode
protected:
XTS_Mode(BlockCipher* cipher);
- const byte* tweak() const { return &m_tweak[0]; }
+ const byte* tweak() const { return m_tweak.data(); }
const BlockCipher& cipher() const { return *m_cipher; }
diff --git a/src/lib/passhash/bcrypt/bcrypt.cpp b/src/lib/passhash/bcrypt/bcrypt.cpp
index 218404110..3f6a68352 100644
--- a/src/lib/passhash/bcrypt/bcrypt.cpp
+++ b/src/lib/passhash/bcrypt/bcrypt.cpp
@@ -103,13 +103,13 @@ std::string make_bcrypt(const std::string& pass,
// Include the trailing NULL byte
blowfish.eks_key_schedule(reinterpret_cast<const byte*>(pass.c_str()),
pass.length() + 1,
- &salt[0],
+ salt.data(),
work_factor);
for(size_t i = 0; i != 64; ++i)
- blowfish.encrypt_n(&ctext[0], &ctext[0], 3);
+ blowfish.encrypt_n(ctext.data(), ctext.data(), 3);
- std::string salt_b64 = bcrypt_base64_encode(&salt[0], salt.size());
+ std::string salt_b64 = bcrypt_base64_encode(salt.data(), salt.size());
std::string work_factor_str = std::to_string(work_factor);
if(work_factor_str.length() == 1)
@@ -117,7 +117,7 @@ std::string make_bcrypt(const std::string& pass,
return "$2a$" + work_factor_str +
"$" + salt_b64.substr(0, 22) +
- bcrypt_base64_encode(&ctext[0], ctext.size() - 1);
+ bcrypt_base64_encode(ctext.data(), ctext.size() - 1);
}
}
diff --git a/src/lib/passhash/passhash9/passhash9.cpp b/src/lib/passhash/passhash9/passhash9.cpp
index 3898cdb44..f30684ec6 100644
--- a/src/lib/passhash/passhash9/passhash9.cpp
+++ b/src/lib/passhash/passhash9/passhash9.cpp
@@ -56,7 +56,7 @@ std::string generate_passhash9(const std::string& pass,
PKCS5_PBKDF2 kdf(prf); // takes ownership of pointer
secure_vector<byte> salt(SALT_BYTES);
- rng.randomize(&salt[0], salt.size());
+ rng.randomize(salt.data(), salt.size());
const size_t kdf_iterations = WORK_FACTOR_SCALE * work_factor;
@@ -67,7 +67,7 @@ std::string generate_passhash9(const std::string& pass,
blob += salt;
blob += kdf.derive_key(PASSHASH9_PBKDF_OUTPUT_LEN,
pass,
- &salt[0], salt.size(),
+ salt.data(), salt.size(),
kdf_iterations).bits_of();
return MAGIC_PREFIX + base64_encode(blob);
@@ -123,7 +123,7 @@ bool check_passhash9(const std::string& pass, const std::string& hash)
&bin[ALGID_BYTES + WORKFACTOR_BYTES], SALT_BYTES,
kdf_iterations).bits_of();
- return same_mem(&cmp[0],
+ return same_mem(cmp.data(),
&bin[ALGID_BYTES + WORKFACTOR_BYTES + SALT_BYTES],
PASSHASH9_PBKDF_OUTPUT_LEN);
}
diff --git a/src/lib/pbkdf/pbkdf.cpp b/src/lib/pbkdf/pbkdf.cpp
index 6fbf8ba37..7f0a68a01 100644
--- a/src/lib/pbkdf/pbkdf.cpp
+++ b/src/lib/pbkdf/pbkdf.cpp
@@ -39,7 +39,7 @@ secure_vector<byte> PBKDF::pbkdf_iterations(size_t out_len,
size_t iterations) const
{
secure_vector<byte> out(out_len);
- pbkdf_iterations(&out[0], out_len, passphrase, salt, salt_len, iterations);
+ pbkdf_iterations(out.data(), out_len, passphrase, salt, salt_len, iterations);
return out;
}
@@ -50,7 +50,7 @@ secure_vector<byte> PBKDF::pbkdf_timed(size_t out_len,
size_t& iterations) const
{
secure_vector<byte> out(out_len);
- pbkdf_timed(&out[0], out_len, passphrase, salt, salt_len, msec, iterations);
+ pbkdf_timed(out.data(), out_len, passphrase, salt, salt_len, msec, iterations);
return out;
}
diff --git a/src/lib/pbkdf/pbkdf.h b/src/lib/pbkdf/pbkdf.h
index 3eaa293a1..5f6cd904c 100644
--- a/src/lib/pbkdf/pbkdf.h
+++ b/src/lib/pbkdf/pbkdf.h
@@ -107,7 +107,7 @@ class BOTAN_DLL PBKDF
const std::vector<byte, Alloc>& salt,
size_t iterations) const
{
- return pbkdf_iterations(out_len, passphrase, &salt[0], salt.size(), iterations);
+ return pbkdf_iterations(out_len, passphrase, salt.data(), salt.size(), iterations);
}
/**
@@ -143,7 +143,7 @@ class BOTAN_DLL PBKDF
std::chrono::milliseconds msec,
size_t& iterations) const
{
- return pbkdf_timed(out_len, passphrase, &salt[0], salt.size(), msec, iterations);
+ return pbkdf_timed(out_len, passphrase, salt.data(), salt.size(), msec, iterations);
}
};
diff --git a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
index 8134b39c4..a2b5957a0 100644
--- a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
+++ b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp
@@ -45,12 +45,12 @@ size_t PKCS5_PBKDF1::pbkdf(byte output_buf[], size_t output_len,
break;
m_hash->update(key);
- m_hash->final(&key[0]);
+ m_hash->final(key.data());
++iterations_performed;
}
- copy_mem(output_buf, &key[0], output_len);
+ copy_mem(output_buf, key.data(), output_len);
return iterations_performed;
}
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
index ab3735bac..a27b9b15c 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
@@ -66,9 +66,9 @@ pbkdf2(MessageAuthenticationCode& prf,
prf.update(salt, salt_len);
prf.update_be(counter++);
- prf.final(&U[0]);
+ prf.final(U.data());
- xor_buf(out, &U[0], prf_output);
+ xor_buf(out, U.data(), prf_output);
if(iterations == 0)
{
@@ -84,8 +84,8 @@ pbkdf2(MessageAuthenticationCode& prf,
while(true)
{
prf.update(U);
- prf.final(&U[0]);
- xor_buf(out, &U[0], prf_output);
+ prf.final(U.data());
+ xor_buf(out, U.data(), prf_output);
iterations++;
/*
@@ -107,8 +107,8 @@ pbkdf2(MessageAuthenticationCode& prf,
for(size_t i = 1; i != iterations; ++i)
{
prf.update(U);
- prf.final(&U[0]);
- xor_buf(out, &U[0], prf_output);
+ prf.final(U.data());
+ xor_buf(out, U.data(), prf_output);
}
}
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp
index d6934748b..b314e16dc 100644
--- a/src/lib/pubkey/curve25519/curve25519.cpp
+++ b/src/lib/pubkey/curve25519/curve25519.cpp
@@ -24,7 +24,7 @@ secure_vector<byte> curve25519(const secure_vector<byte>& secret,
const byte pubval[32])
{
secure_vector<byte> out(32);
- const int rc = curve25519_donna(&out[0], &secret[0], &pubval[0]);
+ const int rc = curve25519_donna(out.data(), secret.data(), pubval);
BOTAN_ASSERT_EQUAL(rc, 0, "Return value of curve25519_donna is ok");
return out;
}
diff --git a/src/lib/pubkey/dlies/dlies.cpp b/src/lib/pubkey/dlies/dlies.cpp
index 899ee98aa..4b1a63f2c 100644
--- a/src/lib/pubkey/dlies/dlies.cpp
+++ b/src/lib/pubkey/dlies/dlies.cpp
@@ -50,7 +50,7 @@ std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
byte* C = &out[my_key.size()];
- mac->set_key(&K[0], mac_keylen);
+ mac->set_key(K.data(), mac_keylen);
xor_buf(C, &K[mac_keylen], length);
mac->update(C, length);
@@ -118,7 +118,7 @@ secure_vector<byte> DLIES_Decryptor::dec(const byte msg[], size_t length) const
if(K.size() != K_LENGTH)
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
- mac->set_key(&K[0], mac_keylen);
+ mac->set_key(K.data(), mac_keylen);
mac->update(C);
for(size_t j = 0; j != 8; ++j)
mac->update(0);
@@ -126,7 +126,7 @@ secure_vector<byte> DLIES_Decryptor::dec(const byte msg[], size_t length) const
if(T != T2)
throw Decoding_Error("DLIES: message authentication failed");
- xor_buf(C, &K[0] + mac_keylen, C.size());
+ xor_buf(C, K.data() + mac_keylen, C.size());
return C;
}
diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp
index 8eb711617..3950c0e43 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.cpp
+++ b/src/lib/pubkey/gost_3410/gost_3410.cpp
@@ -70,7 +70,7 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
std::swap(bits[part_size+i], bits[2*part_size-1-i]);
}
- BigInt x(&bits[0], part_size);
+ BigInt x(bits.data(), part_size);
BigInt y(&bits[part_size], part_size);
public_key = PointGFp(domain().get_curve(), x, y);
@@ -88,7 +88,7 @@ BigInt decode_le(const byte msg[], size_t msg_len)
for(size_t i = 0; i != msg_le.size() / 2; ++i)
std::swap(msg_le[i], msg_le[msg_le.size()-1-i]);
- return BigInt(&msg_le[0], msg_le.size());
+ return BigInt(msg_le.data(), msg_le.size());
}
/**
diff --git a/src/lib/pubkey/mce/code_based_key_gen.cpp b/src/lib/pubkey/mce/code_based_key_gen.cpp
index 150f9b2ee..7adf85112 100644
--- a/src/lib/pubkey/mce/code_based_key_gen.cpp
+++ b/src/lib/pubkey/mce/code_based_key_gen.cpp
@@ -149,7 +149,7 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit e
//
//
std::vector<u32bit> H(bit_size_to_32bit_size(codimension) * code_length );
- u32bit* sk = &H[0];
+ u32bit* sk = H.data();
for (i = 0; i < code_length; ++i)
{
for (l = 0; l < t; ++l)
diff --git a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
index 85da0ec1d..2d4f06130 100644
--- a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
+++ b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
@@ -312,7 +312,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
}while(1);
// side channel / fault attack countermeasure:
- root_pos = patch_root_array(&result[0], result.size(), root_pos);
+ root_pos = patch_root_array(result.data(), result.size(), root_pos);
result.resize(root_pos);
return result;
}
diff --git a/src/lib/pubkey/mce/goppa_code.cpp b/src/lib/pubkey/mce/goppa_code.cpp
index 6f4b40226..175508eac 100644
--- a/src/lib/pubkey/mce/goppa_code.cpp
+++ b/src/lib/pubkey/mce/goppa_code.cpp
@@ -161,14 +161,14 @@ secure_vector<byte> mceliece_decrypt(
key.get_code_length(),
bit_size_to_32bit_size(codimension),
ciphertext,
- &syndrome_vec[0], syndrome_vec.size() );
+ syndrome_vec.data(), syndrome_vec.size() );
secure_vector<byte> syndrome_byte_vec(bit_size_to_byte_size(codimension));
u32bit syndrome_byte_vec_size = syndrome_byte_vec.size();
for(u32bit i = 0; i < syndrome_byte_vec_size; i++)
{
syndrome_byte_vec[i] = syndrome_vec[i/4] >> (8* (i % 4));
}
- syndrome_polyn = polyn_gf2m( t-1, &syndrome_byte_vec[0],bit_size_to_byte_size(codimension), key.get_goppa_polyn().get_sp_field());
+ syndrome_polyn = polyn_gf2m(t-1, syndrome_byte_vec.data(), bit_size_to_byte_size(codimension), key.get_goppa_polyn().get_sp_field());
@@ -179,7 +179,7 @@ secure_vector<byte> mceliece_decrypt(
secure_vector<byte> cleartext(cleartext_len);
- copy_mem(&cleartext[0], ciphertext, cleartext_len);
+ copy_mem(cleartext.data(), ciphertext, cleartext_len);
for(u32bit i = 0; i < nb_err; i++)
{
diff --git a/src/lib/pubkey/mce/mce_kem.cpp b/src/lib/pubkey/mce/mce_kem.cpp
index dd4af4acc..b24c42f85 100644
--- a/src/lib/pubkey/mce/mce_kem.cpp
+++ b/src/lib/pubkey/mce/mce_kem.cpp
@@ -21,7 +21,7 @@ McEliece_KEM_Encryptor::encrypt(RandomNumberGenerator& rng)
{
const McEliece_PublicKey& key = m_raw_pub_op.get_key();
secure_vector<Botan::byte> plaintext((key.get_message_word_bit_length()+7)/8);
- rng.randomize(&plaintext[0], plaintext.size() );
+ rng.randomize(plaintext.data(), plaintext.size());
// unset unused bits in the last plaintext byte
u32bit used = key.get_message_word_bit_length() % 8;
@@ -39,7 +39,7 @@ McEliece_KEM_Encryptor::encrypt(RandomNumberGenerator& rng)
SHA_512 hash;
hash.update(message_and_error_input);
secure_vector<byte> sym_key = hash.final();
- secure_vector<byte> ciphertext = m_raw_pub_op.encrypt(&message_and_error_input[0],
+ secure_vector<byte> ciphertext = m_raw_pub_op.encrypt(message_and_error_input.data(),
message_and_error_input.size(), rng);
return std::make_pair(ciphertext, sym_key);
@@ -53,7 +53,7 @@ McEliece_KEM_Decryptor::McEliece_KEM_Decryptor(const McEliece_PrivateKey& mce_ke
secure_vector<Botan::byte> McEliece_KEM_Decryptor::decrypt(const byte msg[], size_t msg_len)
{
- secure_vector<Botan::byte> message_and_error = m_raw_priv_op.decrypt(&msg[0], msg_len );
+ secure_vector<Botan::byte> message_and_error = m_raw_priv_op.decrypt(msg, msg_len);
SHA_512 hash;
hash.update(message_and_error);
diff --git a/src/lib/pubkey/mce/mce_kem.h b/src/lib/pubkey/mce/mce_kem.h
index cbb2fc553..7a8d2f7ff 100644
--- a/src/lib/pubkey/mce/mce_kem.h
+++ b/src/lib/pubkey/mce/mce_kem.h
@@ -44,7 +44,7 @@ class BOTAN_DLL McEliece_KEM_Decryptor
template<typename Alloc>
secure_vector<Botan::byte> decrypt_vec(const std::vector<byte, Alloc>& v)
{
- return decrypt(&v[0], v.size());
+ return decrypt(v.data(), v.size());
}
private:
diff --git a/src/lib/pubkey/mce/mceliece.cpp b/src/lib/pubkey/mce/mceliece.cpp
index ed4d24467..6bbe93ce3 100644
--- a/src/lib/pubkey/mce/mceliece.cpp
+++ b/src/lib/pubkey/mce/mceliece.cpp
@@ -60,7 +60,7 @@ std::vector<byte> mult_by_pubkey(const byte *cleartext,
u32bit dimension = code_length - codimension;
std::vector<byte> cR(bit_size_to_32bit_size(codimension)* sizeof(u32bit));
- const byte* pt = &public_matrix[0];
+ const byte* pt = public_matrix.data();
for(i = 0; i < dimension / 8; ++i)
{
@@ -68,7 +68,7 @@ std::vector<byte> mult_by_pubkey(const byte *cleartext,
{
if(cleartext[i] & (1 << j))
{
- xor_buf(&cR[0], pt, cR.size());
+ xor_buf(cR.data(), pt, cR.size());
}
pt += bit_size_to_32bit_size(codimension) * sizeof(u32bit);
}
@@ -78,12 +78,12 @@ std::vector<byte> mult_by_pubkey(const byte *cleartext,
{
if(cleartext[i] & (1 << j))
{
- xor_buf(&cR[0], pt, bit_size_to_byte_size(codimension));
+ xor_buf(cR.data(), pt, bit_size_to_byte_size(codimension));
}
pt += bit_size_to_32bit_size(codimension) * sizeof(u32bit);
}
- concat_vectors( &ciphertext[0], cleartext, &cR[0], dimension, codimension);
+ concat_vectors(ciphertext.data(), cleartext, cR.data(), dimension, codimension);
return ciphertext;
}
@@ -150,7 +150,7 @@ secure_vector<byte> McEliece_Public_Operation::encrypt(const byte msg[], size_t
std::vector<byte> ciphertext_tmp = mceliece_encrypt( message_word, m_pub_key.get_public_matrix(), err_pos, m_code_length);
- copy_mem(&ciphertext[0], &ciphertext_tmp[0], ciphertext.size());
+ copy_mem(ciphertext.data(), ciphertext_tmp.data(), ciphertext.size());
return ciphertext;
}
@@ -159,7 +159,7 @@ std::vector<byte> mceliece_encrypt(const secure_vector<byte> & cleartext,
const secure_vector<gf2m> & err_pos,
u32bit code_length)
{
- std::vector<byte> ciphertext = mult_by_pubkey(&cleartext[0], public_matrix, code_length, err_pos.size());
+ std::vector<byte> ciphertext = mult_by_pubkey(cleartext.data(), public_matrix, code_length, err_pos.size());
// flip t error positions
for(size_t i = 0; i < err_pos.size(); ++i)
diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h
index 19de27d8e..b62afee3a 100644
--- a/src/lib/pubkey/mce/mceliece.h
+++ b/src/lib/pubkey/mce/mceliece.h
@@ -30,15 +30,15 @@ class mceliece_message_parts
public:
mceliece_message_parts(const secure_vector<gf2m>& err_pos, const byte* message, u32bit message_length, u32bit code_length) :
- m_error_vector(error_vector_from_error_positions(&err_pos[0], err_pos.size(), code_length)),
+ m_error_vector(error_vector_from_error_positions(err_pos.data(), err_pos.size(), code_length)),
m_code_length(code_length)
{
m_message_word.resize(message_length);
- copy_mem(&m_message_word[0], message, message_length);
+ copy_mem(m_message_word.data(), message, message_length);
}
mceliece_message_parts(const secure_vector<gf2m>& err_pos, const secure_vector<byte>& message, unsigned code_length) :
- m_error_vector(error_vector_from_error_positions(&err_pos[0], err_pos.size(), code_length)),
+ m_error_vector(error_vector_from_error_positions(err_pos.data(), err_pos.size(), code_length)),
m_message_word(message),
m_code_length(code_length)
{}
@@ -68,17 +68,17 @@ class mceliece_message_parts
throw Invalid_Argument("cannot split McEliece message parts");
}
size_t err_vec_start_pos = message_concat_errors_len - err_vec_len;
- m_message_word = secure_vector<byte>(err_vec_start_pos );
- copy_mem(&m_message_word[0], &message_concat_errors[0], err_vec_start_pos);
- m_error_vector = secure_vector<byte>(err_vec_len );
- copy_mem(&m_error_vector[0], &message_concat_errors[err_vec_start_pos], err_vec_len);
+ m_message_word = secure_vector<byte>(err_vec_start_pos);
+ copy_mem(m_message_word.data(), message_concat_errors, err_vec_start_pos);
+ m_error_vector = secure_vector<byte>(err_vec_len);
+ copy_mem(m_error_vector.data(), &message_concat_errors[err_vec_start_pos], err_vec_len);
}
secure_vector<byte> get_concat() const
{
secure_vector<byte> result(m_error_vector.size() + m_message_word.size());
- copy_mem(&result[0], &m_message_word[0], m_message_word.size());
- copy_mem(&result[m_message_word.size()], &m_error_vector[0], m_error_vector.size());
+ copy_mem(result.data(), m_message_word.data(), m_message_word.size());
+ copy_mem(&result[m_message_word.size()], m_error_vector.data(), m_error_vector.size());
return result;
}
diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp
index e0f8b4cd6..41392f695 100644
--- a/src/lib/pubkey/mce/mceliece_key.cpp
+++ b/src/lib/pubkey/mce/mceliece_key.cpp
@@ -139,13 +139,13 @@ bool McEliece_PrivateKey::check_key(RandomNumberGenerator& rng, bool) const
McEliece_Public_Operation pub_op(*this, get_code_length());
secure_vector<byte> plaintext((this->get_message_word_bit_length()+7)/8);
- rng.randomize(&plaintext[0], plaintext.size() - 1);
+ rng.randomize(plaintext.data(), plaintext.size() - 1);
const secure_vector<gf2m> err_pos = create_random_error_positions(this->get_code_length(), this->get_t(), rng);
mceliece_message_parts parts(err_pos, plaintext, this->get_code_length());
secure_vector<byte> message_and_error_input = parts.get_concat();
- secure_vector<byte> ciphertext = pub_op.encrypt(&message_and_error_input[0], message_and_error_input.size(), rng);
- secure_vector<byte> message_and_error_output = priv_op.decrypt(&ciphertext[0], ciphertext.size());
+ secure_vector<byte> ciphertext = pub_op.encrypt(message_and_error_input.data(), message_and_error_input.size(), rng);
+ secure_vector<byte> message_and_error_output = priv_op.decrypt(ciphertext.data(), ciphertext.size());
return (message_and_error_input == message_and_error_output);
}
diff --git a/src/lib/pubkey/mceies/mceies.cpp b/src/lib/pubkey/mceies/mceies.cpp
index 3fec1fd48..6b013c250 100644
--- a/src/lib/pubkey/mceies/mceies.cpp
+++ b/src/lib/pubkey/mceies/mceies.cpp
@@ -57,9 +57,9 @@ mceies_encrypt(const McEliece_PublicKey& pubkey,
const secure_vector<byte> nonce = rng.random_vec(nonce_len);
secure_vector<byte> msg(mce_ciphertext.size() + nonce.size() + pt.size());
- copy_mem(&msg[0], &mce_ciphertext[0], mce_ciphertext.size());
- copy_mem(&msg[mce_ciphertext.size()], &nonce[0], nonce.size());
- copy_mem(&msg[mce_ciphertext.size() + nonce.size()], &pt[0], pt.size());
+ copy_mem(msg.data(), mce_ciphertext.data(), mce_ciphertext.size());
+ copy_mem(&msg[mce_ciphertext.size()], nonce.data(), nonce.size());
+ copy_mem(&msg[mce_ciphertext.size() + nonce.size()], pt.data(), pt.size());
aead->start(nonce);
aead->finish(msg, mce_ciphertext.size() + nonce.size());
@@ -86,7 +86,7 @@ mceies_decrypt(const McEliece_PrivateKey& privkey,
if(ct.size() < mce_code_bytes + nonce_len + aead->tag_size())
throw std::runtime_error("Input message too small to be valid");
- const secure_vector<byte> mce_key = kem_op.decrypt(&ct[0], mce_code_bytes);
+ const secure_vector<byte> mce_key = kem_op.decrypt(ct.data(), mce_code_bytes);
aead->set_key(aead_key(mce_key, *aead));
aead->set_associated_data(ad, ad_len);
diff --git a/src/lib/pubkey/pk_ops.cpp b/src/lib/pubkey/pk_ops.cpp
index f78861b9f..9f264af12 100644
--- a/src/lib/pubkey/pk_ops.cpp
+++ b/src/lib/pubkey/pk_ops.cpp
@@ -37,7 +37,7 @@ secure_vector<byte> PK_Ops::Encryption_with_EME::encrypt(const byte msg[], size_
if(8*(encoded.size() - 1) + high_bit(encoded[0]) > max_raw)
throw std::runtime_error("Input is too large to encrypt with this key");
- return raw_encrypt(&encoded[0], encoded.size(), rng);
+ return raw_encrypt(encoded.data(), encoded.size(), rng);
}
PK_Ops::Decryption_with_EME::Decryption_with_EME(const std::string& eme)
@@ -95,7 +95,7 @@ secure_vector<byte> PK_Ops::Signature_with_EMSA::sign(RandomNumberGenerator& rng
{
const secure_vector<byte> msg = m_emsa->raw_data();
const auto padded = m_emsa->encoding_of(msg, this->max_input_bits(), rng);
- return raw_sign(&padded[0], padded.size(), rng);
+ return raw_sign(padded.data(), padded.size(), rng);
}
PK_Ops::Verification_with_EMSA::Verification_with_EMSA(const std::string& emsa)
@@ -125,7 +125,7 @@ bool PK_Ops::Verification_with_EMSA::is_valid_signature(const byte sig[], size_t
{
Null_RNG rng;
secure_vector<byte> encoded = m_emsa->encoding_of(msg, max_input_bits(), rng);
- return verify(&encoded[0], encoded.size(), sig, sig_len);
+ return verify(encoded.data(), encoded.size(), sig, sig_len);
}
}
diff --git a/src/lib/pubkey/pubkey.cpp b/src/lib/pubkey/pubkey.cpp
index 685cccfc1..74b6a2053 100644
--- a/src/lib/pubkey/pubkey.cpp
+++ b/src/lib/pubkey/pubkey.cpp
@@ -173,7 +173,7 @@ bool PK_Verifier::check_signature(const byte sig[], size_t length)
m_op->message_part_size(),
m_op->message_parts());
- return m_op->is_valid_signature(&real_sig[0], real_sig.size());
+ return m_op->is_valid_signature(real_sig.data(), real_sig.size());
}
else
throw Decoding_Error("PK_Verifier: Unknown signature format " +
diff --git a/src/lib/pubkey/pubkey.h b/src/lib/pubkey/pubkey.h
index 54c55c597..c95ed4469 100644
--- a/src/lib/pubkey/pubkey.h
+++ b/src/lib/pubkey/pubkey.h
@@ -53,7 +53,7 @@ class BOTAN_DLL PK_Encryptor
std::vector<byte> encrypt(const std::vector<byte, Alloc>& in,
RandomNumberGenerator& rng) const
{
- return enc(&in[0], in.size(), rng);
+ return enc(in.data(), in.size(), rng);
}
/**
@@ -99,7 +99,7 @@ class BOTAN_DLL PK_Decryptor
template<typename Alloc>
secure_vector<byte> decrypt(const std::vector<byte, Alloc>& in) const
{
- return dec(&in[0], in.size());
+ return dec(in.data(), in.size());
}
PK_Decryptor() {}
@@ -142,11 +142,11 @@ class BOTAN_DLL PK_Signer
*/
std::vector<byte> sign_message(const std::vector<byte>& in,
RandomNumberGenerator& rng)
- { return sign_message(&in[0], in.size(), rng); }
+ { return sign_message(in.data(), in.size(), rng); }
std::vector<byte> sign_message(const secure_vector<byte>& in,
RandomNumberGenerator& rng)
- { return sign_message(&in[0], in.size(), rng); }
+ { return sign_message(in.data(), in.size(), rng); }
/**
* Add a message part (single byte).
@@ -165,7 +165,7 @@ class BOTAN_DLL PK_Signer
* Add a message part.
* @param in the message part to add
*/
- void update(const std::vector<byte>& in) { update(&in[0], in.size()); }
+ void update(const std::vector<byte>& in) { update(in.data(), in.size()); }
/**
* Get the signature of the so far processed message (provided by the
@@ -224,8 +224,8 @@ class BOTAN_DLL PK_Verifier
bool verify_message(const std::vector<byte, Alloc>& msg,
const std::vector<byte, Alloc2>& sig)
{
- return verify_message(&msg[0], msg.size(),
- &sig[0], sig.size());
+ return verify_message(msg.data(), msg.size(),
+ sig.data(), sig.size());
}
/**
@@ -249,7 +249,7 @@ class BOTAN_DLL PK_Verifier
* @param in the new message part
*/
void update(const std::vector<byte>& in)
- { update(&in[0], in.size()); }
+ { update(in.data(), in.size()); }
/**
* Check the signature of the buffered message, i.e. the one build
@@ -269,7 +269,7 @@ class BOTAN_DLL PK_Verifier
template<typename Alloc>
bool check_signature(const std::vector<byte, Alloc>& sig)
{
- return check_signature(&sig[0], sig.size());
+ return check_signature(sig.data(), sig.size());
}
/**
@@ -326,7 +326,7 @@ class BOTAN_DLL PK_Key_Agreement
const byte params[],
size_t params_len) const
{
- return derive_key(key_len, &in[0], in.size(),
+ return derive_key(key_len, in.data(), in.size(),
params, params_len);
}
@@ -356,7 +356,7 @@ class BOTAN_DLL PK_Key_Agreement
const std::vector<byte>& in,
const std::string& params = "") const
{
- return derive_key(key_len, &in[0], in.size(),
+ return derive_key(key_len, in.data(), in.size(),
reinterpret_cast<const byte*>(params.data()),
params.length());
}
diff --git a/src/lib/pubkey/rfc6979/rfc6979.cpp b/src/lib/pubkey/rfc6979/rfc6979.cpp
index 58cdbaa1b..5f606891d 100644
--- a/src/lib/pubkey/rfc6979/rfc6979.cpp
+++ b/src/lib/pubkey/rfc6979/rfc6979.cpp
@@ -35,19 +35,19 @@ RFC6979_Nonce_Generator::RFC6979_Nonce_Generator(const std::string& hash,
m_rng_in(m_rlen * 2),
m_rng_out(m_rlen)
{
- BigInt::encode_1363(&m_rng_in[0], m_rlen, x);
+ BigInt::encode_1363(m_rng_in.data(), m_rlen, x);
}
const BigInt& RFC6979_Nonce_Generator::nonce_for(const BigInt& m)
{
BigInt::encode_1363(&m_rng_in[m_rlen], m_rlen, m);
m_hmac_drbg->clear();
- m_hmac_drbg->add_entropy(&m_rng_in[0], m_rng_in.size());
+ m_hmac_drbg->add_entropy(m_rng_in.data(), m_rng_in.size());
do
{
- m_hmac_drbg->randomize(&m_rng_out[0], m_rng_out.size());
- m_k.binary_decode(&m_rng_out[0], m_rng_out.size());
+ m_hmac_drbg->randomize(m_rng_out.data(), m_rng_out.size());
+ m_k.binary_decode(m_rng_out.data(), m_rng_out.size());
m_k >>= (8*m_rlen - m_qlen);
}
while(m_k == 0 || m_k >= m_order);