6#ifndef CRYPTOPP_ITERHASH_H
7#define CRYPTOPP_ITERHASH_H
14#if CRYPTOPP_MSC_VERSION
16# pragma warning(disable: 4231 4275)
17# if (CRYPTOPP_MSC_VERSION >= 1400)
18# pragma warning(disable: 6011 6386 28193)
29 :
InvalidDataFormat(
"IteratedHashBase: input data exceeds maximum allowed by hash function " + alg) {}
37template <
class T,
class BASE>
41 typedef T HashWordType;
63 void Update(
const byte *input,
size_t length);
73 byte * CreateUpdateSpace(
size_t &size);
84 void TruncatedFinal(
byte *digest,
size_t digestSize);
97 inline T GetBitCountHi()
const
98 {
return (m_countLo >> (8*
sizeof(T)-3)) + (m_countHi << 3);}
99 inline T GetBitCountLo()
const
100 {
return m_countLo << 3;}
102 void PadLastBlock(
unsigned int lastBlockSize,
byte padFirst=0x80);
103 virtual void Init() =0;
105 virtual ByteOrder GetByteOrder()
const =0;
106 virtual void HashEndianCorrectedBlock(
const HashWordType *data) =0;
107 virtual size_t HashMultipleBlocks(
const T *input,
size_t length);
108 void HashBlock(
const HashWordType *input)
109 {HashMultipleBlocks(input, this->
BlockSize());}
111 virtual T* DataBuf() =0;
112 virtual T* StateBuf() =0;
115 T m_countLo, m_countHi;
125template <
class T_HashWordType,
class T_Endianness,
unsigned int T_BlockSize,
class T_Base = HashTransformation>
129 typedef T_Endianness ByteOrderClass;
130 typedef T_HashWordType HashWordType;
132 CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize);
165 enum { Blocks = T_BlockSize/
sizeof(T_HashWordType) };
166 T_HashWordType* DataBuf() {
return this->m_data;}
179template <
class T_HashWordType,
class T_Endianness,
unsigned int T_BlockSize,
unsigned int T_StateSize,
class T_Transform,
unsigned int T_DigestSize = 0,
bool T_StateAligned = false>
181 :
public ClonableImpl<T_Transform, AlgorithmImpl<IteratedHash<T_HashWordType, T_Endianness, T_BlockSize>, T_Transform> >
184 CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize);
196 void HashEndianCorrectedBlock(
const T_HashWordType *data) {T_Transform::Transform(this->m_state, data);}
197 void Init() {T_Transform::InitState(this->m_state);}
199 enum { Blocks = T_BlockSize/
sizeof(T_HashWordType) };
200 T_HashWordType* StateBuf() {
return this->m_state;}
204#if !defined(__GNUC__) && !defined(__clang__)
214#if CRYPTOPP_MSC_VERSION
Base class for identifying algorithm.
Fixed size stack-based SecBlock with 16-byte alignment.
Fixed size stack-based SecBlock.
Iterated hash base class.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
virtual std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
IteratedHashBase()
Construct an IteratedHashBase.
unsigned int OptimalBlockSize() const
Provides the input block size most efficient for this cipher.
Iterated hash base class.
ByteOrder GetByteOrder() const
Provides the byte order of the hash.
void CorrectEndianess(HashWordType *out, const HashWordType *in, size_t byteCount)
Adjusts the byte ordering of the hash.
unsigned int BlockSize() const
Provides the block size of the hash.
#define CRYPTOPP_STATIC_TEMPLATE_CLASS
Instantiate templates in a dynamic library.
#define CRYPTOPP_DLL_TEMPLATE_CLASS
Instantiate templates in a dynamic library.
Abstract base classes that provide a uniform interface to this library.
ByteOrder
Provides the byte ordering.
Utility functions for the Crypto++ library.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
T ConditionalByteReverse(ByteOrder order, T value)
Reverses bytes in a value depending upon endianness.
Crypto++ library namespace.
const char * BlockSize()
int, in bytes
Classes and functions for secure memory allocations.
Classes providing basic library services.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.