diff options
author | Simon Warta <[email protected]> | 2015-06-23 21:07:00 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-06-24 12:22:07 +0200 |
commit | b6c79e70b16e862a7ffd3b54e980263548c1d251 (patch) | |
tree | 98cb253307a7096c5466bc2e2b6c471cffd08e49 /src/lib/modes/aead/gcm/gcm.cpp | |
parent | d4811ce2ea1c041795804e3ebd2a661d7e043d17 (diff) |
lib/modes: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/lib/modes/aead/gcm/gcm.cpp')
-rw-r--r-- | src/lib/modes/aead/gcm/gcm.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
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); |