diff options
Diffstat (limited to 'src/lib/modes/xts/xts.cpp')
-rw-r--r-- | src/lib/modes/xts/xts.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/modes/xts/xts.cpp b/src/lib/modes/xts/xts.cpp index 02da5fa5d..1b41a5a5d 100644 --- a/src/lib/modes/xts/xts.cpp +++ b/src/lib/modes/xts/xts.cpp @@ -197,7 +197,11 @@ void XTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset) xor_buf(last, tweak(), BS); for(size_t i = 0; i != final_bytes - BS; ++i) - std::swap(last[i], last[i + BS]); + { + last[i] ^= last[i + BS]; + last[i + BS] ^= last[i]; + last[i] ^= last[i + BS]; + } xor_buf(last, tweak() + BS, BS); cipher().encrypt(last); @@ -272,7 +276,11 @@ void XTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset) xor_buf(last, tweak() + BS, BS); for(size_t i = 0; i != final_bytes - BS; ++i) - std::swap(last[i], last[i + BS]); + { + last[i] ^= last[i + BS]; + last[i + BS] ^= last[i]; + last[i] ^= last[i + BS]; + } xor_buf(last, tweak(), BS); cipher().decrypt(last); |