Crypto++
8.6
Free C++ class library of cryptographic schemes
|
Go to the documentation of this file.
6 #ifndef CRYPTOPP_ITERHASH_H
7 #define CRYPTOPP_ITERHASH_H
14 #if CRYPTOPP_MSC_VERSION
15 # pragma warning(push)
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) {}
37 template <
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;
125 template <
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;}
179 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>
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
215 # pragma warning(pop)
Fixed size stack-based SecBlock with 16-byte alignment.
virtual std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
unsigned int OptimalBlockSize() const
Provides the input block size most efficient for this cipher.
unsigned int BlockSize() const
Provides the block size of the hash.
Classes and functions for secure memory allocations.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
Classes providing basic library services.
Utility functions for the Crypto++ library.
ByteOrder GetByteOrder() const
Provides the byte order of the hash.
ByteOrder
Provides the byte ordering.
void CorrectEndianess(HashWordType *out, const HashWordType *in, size_t byteCount)
Adjusts the byte ordering of the hash.
IteratedHashBase()
Construct an IteratedHashBase.
T ConditionalByteReverse(ByteOrder order, T value)
Reverses bytes in a value depending upon endianness.
Iterated hash base class.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
#define CRYPTOPP_STATIC_TEMPLATE_CLASS
Instantiate templates in a dynamic library.
Base class for identifying algorithm.
Crypto++ library namespace.
#define CRYPTOPP_DLL_TEMPLATE_CLASS
Instantiate templates in a dynamic library.
Abstract base classes that provide a uniform interface to this library.
Iterated hash base class.