aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/modes/cbc/cbc.cpp8
-rw-r--r--src/lib/modes/xts/xts.cpp12
2 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/modes/cbc/cbc.cpp b/src/lib/modes/cbc/cbc.cpp
index 31834bade..3095875f5 100644
--- a/src/lib/modes/cbc/cbc.cpp
+++ b/src/lib/modes/cbc/cbc.cpp
@@ -179,8 +179,8 @@ void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
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];
}
cipher().encrypt(&last[0]);
@@ -286,7 +286,11 @@ void CTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
xor_buf(&last[0], &last[BS], final_bytes - 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];
+ }
cipher().decrypt(&last[0]);
xor_buf(&last[0], state_ptr(), BS);
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);