ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | List of all members
Hash Class Referenceabstract

Abstract base class for cryptographic hash algorithms. More...

#include <Hash.h>

Inheritance diagram for Hash:
BLAKE2s SHA1 SHA256

Public Member Functions

 Hash ()
 Constructs a new hash object.
 
virtual ~Hash ()
 Destroys this hash object. More...
 
virtual size_t hashSize () const =0
 Size of the hash result from finalize(). More...
 
virtual size_t blockSize () const =0
 Size of the internal block used by the hash algorithm. More...
 
virtual void reset ()=0
 Resets the hash ready for a new hashing process. More...
 
virtual void update (const void *data, size_t len)=0
 Updates the hash with more data. More...
 
virtual void finalize (void *hash, size_t len)=0
 Finalizes the hashing process and returns the hash. More...
 
virtual void clear ()=0
 Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing process. More...
 

Detailed Description

Abstract base class for cryptographic hash algorithms.

See Also
SHA1, SHA256

Definition at line 29 of file Hash.h.

Constructor & Destructor Documentation

Hash::~Hash ( )
virtual

Destroys this hash object.

Note
Subclasses are responsible for clearing any sensitive data that remains in the hash object when it is destroyed.
See Also
clear()

Definition at line 47 of file Hash.cpp.

Member Function Documentation

size_t Hash::blockSize ( ) const
pure virtual

Size of the internal block used by the hash algorithm.

See Also
update(), hashSize()

Implemented in BLAKE2s, SHA1, and SHA256.

void Hash::clear ( )
pure virtual

Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing process.

See Also
reset()

Implemented in BLAKE2s, SHA1, and SHA256.

void Hash::finalize ( void *  hash,
size_t  len 
)
pure virtual

Finalizes the hashing process and returns the hash.

Parameters
hashThe buffer to return the hash value in.
lenThe length of the hash buffer, normally hashSize().

If len is less than hashSize(), then the hash value will be truncated to the first len bytes. If len is greater than hashSize(), then the remaining bytes will left unchanged.

If finalize() is called again, the same hash value is returned again until the next call to reset() or update().

See Also
reset(), update()

Implemented in BLAKE2s, SHA1, and SHA256.

size_t Hash::hashSize ( ) const
pure virtual

Size of the hash result from finalize().

See Also
finalize(), blockSize()

Implemented in BLAKE2s, SHA1, and SHA256.

void Hash::reset ( )
pure virtual

Resets the hash ready for a new hashing process.

See Also
update(), finalize()

Implemented in BLAKE2s, SHA1, and SHA256.

void Hash::update ( const void *  data,
size_t  len 
)
pure virtual

Updates the hash with more data.

Parameters
dataData to be hashed.
lenNumber of bytes of data to be hashed.

If finalize() has already been called, then calling update() will reset() the hash and start a new hashing process.

See Also
reset(), finalize()

Implemented in BLAKE2s, SHA1, and SHA256.


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