aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes/aead
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/modes/aead')
-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
8 files changed, 79 insertions, 79 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");