Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# sha.h

    00001 #ifndef CRYPTOPP_SHA_H
    00002 #define CRYPTOPP_SHA_H
    00003
    00004 #include "iterhash.h"
    00005
    00006 NAMESPACE_BEGIN(CryptoPP)
    00007
    00008 /// <a href="http://www.weidai.com/scan-mirror/md.html#SHA-1">SHA-1</a>
    00009 class CRYPTOPP_DLL SHA : public IteratedHashWithStaticTransform<word32, BigEndian, 64, SHA>
    00010 {
    00011 public:
    00012         enum {DIGESTSIZE = 20};
    00013         SHA() : IteratedHashWithStaticTransform<word32, BigEndian, 64, SHA>(DIGESTSIZE) {Init();}
    00014         static void Transform(word32 *digest, const word32 *data);
    00015         static const char * StaticAlgorithmName() {return "SHA-1";}
    00016
    00017 protected:
    00018         void Init();
    00019 };
    00020
    00021 typedef SHA SHA1;
    00022
    00023 //! implements the SHA-256 standard
    00024 class SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, SHA256>
    00025 {
    00026 public:
    00027         enum {DIGESTSIZE = 32};
    00028         SHA256() : IteratedHashWithStaticTransform<word32, BigEndian, 64, SHA256>(DIGESTSIZE) {Init();}
    00029         static void Transform(word32 *digest, const word32 *data);
    00030         static const char * StaticAlgorithmName() {return "SHA-256";}
    00031
    00032 protected:
    00033         void Init();
    00034
    00035         static const word32 K[64];
    00036 };
    00037
    00038 #ifdef WORD64_AVAILABLE
    00039
    00040 //! implements the SHA-512 standard
    00041 class SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, SHA512>
    00042 {
    00043 public:
    00044         enum {DIGESTSIZE = 64};
    00045         SHA512() : IteratedHashWithStaticTransform<word64, BigEndian, 128, SHA512>(DIGESTSIZE) {Init();}
    00046         static void Transform(word64 *digest, const word64 *data);
    00047         static const char * StaticAlgorithmName() {return "SHA-512";}
    00048
    00049 protected:
    00050         void Init();
    00051
    00052         static const word64 K[80];
    00053 };
    00054
    00055 //! implements the SHA-384 standard
    00056 class SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, SHA512>
    00057 {
    00058 public:
    00059         enum {DIGESTSIZE = 48};
    00060         SHA384() : IteratedHashWithStaticTransform<word64, BigEndian, 128, SHA512>(64) {Init();}
    00061         unsigned int DigestSize() const {return DIGESTSIZE;};
    00062         static const char * StaticAlgorithmName() {return "SHA-384";}
    00063
    00064 protected:
    00065         void Init();
    00066 };
    00067
    00068 #endif
    00069
    00070 NAMESPACE_END
    00071
    00072 #endif