diff options
author | Jack Lloyd <[email protected]> | 2018-01-30 14:06:26 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-01-30 14:06:26 -0500 |
commit | 4d3f7ebb72339a85ed3eb39d5428512405320042 (patch) | |
tree | cbeba3671bfb0ea698533998c2e2556bb66ec67f | |
parent | 3aaec2e7e62185f4c954b0d454fa01008b1bef44 (diff) |
Reorganize SHA-3 source file [ci skip]
Put all the statics at beginning followed by member functions.
-rw-r--r-- | src/lib/hash/sha3/sha3.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/lib/hash/sha3/sha3.cpp b/src/lib/hash/sha3/sha3.cpp index df6fa64e5..0fd980b33 100644 --- a/src/lib/hash/sha3/sha3.cpp +++ b/src/lib/hash/sha3/sha3.cpp @@ -10,11 +10,6 @@ namespace Botan { -std::unique_ptr<HashFunction> SHA_3::copy_state() const - { - return std::unique_ptr<HashFunction>(new SHA_3(*this)); - } - //static void SHA_3::permute(uint64_t A[25]) { @@ -99,36 +94,6 @@ void SHA_3::permute(uint64_t A[25]) } } -SHA_3::SHA_3(size_t output_bits) : - m_output_bits(output_bits), - m_bitrate(1600 - 2*output_bits), - m_S(25), - m_S_pos(0) - { - // We only support the parameters for SHA-3 in this constructor - - if(output_bits != 224 && output_bits != 256 && - output_bits != 384 && output_bits != 512) - throw Invalid_Argument("SHA_3: Invalid output length " + - std::to_string(output_bits)); - } - -std::string SHA_3::name() const - { - return "SHA-3(" + std::to_string(m_output_bits) + ")"; - } - -HashFunction* SHA_3::clone() const - { - return new SHA_3(m_output_bits); - } - -void SHA_3::clear() - { - zeroise(m_S); - m_S_pos = 0; - } - //static size_t SHA_3::absorb(size_t bitrate, secure_vector<uint64_t>& S, size_t S_pos, @@ -214,6 +179,41 @@ void SHA_3::expand(size_t bitrate, } } +SHA_3::SHA_3(size_t output_bits) : + m_output_bits(output_bits), + m_bitrate(1600 - 2*output_bits), + m_S(25), + m_S_pos(0) + { + // We only support the parameters for SHA-3 in this constructor + + if(output_bits != 224 && output_bits != 256 && + output_bits != 384 && output_bits != 512) + throw Invalid_Argument("SHA_3: Invalid output length " + + std::to_string(output_bits)); + } + +std::string SHA_3::name() const + { + return "SHA-3(" + std::to_string(m_output_bits) + ")"; + } + +std::unique_ptr<HashFunction> SHA_3::copy_state() const + { + return std::unique_ptr<HashFunction>(new SHA_3(*this)); + } + +HashFunction* SHA_3::clone() const + { + return new SHA_3(m_output_bits); + } + +void SHA_3::clear() + { + zeroise(m_S); + m_S_pos = 0; + } + void SHA_3::add_data(const uint8_t input[], size_t length) { m_S_pos = SHA_3::absorb(m_bitrate, m_S, m_S_pos, input, length); |