diff options
author | lloyd <[email protected]> | 2008-10-08 14:09:44 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-10-08 14:09:44 +0000 |
commit | 9259a1c13140636981720c19a8d1cabfe4eb8f8e (patch) | |
tree | 0a476ebc80a1768ddfad8be6c928aa34f49a6042 /src/hash/sha2/sha2_32.h | |
parent | 66aa83a7e110975ce091559317f06d88d20dd9b1 (diff) |
Add SHA-224 from InSiTo, written and (C) by FlexSecure GmbH
Rename sha256.h and sha_64.h to sha2_32.h and sha2_64.h - this affects
users who instantiate these classes directly.
Diffstat (limited to 'src/hash/sha2/sha2_32.h')
-rw-r--r-- | src/hash/sha2/sha2_32.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/hash/sha2/sha2_32.h b/src/hash/sha2/sha2_32.h new file mode 100644 index 000000000..a767b3d10 --- /dev/null +++ b/src/hash/sha2/sha2_32.h @@ -0,0 +1,57 @@ +/************************************************* +* SHA-{224,256} Header File * +* (C) 1999-2008 Jack Lloyd * +* 2007 FlexSecure GmbH * +*************************************************/ + +#ifndef BOTAN_SHA_256_H__ +#define BOTAN_SHA_256_H__ + +#include <botan/mdx_hash.h> + +namespace Botan { + +/************************************************* +* SHA-{224,256} Base * +*************************************************/ +class BOTAN_DLL SHA_224256_BASE : public MDx_HashFunction + { + protected: + void clear() throw(); + SHA_224256_BASE(u32bit out) : + MDx_HashFunction(out, 64, true, true) { clear(); } + + SecureBuffer<u32bit, 64> W; + SecureBuffer<u32bit, 8> digest; + private: + void hash(const byte[]); + void copy_out(byte[]); + }; + +/************************************************* +* SHA-224 * +*************************************************/ +class BOTAN_DLL SHA_224 : public SHA_224256_BASE + { + public: + void clear() throw(); + std::string name() const { return "SHA-224"; } + HashFunction* clone() const { return new SHA_224; } + SHA_224() : SHA_224256_BASE(28) { clear(); } + }; + +/************************************************* +* SHA-256 * +*************************************************/ +class BOTAN_DLL SHA_256 : public SHA_224256_BASE + { + public: + void clear() throw(); + std::string name() const { return "SHA-256"; } + HashFunction* clone() const { return new SHA_256; } + SHA_256() : SHA_224256_BASE(32) { clear (); } + }; + +} + +#endif |