diff options
Diffstat (limited to 'src/hash/sha2/sha2_32.h')
-rw-r--r-- | src/hash/sha2/sha2_32.h | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/hash/sha2/sha2_32.h b/src/hash/sha2/sha2_32.h index e8e60d07c..71f0cff4b 100644 --- a/src/hash/sha2/sha2_32.h +++ b/src/hash/sha2/sha2_32.h @@ -1,61 +1,52 @@ /* * SHA-{224,256} -* (C) 1999-2008 Jack Lloyd +* (C) 1999-2010 Jack Lloyd * 2007 FlexSecure GmbH * * Distributed under the terms of the Botan license */ -#ifndef BOTAN_SHA_256_H__ -#define BOTAN_SHA_256_H__ +#ifndef BOTAN_SHA_224_256_H__ +#define BOTAN_SHA_224_256_H__ #include <botan/mdx_hash.h> namespace Botan { /** -* Base class for the 32-bit SHA-2 hashes (SHA-224 and SHA-256) -*/ -class BOTAN_DLL SHA_224_256_BASE : public MDx_HashFunction - { - protected: - void clear(); - - /** - * @param out output size in bytes - */ - SHA_224_256_BASE(u32bit out) : - MDx_HashFunction(out, 64, true, true) { clear(); } - - SecureVector<u32bit, 64> W; - SecureVector<u32bit, 8> digest; - private: - void compress_n(const byte[], u32bit blocks); - void copy_out(byte[]); - }; - -/** * SHA-224 */ -class BOTAN_DLL SHA_224 : public SHA_224_256_BASE +class BOTAN_DLL SHA_224 : public MDx_HashFunction { public: void clear(); std::string name() const { return "SHA-224"; } HashFunction* clone() const { return new SHA_224; } - SHA_224() : SHA_224_256_BASE(28) { clear(); } + SHA_224() : MDx_HashFunction(28, 64, true, true) { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureVector<u32bit, 64> W; + SecureVector<u32bit, 8> digest; }; /** * SHA-256 */ -class BOTAN_DLL SHA_256 : public SHA_224_256_BASE +class BOTAN_DLL SHA_256 : public MDx_HashFunction { public: void clear(); std::string name() const { return "SHA-256"; } HashFunction* clone() const { return new SHA_256; } - SHA_256() : SHA_224_256_BASE(32) { clear (); } + SHA_256() : MDx_HashFunction(32, 64, true, true) { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureVector<u32bit, 64> W; + SecureVector<u32bit, 8> digest; }; } |