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/cbc | |
parent | d4811ce2ea1c041795804e3ebd2a661d7e043d17 (diff) |
lib/modes: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/lib/modes/cbc')
-rw-r--r-- | src/lib/modes/cbc/cbc.cpp | 28 | ||||
-rw-r--r-- | src/lib/modes/cbc/cbc.h | 2 |
2 files changed, 15 insertions, 15 deletions
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; |