Crypto++

- Main Page
- Namespaces
- Classes
- Files

- File List
- 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 SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1>
    00010 {
    00011 public:
    00012     static void CRYPTOPP_API InitState(HashWordType *state);
    00013     static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
    00014     static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
    00015 };
    00016
    00017 typedef SHA1 SHA;   // for backwards compatibility
    00018
    00019 //! implements the SHA-256 standard
    00020 class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true>
    00021 {
    00022 public:
    00023 #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
    00024     size_t HashMultipleBlocks(const word32 *input, size_t length);
    00025 #endif
    00026     static void CRYPTOPP_API InitState(HashWordType *state);
    00027     static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
    00028     static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
    00029 };
    00030
    00031 //! implements the SHA-224 standard
    00032 class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true>
    00033 {
    00034 public:
    00035 #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
    00036     size_t HashMultipleBlocks(const word32 *input, size_t length);
    00037 #endif
    00038     static void CRYPTOPP_API InitState(HashWordType *state);
    00039     static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);}
    00040     static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
    00041 };
    00042
    00043 //! implements the SHA-512 standard
    00044 class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, CRYPTOPP_BOOL_X86>
    00045 {
    00046 public:
    00047     static void CRYPTOPP_API InitState(HashWordType *state);
    00048     static void CRYPTOPP_API Transform(word64 *digest, const word64 *data);
    00049     static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
    00050 };
    00051
    00052 //! implements the SHA-384 standard
    00053 class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, CRYPTOPP_BOOL_X86>
    00054 {
    00055 public:
    00056     static void CRYPTOPP_API InitState(HashWordType *state);
    00057     static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);}
    00058     static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
    00059 };
    00060
    00061 NAMESPACE_END
    00062
    00063 #endif