aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash/keccak
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-01-20 13:53:14 +0000
committerlloyd <[email protected]>2011-01-20 13:53:14 +0000
commit599204c32af04c29168f8df7dda4fb09a8b6402a (patch)
tree5f79a2155117961a0bbe600b8d292baffff63fcd /src/hash/keccak
parent858c81d74f5111594846b021a77c29224dd0e1ea (diff)
Update Keccak to the round 3 variant announced 2011-01-17
Only change is the padding rule. It 'simplifies' the padding by making it less flexible and harder to implement efficiently. :(
Diffstat (limited to 'src/hash/keccak')
-rw-r--r--src/hash/keccak/keccak.cpp12
-rw-r--r--src/hash/keccak/keccak.h1
2 files changed, 4 insertions, 9 deletions
diff --git a/src/hash/keccak/keccak.cpp b/src/hash/keccak/keccak.cpp
index 841c8875d..922167b61 100644
--- a/src/hash/keccak/keccak.cpp
+++ b/src/hash/keccak/keccak.cpp
@@ -104,7 +104,6 @@ void keccak_f_1600(u64bit A[25])
Keccak_1600::Keccak_1600(size_t output_bits) :
output_bits(output_bits),
bitrate(1600 - 2*output_bits),
- diversifier(static_cast<byte>(output_bits / 8)),
S(25),
S_pos(0)
{
@@ -179,15 +178,12 @@ void Keccak_1600::add_data(const byte input[], size_t length)
void Keccak_1600::final_result(byte output[])
{
- const byte padding[4] = { 0x01,
- diversifier,
- static_cast<byte>(bitrate / 8),
- 0x01 };
+ MemoryVector<byte> padding(bitrate / 8 - S_pos);
- add_data(padding, sizeof(padding));
+ padding[0] = 0x01;
+ padding[padding.size()-1] |= 0x80;
- if(S_pos)
- keccak_f_1600(&S[0]);
+ add_data(padding, padding.size());
/*
* We never have to run the permutation again because we only support
diff --git a/src/hash/keccak/keccak.h b/src/hash/keccak/keccak.h
index 1c6ec3122..17ae632ba 100644
--- a/src/hash/keccak/keccak.h
+++ b/src/hash/keccak/keccak.h
@@ -38,7 +38,6 @@ class BOTAN_DLL Keccak_1600 : public HashFunction
void final_result(byte out[]);
size_t output_bits, bitrate;
- byte diversifier;
SecureVector<u64bit> S;
size_t S_pos;
};