aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-24 15:19:02 +0000
committerlloyd <[email protected]>2014-01-24 15:19:02 +0000
commit910625b2468df6db8a26cbe7abfd8fc1a131f51d (patch)
treedc29b3cda3d38a4eb95767630d04d1d7a59112f1 /src/lib
parente7365efee55242622bc62df3ec05361571160acb (diff)
Avoid strict overflow warnings in GCC 4.8
Diffstat (limited to 'src/lib')
-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);