aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/keccak
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-01-30 12:16:50 -0500
committerJack Lloyd <[email protected]>2018-01-30 12:41:35 -0500
commitc3a2c598f7f9ac714681e7f7c7568dd022451382 (patch)
treef2d7bc6939cbdc81653115eb64bde1f6634df93f /src/lib/hash/keccak
parentd8e6c5bd2912e19654ad46389fb27dcb00610b66 (diff)
Avoid allocating zero bytes for SHA-3 padding
Inspired by #1433
Diffstat (limited to 'src/lib/hash/keccak')
-rw-r--r--src/lib/hash/keccak/keccak.cpp7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/lib/hash/keccak/keccak.cpp b/src/lib/hash/keccak/keccak.cpp
index 94e3f70ba..a4d4cef7d 100644
--- a/src/lib/hash/keccak/keccak.cpp
+++ b/src/lib/hash/keccak/keccak.cpp
@@ -53,12 +53,7 @@ void Keccak_1600::add_data(const uint8_t input[], size_t length)
void Keccak_1600::final_result(uint8_t output[])
{
- std::vector<uint8_t> padding(m_bitrate / 8 - m_S_pos);
-
- padding[0] = 0x01;
- padding[padding.size()-1] |= 0x80;
-
- add_data(padding.data(), padding.size());
+ SHA_3::finish(m_bitrate, m_S, m_S_pos, 0x01, 0x80);
/*
* We never have to run the permutation again because we only support