Crypto++
sha.h
1 #ifndef CRYPTOPP_SHA_H
2 #define CRYPTOPP_SHA_H
3 
4 #include "iterhash.h"
5 
6 NAMESPACE_BEGIN(CryptoPP)
7 
8 /// <a href="http://www.weidai.com/scan-mirror/md.html#SHA-1">SHA-1</a>
9 class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1>
10 {
11 public:
12  static void CRYPTOPP_API InitState(HashWordType *state);
13  static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
14  static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
15 };
16 
17 typedef SHA1 SHA; // for backwards compatibility
18 
19 //! implements the SHA-256 standard
20 class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true>
21 {
22 public:
23 #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
24  size_t HashMultipleBlocks(const word32 *input, size_t length);
25 #endif
26  static void CRYPTOPP_API InitState(HashWordType *state);
27  static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
28  static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
29 };
30 
31 //! implements the SHA-224 standard
32 class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true>
33 {
34 public:
35 #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
36  size_t HashMultipleBlocks(const word32 *input, size_t length);
37 #endif
38  static void CRYPTOPP_API InitState(HashWordType *state);
39  static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);}
40  static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
41 };
42 
43 //! implements the SHA-512 standard
44 class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, CRYPTOPP_BOOL_X86>
45 {
46 public:
47  static void CRYPTOPP_API InitState(HashWordType *state);
48  static void CRYPTOPP_API Transform(word64 *digest, const word64 *data);
49  static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
50 };
51 
52 //! implements the SHA-384 standard
53 class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, CRYPTOPP_BOOL_X86>
54 {
55 public:
56  static void CRYPTOPP_API InitState(HashWordType *state);
57  static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);}
58  static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
59 };
60 
61 NAMESPACE_END
62 
63 #endif
implements the SHA-384 standard
Definition: sha.h:53
implements the SHA-256 standard
Definition: sha.h:20
implements the SHA-512 standard
Definition: sha.h:44
SHA-1
Definition: sha.h:9
implements the SHA-224 standard
Definition: sha.h:32