diff options
author | lloyd <[email protected]> | 2010-09-30 18:42:42 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-30 18:42:42 +0000 |
commit | 63bc6e8971f66233f4e05bb8d7f7db9afd7ba7f4 (patch) | |
tree | 0dcb7fa1934bf1e84f1567f80a926ecfe7d9a1b6 /src/hash/sha2_32/sha2_32.h | |
parent | d45c828067598fc44eff08333c23af413ab2a455 (diff) |
Split SHA-2 into 32 and 64 bit versions; they are totally independent
of each other anyway.
Diffstat (limited to 'src/hash/sha2_32/sha2_32.h')
-rw-r--r-- | src/hash/sha2_32/sha2_32.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/hash/sha2_32/sha2_32.h b/src/hash/sha2_32/sha2_32.h new file mode 100644 index 000000000..a3e3a6f19 --- /dev/null +++ b/src/hash/sha2_32/sha2_32.h @@ -0,0 +1,56 @@ +/* +* SHA-{224,256} +* (C) 1999-2010 Jack Lloyd +* 2007 FlexSecure GmbH +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SHA_224_256_H__ +#define BOTAN_SHA_224_256_H__ + +#include <botan/mdx_hash.h> + +namespace Botan { + +/** +* SHA-224 +*/ +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() : MDx_HashFunction(28, 64, true, true), W(64), digest(8) + { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureVector<u32bit> W, digest; + }; + +/** +* SHA-256 +*/ +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() : MDx_HashFunction(32, 64, true, true), W(64), digest(8) + { clear(); } + private: + void compress_n(const byte[], u32bit blocks); + void copy_out(byte[]); + + SecureVector<u32bit> W, digest; + }; + +} + +#endif |