diff options
author | Jack Lloyd <[email protected]> | 2016-11-10 13:25:10 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-11-10 13:25:10 -0500 |
commit | b7ae8043e963467eb222a44f48d66a1df36d9371 (patch) | |
tree | f5ec4059e21d874404c60595568a4a3d4d7305c9 /src/lib/hash/keccak | |
parent | e6bf87b6b0d4d9c3877b79de53de58dc34a3acca (diff) |
Add SHAKE-128 and SHAKE-256 as hash functions
Diffstat (limited to 'src/lib/hash/keccak')
-rw-r--r-- | src/lib/hash/keccak/keccak.cpp | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/src/lib/hash/keccak/keccak.cpp b/src/lib/hash/keccak/keccak.cpp index 60cb20696..e0c67131b 100644 --- a/src/lib/hash/keccak/keccak.cpp +++ b/src/lib/hash/keccak/keccak.cpp @@ -44,47 +44,7 @@ void Keccak_1600::clear() void Keccak_1600::add_data(const byte input[], size_t length) { - if(length == 0) - return; - - while(length) - { - size_t to_take = std::min(length, m_bitrate / 8 - m_S_pos); - - length -= to_take; - - while(to_take && m_S_pos % 8) - { - m_S[m_S_pos / 8] ^= static_cast<u64bit>(input[0]) << (8 * (m_S_pos % 8)); - - ++m_S_pos; - ++input; - --to_take; - } - - while(to_take && to_take % 8 == 0) - { - m_S[m_S_pos / 8] ^= load_le<u64bit>(input, 0); - m_S_pos += 8; - input += 8; - to_take -= 8; - } - - while(to_take) - { - m_S[m_S_pos / 8] ^= static_cast<u64bit>(input[0]) << (8 * (m_S_pos % 8)); - - ++m_S_pos; - ++input; - --to_take; - } - - if(m_S_pos == m_bitrate / 8) - { - SHA_3::permute(m_S.data()); - m_S_pos = 0; - } - } + m_S_pos = SHA_3::absorb(m_bitrate, m_S, m_S_pos, input, length); } void Keccak_1600::final_result(byte output[]) |