diff options
author | weidai <weidai11@users.noreply.github.com> | 2002-10-04 17:31:41 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2002-10-04 17:31:41 +0000 |
commit | a3b6ece7ab341b5b14135baeccea7d5e4c086771 (patch) | |
tree | 8b045309c238226c32a563b1df6b9c30a2f0e0b3 /sha.h | |
download | cryptopp-git-a3b6ece7ab341b5b14135baeccea7d5e4c086771.tar.gz |
Initial revision
Diffstat (limited to 'sha.h')
-rw-r--r-- | sha.h | 72 |
1 files changed, 72 insertions, 0 deletions
@@ -0,0 +1,72 @@ +#ifndef CRYPTOPP_SHA_H +#define CRYPTOPP_SHA_H + +#include "iterhash.h" + +NAMESPACE_BEGIN(CryptoPP) + +/// <a href="http://www.weidai.com/scan-mirror/md.html#SHA-1">SHA-1</a> +class SHA : public IteratedHashWithStaticTransform<word32, BigEndian, 64, SHA> +{ +public: + enum {DIGESTSIZE = 20}; + SHA() : IteratedHashWithStaticTransform<word32, BigEndian, 64, SHA>(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<word32, BigEndian, 64, SHA256> +{ +public: + enum {DIGESTSIZE = 32}; + SHA256() : IteratedHashWithStaticTransform<word32, BigEndian, 64, SHA256>(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<word64, BigEndian, 128, SHA512> +{ +public: + enum {DIGESTSIZE = 64}; + SHA512() : IteratedHashWithStaticTransform<word64, BigEndian, 128, SHA512>(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<word64, BigEndian, 128, SHA512> +{ +public: + enum {DIGESTSIZE = 48}; + SHA384() : IteratedHashWithStaticTransform<word64, BigEndian, 128, SHA512>(64) {Init();} + unsigned int DigestSize() const {return DIGESTSIZE;}; + static const char *StaticAlgorithmName() {return "SHA-384";} + +protected: + void Init(); +}; + +#endif + +NAMESPACE_END + +#endif |