Fabcoin Core  0.16.2
P2P Digital Currency
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
IteratedHashBase< T, BASE > Class Template Referenceabstract

Iterated hash base class. More...

#include <iterhash.h>

Inheritance diagram for IteratedHashBase< T, BASE >:
[legend]
Collaboration diagram for IteratedHashBase< T, BASE >:
[legend]

Public Types

typedef T HashWordType
 

Public Member Functions

 IteratedHashBase ()
 Construct an IteratedHashBase. More...
 
unsigned int OptimalBlockSize () const
 Provides the input block size most efficient for this cipher. More...
 
unsigned int OptimalDataAlignment () const
 Provides input and output data alignment for optimal performance. More...
 
void Update (const byte *input, size_t length)
 Updates a hash with additional input. More...
 
byteCreateUpdateSpace (size_t &size)
 Requests space which can be written into by the caller. More...
 
void Restart ()
 Restart the hash. More...
 
void TruncatedFinal (byte *digest, size_t digestSize)
 Computes the hash of the current message. More...
 

Protected Member Functions

T GetBitCountHi () const
 
T GetBitCountLo () const
 
void PadLastBlock (unsigned int lastBlockSize, byte padFirst=0x80)
 
virtual void Init ()=0
 
virtual ByteOrder GetByteOrder () const =0
 
virtual void HashEndianCorrectedBlock (const HashWordType *data)=0
 
virtual size_t HashMultipleBlocks (const T *input, size_t length)
 
void HashBlock (const HashWordType *input)
 
virtual TDataBuf ()=0
 
virtual TStateBuf ()=0
 

Private Attributes

T m_countLo
 
T m_countHi
 

Detailed Description

template<class T, class BASE>
class IteratedHashBase< T, BASE >

Iterated hash base class.

Template Parameters
THash word type
BASEHashTransformation derived class

IteratedHashBase provides an interface for block-based iterated hashes

See also
HashTransformation, MessageAuthenticationCode

Definition at line 27 of file iterhash.h.

Member Typedef Documentation

template<class T, class BASE>
typedef T IteratedHashBase< T, BASE >::HashWordType

Definition at line 30 of file iterhash.h.

Constructor & Destructor Documentation

template<class T, class BASE>
IteratedHashBase< T, BASE >::IteratedHashBase ( )
inline

Construct an IteratedHashBase.

Definition at line 33 of file iterhash.h.

Member Function Documentation

template<class T , class BASE >
byte * IteratedHashBase< T, BASE >::CreateUpdateSpace ( size_t &  size)

Requests space which can be written into by the caller.

Parameters
sizethe requested size of the buffer

The purpose of this method is to help avoid extra memory allocations.

size is an IN and OUT parameter and used as a hint. When the call is made, size is the requested size of the buffer. When the call returns, size is the size of the array returned to the caller.

The base class implementation sets size to 0 and returns NULL.

Note
Some objects, like ArraySink, cannot create a space because its fixed.

Definition at line 75 of file iterhash.cpp.

Here is the call graph for this function:

template<class T, class BASE>
virtual T* IteratedHashBase< T, BASE >::DataBuf ( )
protectedpure virtual
template<class T, class BASE>
T IteratedHashBase< T, BASE >::GetBitCountHi ( ) const
inlineprotected

Definition at line 74 of file iterhash.h.

template<class T, class BASE>
T IteratedHashBase< T, BASE >::GetBitCountLo ( ) const
inlineprotected

Definition at line 75 of file iterhash.h.

template<class T, class BASE>
virtual ByteOrder IteratedHashBase< T, BASE >::GetByteOrder ( ) const
protectedpure virtual
template<class T, class BASE>
void IteratedHashBase< T, BASE >::HashBlock ( const HashWordType input)
inlineprotected

Definition at line 83 of file iterhash.h.

template<class T, class BASE>
virtual void IteratedHashBase< T, BASE >::HashEndianCorrectedBlock ( const HashWordType data)
protectedpure virtual
template<class T, class BASE >
size_t IteratedHashBase< T, BASE >::HashMultipleBlocks ( const T input,
size_t  length 
)
protectedvirtual

Reimplemented in Weak::PanamaHash< B >, and VMAC_Base.

Definition at line 83 of file iterhash.cpp.

Here is the call graph for this function:

template<class T, class BASE>
virtual void IteratedHashBase< T, BASE >::Init ( )
protectedpure virtual
template<class T, class BASE>
unsigned int IteratedHashBase< T, BASE >::OptimalBlockSize ( ) const
inline

Provides the input block size most efficient for this cipher.

Returns
The input block size that is most efficient for the cipher

The base class implementation returns MandatoryBlockSize().

Note
Optimal input length is n * OptimalBlockSize() - GetOptimalBlockSizeUsed() for any n > 0.

Definition at line 40 of file iterhash.h.

template<class T, class BASE>
unsigned int IteratedHashBase< T, BASE >::OptimalDataAlignment ( ) const
inline

Provides input and output data alignment for optimal performance.

Returns
the input data alignment that provides optimal performance

OptimalDataAlignment returns the natural alignment of the hash word.

Definition at line 45 of file iterhash.h.

template<class T , class BASE >
void IteratedHashBase< T, BASE >::PadLastBlock ( unsigned int  lastBlockSize,
byte  padFirst = 0x80 
)
protected

Definition at line 108 of file iterhash.cpp.

Here is the call graph for this function:

template<class T , class BASE >
void IteratedHashBase< T, BASE >::Restart ( )

Restart the hash.

Discards the current state, and restart for a new message

Definition at line 125 of file iterhash.cpp.

template<class T, class BASE>
virtual T* IteratedHashBase< T, BASE >::StateBuf ( )
protectedpure virtual
template<class T , class BASE >
void IteratedHashBase< T, BASE >::TruncatedFinal ( byte digest,
size_t  digestSize 
)

Computes the hash of the current message.

Parameters
digesta pointer to the buffer to receive the hash
digestSizethe size of the truncated digest, in bytes

TruncatedFinal() call Final() and then copies digestSize bytes to digest. The hash is restarted the hash for the next message.

Definition at line 131 of file iterhash.cpp.

Here is the call graph for this function:

template<class T , class BASE >
void IteratedHashBase< T, BASE >::Update ( const byte input,
size_t  length 
)

Updates a hash with additional input.

Parameters
inputthe additional input as a buffer
lengththe size of the buffer, in bytes

Definition at line 12 of file iterhash.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

template<class T, class BASE>
T IteratedHashBase< T, BASE >::m_countHi
private

Definition at line 89 of file iterhash.h.

template<class T, class BASE>
T IteratedHashBase< T, BASE >::m_countLo
private

Definition at line 89 of file iterhash.h.


The documentation for this class was generated from the following files: