From 9285e06b23001e2ea3a628178151047ceec8d83e Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 13 Dec 2010 16:18:38 +0000 Subject: Do the XOR a word at a time where possible which gets performance back to the level of the version using xor_buf, at least on a little-endian CPU. --- src/hash/keccak/keccak.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/hash/keccak/keccak.cpp b/src/hash/keccak/keccak.cpp index 9ee4d2363..37fdc0d86 100644 --- a/src/hash/keccak/keccak.cpp +++ b/src/hash/keccak/keccak.cpp @@ -143,6 +143,23 @@ void Keccak_1600::add_data(const byte input[], size_t length) length -= to_take; + while(to_take && S_pos % 8) + { + S[S_pos / 8] ^= static_cast(input[0]) << (8 * (S_pos % 8)); + + ++S_pos; + ++input; + --to_take; + } + + while(to_take && to_take % 8 == 0) + { + S[S_pos / 8] ^= load_le(input, 0); + S_pos += 8; + input += 8; + to_take -= 8; + } + while(to_take) { S[S_pos / 8] ^= static_cast(input[0]) << (8 * (S_pos % 8)); -- cgit v1.2.3