diff options
author | Jack Lloyd <[email protected]> | 2017-09-24 18:23:04 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-24 18:23:13 -0400 |
commit | 1f8ea081665b1d8ef0baac377f164fbf8e339e70 (patch) | |
tree | 2c456c634b8aee4d6d7c491c2fbe38e8ecadad05 /src/lib/modes | |
parent | cb825beb78fe5671e1e124f2a46491a4114af105 (diff) |
Avoid debug iterator error
Diffstat (limited to 'src/lib/modes')
-rw-r--r-- | src/lib/modes/aead/siv/siv.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/modes/aead/siv/siv.cpp b/src/lib/modes/aead/siv/siv.cpp index 8b2cc4ef0..a3de8f35c 100644 --- a/src/lib/modes/aead/siv/siv.cpp +++ b/src/lib/modes/aead/siv/siv.cpp @@ -161,8 +161,11 @@ void SIV_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset) buffer.insert(buffer.begin() + offset, V.begin(), V.end()); - set_ctr_iv(V); - ctr().cipher1(&buffer[offset + V.size()], buffer.size() - offset - V.size()); + if(buffer.size() != offset + V.size()) + { + set_ctr_iv(V); + ctr().cipher1(&buffer[offset + V.size()], buffer.size() - offset - V.size()); + } } void SIV_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset) @@ -179,11 +182,14 @@ void SIV_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset) secure_vector<uint8_t> V(buffer.data() + offset, buffer.data() + offset + block_size()); - set_ctr_iv(V); + if(buffer.size() != offset + V.size()) + { + set_ctr_iv(V); - ctr().cipher(buffer.data() + offset + V.size(), - buffer.data() + offset, - buffer.size() - offset - V.size()); + ctr().cipher(buffer.data() + offset + V.size(), + buffer.data() + offset, + buffer.size() - offset - V.size()); + } const secure_vector<uint8_t> T = S2V(buffer.data() + offset, buffer.size() - offset - V.size()); |