aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes/aead/gcm
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/modes/aead/gcm')
-rw-r--r--src/lib/modes/aead/gcm/clmul/clmul.cpp6
-rw-r--r--src/lib/modes/aead/gcm/gcm.cpp34
2 files changed, 20 insertions, 20 deletions
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);