Security Scol plugin
sha.h
Go to the documentation of this file.
1// sha.h - originally written and placed in the public domain by Wei Dai
2
7
8#ifndef CRYPTOPP_SHA_H
9#define CRYPTOPP_SHA_H
10
11#include "config.h"
12#include "iterhash.h"
13
14// Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler
15// error with .intel_syntax, http://llvm.org/bugs/show_bug.cgi?id=24232
16#if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_MIXED_ASM)
17# define CRYPTOPP_DISABLE_SHA_ASM 1
18#endif
19
20NAMESPACE_BEGIN(CryptoPP)
21
22
26class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1>
27{
28public:
37 static void CRYPTOPP_API InitState(HashWordType *state);
49 static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data);
52 CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
53 // Algorithm class
54 std::string AlgorithmProvider() const;
55
56protected:
57 size_t HashMultipleBlocks(const HashWordType *input, size_t length);
58};
59
64class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true>
65{
66public:
75 static void CRYPTOPP_API InitState(HashWordType *state);
87 static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data);
90 CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
91
92 // Algorithm class
93 std::string AlgorithmProvider() const;
94
95protected:
96 size_t HashMultipleBlocks(const HashWordType *input, size_t length);
97};
98
103class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true>
104{
105public:
114 static void CRYPTOPP_API InitState(HashWordType *state);
126 static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data) {SHA256::Transform(digest, data);}
129 CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
130
131 // Algorithm class
132 std::string AlgorithmProvider() const;
133
134protected:
135 size_t HashMultipleBlocks(const HashWordType *input, size_t length);
136};
137
141class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, true>
142{
143public:
152 static void CRYPTOPP_API InitState(HashWordType *state);
164 static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data);
167 CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
168
169 // Algorithm class
170 std::string AlgorithmProvider() const;
171};
172
176class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, true>
177{
178public:
187 static void CRYPTOPP_API InitState(HashWordType *state);
199 static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data) {SHA512::Transform(digest, data);}
202 CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
203
204 // Algorithm class
205 std::string AlgorithmProvider() const;
206};
207
208NAMESPACE_END
209
210#endif
virtual std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
Definition iterhash.h:94
Iterated hash with a static transformation function.
Definition iterhash.h:182
SHA-1 message digest.
Definition sha.h:27
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
The algorithm name.
Definition sha.h:52
SHA-224 message digest.
Definition sha.h:104
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
The algorithm name.
Definition sha.h:129
static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data)
Operate the hash.
Definition sha.h:126
SHA-256 message digest.
Definition sha.h:65
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
The algorithm name.
Definition sha.h:90
static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data)
Operate the hash.
Definition sha.cpp:858
SHA-384 message digest.
Definition sha.h:177
static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data)
Operate the hash.
Definition sha.h:199
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
The algorithm name.
Definition sha.h:202
SHA-512 message digest.
Definition sha.h:142
static void CRYPTOPP_API Transform(HashWordType *digest, const HashWordType *data)
Operate the hash.
Definition sha.cpp:1371
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
The algorithm name.
Definition sha.h:167
Library configuration file.
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
Base classes for iterated hashes.
Converts an enumeration to a type suitable for use as a template parameter.
Definition cryptlib.h:136