From b21162cf8e06f40baa1f58be6a8c17435cebc34d Mon Sep 17 00:00:00 2001 From: weidai Date: Fri, 4 Oct 2002 17:31:41 +0000 Subject: Initial revision git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@2 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- sha.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 sha.h (limited to 'sha.h') diff --git a/sha.h b/sha.h new file mode 100644 index 0000000..9c1cce5 --- /dev/null +++ b/sha.h @@ -0,0 +1,72 @@ +#ifndef CRYPTOPP_SHA_H +#define CRYPTOPP_SHA_H + +#include "iterhash.h" + +NAMESPACE_BEGIN(CryptoPP) + +/// SHA-1 +class SHA : public IteratedHashWithStaticTransform +{ +public: + enum {DIGESTSIZE = 20}; + SHA() : IteratedHashWithStaticTransform(DIGESTSIZE) {Init();} + static void Transform(word32 *digest, const word32 *data); + static const char *StaticAlgorithmName() {return "SHA-1";} + +protected: + void Init(); +}; + +typedef SHA SHA1; + +//! implements the SHA-256 standard +class SHA256 : public IteratedHashWithStaticTransform +{ +public: + enum {DIGESTSIZE = 32}; + SHA256() : IteratedHashWithStaticTransform(DIGESTSIZE) {Init();} + static void Transform(word32 *digest, const word32 *data); + static const char *StaticAlgorithmName() {return "SHA-256";} + +protected: + void Init(); + + static const word32 K[64]; +}; + +#ifdef WORD64_AVAILABLE + +//! implements the SHA-512 standard +class SHA512 : public IteratedHashWithStaticTransform +{ +public: + enum {DIGESTSIZE = 64}; + SHA512() : IteratedHashWithStaticTransform(DIGESTSIZE) {Init();} + static void Transform(word64 *digest, const word64 *data); + static const char *StaticAlgorithmName() {return "SHA-512";} + +protected: + void Init(); + + static const word64 K[80]; +}; + +//! implements the SHA-384 standard +class SHA384 : public IteratedHashWithStaticTransform +{ +public: + enum {DIGESTSIZE = 48}; + SHA384() : IteratedHashWithStaticTransform(64) {Init();} + unsigned int DigestSize() const {return DIGESTSIZE;}; + static const char *StaticAlgorithmName() {return "SHA-384";} + +protected: + void Init(); +}; + +#endif + +NAMESPACE_END + +#endif -- cgit v1.2.1