AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::crypto::Hash< O, B > Class Template Referenceabstract

Hash algorithm abstract class. More...

#include <hash.hpp>

+ Inheritance diagram for anch::crypto::Hash< O, B >:
+ Collaboration diagram for anch::crypto::Hash< O, B >:

Public Member Functions

virtual const std::array< uint8_t, O > & digest () const =0
 
const std::array< uint8_t, O > & digest (const std::string &data)
 
template<std::size_t N>
const std::array< uint8_t, O > & digest (const std::array< uint8_t, N > &data)
 
const std::array< uint8_t, O > & digest (const uint8_t *data, std::size_t len)
 
const std::array< uint8_t, O > & digest (std::istream &stream)
 

Static Public Member Functions

static constexpr std::size_t getOutputSize ()
 
static constexpr std::size_t getBlockSize ()
 

Protected Member Functions

virtual void reset ()=0
 
virtual void addData (const uint8_t *data, std::size_t len)=0
 
virtual void finalize ()=0
 

Protected Attributes

std::array< uint8_t, O > * _digest
 

Detailed Description

template<std::size_t O, std::size_t B>
class anch::crypto::Hash< O, B >

Hash algorithm abstract class.

N is the hash output size in bytes.
B is the hash block size in bytes (used in HMAC algorithm).

Author
Vincent Lachenal

Member Function Documentation

◆ addData()

template<std::size_t O, std::size_t B>
virtual void anch::crypto::Hash< O, B >::addData ( const uint8_t * data,
std::size_t len )
protectedpure virtual

Compute hash for data with the current hash

Parameters
dataThe data to add
lenThe data length

Implemented in anch::crypto::MD5, and anch::crypto::SHA1.

◆ digest() [1/5]

template<std::size_t O, std::size_t B>
virtual const std::array< uint8_t, O > & anch::crypto::Hash< O, B >::digest ( ) const
pure virtual

Get the hash result

Returns
the hash result

Implemented in anch::crypto::MD5, anch::crypto::SHA1, and anch::crypto::SHA2< O, B, W, R, I >.

◆ digest() [2/5]

template<std::size_t O, std::size_t B>
template<std::size_t N>
const std::array< uint8_t, O > & anch::crypto::Hash< O, B >::digest ( const std::array< uint8_t, N > & data)

Reset current hash context and compute hash for string

Parameters
datathe string to hash
Returns
the hash result

◆ digest() [3/5]

template<std::size_t O, std::size_t B>
template const std::array< uint8_t, 64 > & anch::crypto::Hash< O, B >::digest ( const std::string & data)

Reset current hash context and compute hash for string

Parameters
datathe string to hash
Returns
the hash result

◆ digest() [4/5]

template<std::size_t O, std::size_t B>
const std::array< uint8_t, O > & anch::crypto::Hash< O, B >::digest ( const uint8_t * data,
std::size_t len )

Reset current hash context and compute hash for string

Parameters
datathe string to hash
lenthe data length
Returns
the hash result

◆ digest() [5/5]

template<std::size_t O, std::size_t B>
template const std::array< uint8_t, 64 > & anch::crypto::Hash< O, B >::digest ( std::istream & stream)

Reset current hash context and compute hash for stream

Parameters
streamthe stream to hash
Returns
the hash result

◆ finalize()

template<std::size_t O, std::size_t B>
virtual void anch::crypto::Hash< O, B >::finalize ( )
protectedpure virtual

Reset hash context

Implemented in anch::crypto::MD5, and anch::crypto::SHA1.

◆ getBlockSize()

template<std::size_t O, std::size_t B>
static constexpr std::size_t anch::crypto::Hash< O, B >::getBlockSize ( )
inlinestaticconstexpr

Hash block size getter

Returns
the block size

◆ getOutputSize()

template<std::size_t O, std::size_t B>
static constexpr std::size_t anch::crypto::Hash< O, B >::getOutputSize ( )
inlinestaticconstexpr

Hash output size getter

Returns
the output size

◆ reset()

template<std::size_t O, std::size_t B>
virtual void anch::crypto::Hash< O, B >::reset ( )
protectedpure virtual

Reset hash context

Implemented in anch::crypto::MD5, and anch::crypto::SHA1.

Member Data Documentation

◆ _digest

template<std::size_t O, std::size_t B>
std::array<uint8_t,O>* anch::crypto::Hash< O, B >::_digest
protected

Digest


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