aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash/keccak
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-12-13 16:14:16 +0000
committerlloyd <[email protected]>2010-12-13 16:14:16 +0000
commit3560566f3993477ed8be95e7ec6817bf0db1edc3 (patch)
tree6420daada88aa78ca8efda63758c238df36bedab /src/hash/keccak
parenta8dc533b61713be885b7c1554ae10423c3939170 (diff)
Fix Keccak message XOR, did not work on big-endian CPUs
Diffstat (limited to 'src/hash/keccak')
-rw-r--r--src/hash/keccak/keccak.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/hash/keccak/keccak.cpp b/src/hash/keccak/keccak.cpp
index 4e5d3744f..9ee4d2363 100644
--- a/src/hash/keccak/keccak.cpp
+++ b/src/hash/keccak/keccak.cpp
@@ -139,14 +139,18 @@ void Keccak_1600::add_data(const byte input[], size_t length)
while(length)
{
- const size_t consumed = std::min(length, bitrate / 8 - S_pos);
- xor_buf(reinterpret_cast<byte*>(&S[0]) + S_pos,
- input,
- consumed);
-
- input += consumed;
- length -= consumed;
- S_pos += consumed;
+ size_t to_take = std::min(length, bitrate / 8 - S_pos);
+
+ length -= to_take;
+
+ while(to_take)
+ {
+ S[S_pos / 8] ^= static_cast<u64bit>(input[0]) << (8 * (S_pos % 8));
+
+ ++S_pos;
+ ++input;
+ --to_take;
+ }
if(S_pos == bitrate / 8)
{