emsha 1.1.0
A compact HMAC-SHA-256 C++11 library.
Public Member Functions | List of all members
emsha::Hash Class Referenceabstract

#include <emsha.h>

Inheritance diagram for emsha::Hash:
Inheritance graph
[legend]

Public Member Functions

virtual ~Hash ()=default
 
virtual EMSHAResult Reset ()=0
 Bring the Hash back to its initial state. More...
 
virtual EMSHAResult Update (const std::uint8_t *message, std::uint32_t messageLength)=0
 Write message data into the Hash. More...
 
virtual EMSHAResult Finalise (std::uint8_t *digest)=0
 Carry out any final operations on the Hash. More...
 
virtual EMSHAResult Result (std::uint8_t *digest)=0
 Result transfers out the hash to the argument. More...
 
virtual std::uint32_t Size ()=0
 Return the output size of the Hash. More...
 

Detailed Description

A Hash is an abstract base class supporting concrete classes that produce digests of data.

Constructor & Destructor Documentation

◆ ~Hash()

virtual emsha::Hash::~Hash ( )
virtualdefault

Member Function Documentation

◆ Finalise()

virtual EMSHAResult emsha::Hash::Finalise ( std::uint8_t *  digest)
pure virtual

Carry out any final operations on the Hash.

After a call to finalize, no more data can be written. Additionally, it transfers out the resulting hash into its argument.

Parameters
digestThe buffer to store the hash in.
Returns
An EMSHAResult describing the status of the operation.

Implemented in emsha::HMAC, and emsha::SHA256.

◆ Reset()

virtual EMSHAResult emsha::Hash::Reset ( )
pure virtual

Bring the Hash back to its initial state.

That is, the idea is that

hash->reset();
hash->update(...);
hash->result(...);

is idempotent, assuming the inputs to update and result are constant. The implications of this for a given concrete class should be described in that class's documentation, but in general, it has the effect of preserving any initial state while removing any data written to the Hash via the update method.

Returns
An EMSHAResult describing the status of the operation.

Implemented in emsha::HMAC, and emsha::SHA256.

◆ Result()

virtual EMSHAResult emsha::Hash::Result ( std::uint8_t *  digest)
pure virtual

Result transfers out the hash to the argument.

The Hash must keep enough state for repeated calls to result to work.

Parameters
digestThe buffer to store the hash in.
Returns
An EMSHAResult describing the status of the operation.

Implemented in emsha::HMAC, and emsha::SHA256.

◆ Size()

virtual std::uint32_t emsha::Hash::Size ( )
pure virtual

Return the output size of the Hash.

This is how large the buffers written to by result should be.

Implemented in emsha::HMAC, and emsha::SHA256.

◆ Update()

virtual EMSHAResult emsha::Hash::Update ( const std::uint8_t *  message,
std::uint32_t  messageLength 
)
pure virtual

Write message data into the Hash.

Parameters
messageThe message data to write into the Hash.
messageLengthThe length of the message data.
Returns
An EMSHAResult describing the status of the operation.

Implemented in emsha::HMAC, and emsha::SHA256.


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