aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-05-30 17:01:15 +0000
committerlloyd <[email protected]>2013-05-30 17:01:15 +0000
commitf85f4188fb21a64cc14d4f93117056292c11f8a8 (patch)
tree377a71719fcf841a3b5773a9c1762437e98d7721
parent4b04fc0fb25d32272d5d037e5e9d0de8b593143b (diff)
Remove mutation from GCM multiply loop
-rw-r--r--src/aead/gcm/gcm.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/aead/gcm/gcm.cpp b/src/aead/gcm/gcm.cpp
index 7563fc924..7b04f6f48 100644
--- a/src/aead/gcm/gcm.cpp
+++ b/src/aead/gcm/gcm.cpp
@@ -31,11 +31,11 @@ gcm_multiply(const secure_vector<byte>& x,
for(size_t i = 0; i != 2; ++i)
{
- u64bit X = load_be<u64bit>(&x[0], i);
+ const u64bit X = load_be<u64bit>(&x[0], i);
for(size_t j = 0; j != 64; ++j)
{
- if(X >> 63)
+ if((X >> (63-j)) & 1)
{
Z[0] ^= V[0];
Z[1] ^= V[1];
@@ -45,8 +45,6 @@ gcm_multiply(const secure_vector<byte>& x,
V[1] = (V[0] << 63) | (V[1] >> 1);
V[0] = (V[0] >> 1) ^ r;
-
- X <<= 1;
}
}