From 718d577455c2e431e32064950f2612e1381c275a Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 8 Jan 2015 01:11:17 +0000 Subject: Add SHA-512/256 Define some new functions for copying out arrays of words and use them across hashes. --- src/lib/hash/sha2_64/sha2_64.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/lib/hash/sha2_64/sha2_64.h') diff --git a/src/lib/hash/sha2_64/sha2_64.h b/src/lib/hash/sha2_64/sha2_64.h index 58b154170..33bcb1100 100644 --- a/src/lib/hash/sha2_64/sha2_64.h +++ b/src/lib/hash/sha2_64/sha2_64.h @@ -1,6 +1,6 @@ /* * SHA-{384,512} -* (C) 1999-2010 Jack Lloyd +* (C) 1999-2010,2015 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -24,13 +24,13 @@ class BOTAN_DLL SHA_384 : public MDx_HashFunction void clear(); - SHA_384() : MDx_HashFunction(128, true, true, 16), digest(8) + SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); } private: void compress_n(const byte[], size_t blocks); void copy_out(byte[]); - secure_vector digest; + secure_vector m_digest; }; /** @@ -45,13 +45,33 @@ class BOTAN_DLL SHA_512 : public MDx_HashFunction void clear(); - SHA_512() : MDx_HashFunction(128, true, true, 16), digest(8) + SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); } private: void compress_n(const byte[], size_t blocks); void copy_out(byte[]); - secure_vector digest; + secure_vector m_digest; + }; + +/** +* SHA-512/256 +*/ +class BOTAN_DLL SHA_512_256 : public MDx_HashFunction + { + public: + std::string name() const { return "SHA-512/256"; } + size_t output_length() const { return 32; } + HashFunction* clone() const { return new SHA_512_256; } + + void clear(); + + SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); } + private: + void compress_n(const byte[], size_t blocks); + void copy_out(byte[]); + + secure_vector m_digest; }; } -- cgit v1.2.3