diff options
author | Simon Warta <[email protected]> | 2015-06-24 12:57:41 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-06-24 12:57:41 +0200 |
commit | 18bf2bacad303cb3ed2aa19367c6ba6a3f3041bd (patch) | |
tree | e663615e490f7812d3d7d7469b76daaa10cc7771 /src/lib/modes/aead/siv/siv.cpp | |
parent | db0dde7107dbe4155a856c20342ca57e09bd329c (diff) | |
parent | b6c79e70b16e862a7ffd3b54e980263548c1d251 (diff) |
Merge pull request #135 from webmaster128/bounds-check3
Bounds check round 3
Diffstat (limited to 'src/lib/modes/aead/siv/siv.cpp')
-rw-r--r-- | src/lib/modes/aead/siv/siv.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
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"); |