3 #ifndef CRYPTOPP_ITERHASH_H 4 #define CRYPTOPP_ITERHASH_H 11 #if CRYPTOPP_MSC_VERSION 12 # pragma warning(push) 13 # pragma warning(disable: 4231 4275) 14 # if (CRYPTOPP_MSC_VERSION >= 1400) 15 # pragma warning(disable: 6011 6386 28193) 20 #define HashWordPtr(x) ((HashWordType*)(void*)(x)) 21 #define ConstHashWordPtr(x) ((const HashWordType*)(const void*)(x)) 30 :
InvalidDataFormat(
"IteratedHashBase: input data exceeds maximum allowed by hash function " + alg) {}
38 template <
class T,
class BASE>
42 typedef T HashWordType;
62 void Update(
const byte *input,
size_t length);
72 byte * CreateUpdateSpace(
size_t &size);
83 void TruncatedFinal(byte *digest,
size_t digestSize);
86 inline T GetBitCountHi()
const {
return (m_countLo >> (8*
sizeof(T)-3)) + (m_countHi << 3);}
87 inline T GetBitCountLo()
const {
return m_countLo << 3;}
89 void PadLastBlock(
unsigned int lastBlockSize, byte padFirst=0x80);
90 virtual void Init() =0;
92 virtual ByteOrder GetByteOrder()
const =0;
93 virtual void HashEndianCorrectedBlock(
const HashWordType *data) =0;
94 virtual size_t HashMultipleBlocks(
const T *input,
size_t length);
95 void HashBlock(
const HashWordType *input) {HashMultipleBlocks(input, this->
BlockSize());}
97 virtual T* DataBuf() =0;
98 virtual T* StateBuf() =0;
101 T m_countLo, m_countHi;
111 template <
class T_HashWordType,
class T_Endianness,
unsigned int T_BlockSize,
class T_Base = HashTransformation>
115 typedef T_Endianness ByteOrderClass;
116 typedef T_HashWordType HashWordType;
118 CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize)
146 T_HashWordType* DataBuf() {
return this->m_data;}
159 template <
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>
161 :
public ClonableImpl<T_Transform, AlgorithmImpl<IteratedHash<T_HashWordType, T_Endianness, T_BlockSize>, T_Transform> >
164 CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize)
175 void HashEndianCorrectedBlock(
const T_HashWordType *data) {T_Transform::Transform(this->m_state, data);}
176 void Init() {T_Transform::InitState(this->m_state);}
178 T_HashWordType* StateBuf() {
return this->m_state;}
182 #if !defined(__GNUC__) && !defined(__clang__) 192 #if CRYPTOPP_MSC_VERSION 193 # pragma warning(pop) IteratedHashBase()
Construct an IteratedHashBase.
Classes providing basic library services.
Utility functions for the Crypto++ library.
ByteOrder
Provides the byte ordering.
Base class for identifying alogorithm.
Abstract base classes that provide a uniform interface to this library.
unsigned int BlockSize() const
Provides the block size of the hash.
Classes and functions for secure memory allocations.
ByteOrder GetByteOrder() const
Provides the byte order of the hash.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
T ConditionalByteReverse(ByteOrder order, T value)
Reverses bytes in a value depending upon endianness.
Fixed size stack-based SecBlock with 16-byte alignment.
void CorrectEndianess(HashWordType *out, const HashWordType *in, size_t byteCount)
Adjusts the byte ordering of the hash.
Fixed size stack-based SecBlock.
const char * BlockSize()
int, in bytes
unsigned int OptimalBlockSize() const
Provides the input block size most efficient for this cipher.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Iterated hash base class.
Iterated hash base class.
Crypto++ library namespace.