Crypto++ 8.2 Free C++ class library of cryptographic schemes

Public Types | Public Member Functions | List of all members
IteratedHashBase< T, BASE > Class Template Referenceabstract

Iterated hash base class. More...

Inheritance diagram for IteratedHashBase< T, BASE >:

## Public Types
typedef T | HashWordType

## Public Member Functions
| IteratedHashBase ()
| Construct an IteratedHashBase.
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...
byte * | CreateUpdateSpace (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...
virtual std::string | AlgorithmProvider () const
| Retrieve the provider of this algorithm. More...

## Detailed Description

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

Iterated hash base class.

Template Parameters

  T | Hash word type
  BASE | HashTransformation derived class

IteratedHashBase provides an interface for block-based iterated hashes

See also
  HashTransformation, MessageAuthenticationCode

Definition at line 38 of file iterhash.h.

## Member Function Documentation

## ◆ OptimalBlockSize()

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 53 of file iterhash.h.

## ◆ OptimalDataAlignment()

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 58 of file iterhash.h.

## ◆ Update()

template<class T , class BASE >

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

Updates a hash with additional input.

Parameters

  input | the additional input as a buffer
  length | the size of the buffer, in bytes

Definition at line 13 of file iterhash.cpp.

## ◆ CreateUpdateSpace()

template<class T , class BASE >

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

Requests space which can be written into by the caller.

Parameters

  size | the 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 85 of file iterhash.cpp.

## ◆ Restart()

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 159 of file iterhash.cpp.

## ◆ TruncatedFinal()

template<class T , class BASE >

void IteratedHashBase< T, BASE >::TruncatedFinal | ( | byte * | digest,
|  | size_t | digestSize
| ) |  |

Computes the hash of the current message.

Parameters

  digest | a pointer to the buffer to receive the hash
  digestSize | the 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 165 of file iterhash.cpp.

## ◆ AlgorithmProvider()

template<class T, class BASE>

virtual std::string IteratedHashBase< T, BASE >::AlgorithmProvider | ( |  | ) | const
| inline virtual

Retrieve the provider of this algorithm.

Returns
  the algorithm provider

The algorithm provider can be a name like "C++", "SSE", "NEON", "AESNI", "ARMv8" and "Power8". C++ is standard C++ code. Other labels, like SSE, usually indicate a specialized implementation using instructions from a higher instruction set architecture (ISA). Future labels may include external hardware like a hardware security module (HSM).

Note
  Provider is not universally implemented yet.

Reimplemented in SHA384, SHA512, SHA224, SHA256, SHA1, Weak::PanamaHash< B >, Tiger, Whirlpool, and VMAC_Base.

Definition at line 94 of file iterhash.h.

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

- iterhash.h
- iterhash.cpp