scclib
Stable Cloud Computing C++ Library
Public Member Functions | Static Public Member Functions | List of all members
scc::crypto::Hmac Class Reference

Hmac, aka hash-based message authentication code. More...

#include <hash.h>

Public Member Functions

 Hmac (const void *, int, Hash::Algorithm)
 Construct an hmac. More...
 
 Hmac (const std::vector< char > &key, Hash::Algorithm alg)
 Construct an hmac. More...
 
 Hmac (const std::string &key, Hash::Algorithm alg)
 Construct an hmac. More...
 
 Hmac (const Hmac &)=delete
 
Hmacoperator= (const Hmac &)=delete
 
 Hmac (Hmac &&other)
 Move constructor. More...
 
Hmacoperator= (Hmac &&other)
 Move assign. More...
 
void init (const void *, int)
 Initialize the hmac with a new key. More...
 
void init (std::vector< char > &v)
 Initialize the hmac with a new key vector.
 
void reset ()
 Reset the hmac, using the same key.
 
void update (const void *, int)
 Update the hmac with new data.
 
void update (const std::vector< char > &v)
 Update the hmac with new data.
 
void update (const std::string &v)
 
int final (void *, int)
 Calculate the final hmac value. More...
 
int final (std::vector< char > &v)
 Calculate the final hmac value. More...
 
int alg () const
 Hmac algorithm. More...
 
int size () const
 Hmac size.
 

Static Public Member Functions

static bool supported (int)
 Test if an algorithm type is supported.
 

Detailed Description

Hmac, aka hash-based message authentication code.

https://tools.ietf.org/html/rfc2104

Streaming class allows updates of the hash and calculation of a final result.

Examples
scclib/crypto/unittest/hash_digest.cc.

Definition at line 264 of file hash.h.

Constructor & Destructor Documentation

◆ Hmac() [1/4]

scc::crypto::Hmac::Hmac ( const void *  ,
int  ,
Hash::Algorithm   
)

Construct an hmac.

Parameters
keykey to set into the hmac
lenlength of key
hash_alghash algorithm,
See also
Hash::Algorithm

◆ Hmac() [2/4]

scc::crypto::Hmac::Hmac ( const std::vector< char > &  key,
Hash::Algorithm  alg 
)
inline

Construct an hmac.

Parameters
keykey to set into the hmac
hash_alghash algorithm,
See also
Hash::Algorithm

Definition at line 279 of file hash.h.

◆ Hmac() [3/4]

scc::crypto::Hmac::Hmac ( const std::string &  key,
Hash::Algorithm  alg 
)
inline

Construct an hmac.

Parameters
keykey to set into the hmac
hash_alghash algorithm,
See also
Hash::Algorithm

Definition at line 284 of file hash.h.

◆ Hmac() [4/4]

scc::crypto::Hmac::Hmac ( Hmac &&  other)

Move constructor.

Original hmac will throw an exception if operations are attempted.

Member Function Documentation

◆ alg()

int scc::crypto::Hmac::alg ( ) const
inline

Hmac algorithm.

See also
Hash::Algorithm

Definition at line 337 of file hash.h.

◆ final() [1/2]

int scc::crypto::Hmac::final ( std::vector< char > &  v)
inline

Calculate the final hmac value.

Return size written.

Definition at line 330 of file hash.h.

◆ final() [2/2]

int scc::crypto::Hmac::final ( void *  ,
int   
)

Calculate the final hmac value.

Reset the hmac, using the same key.

Parameters
locLocation to write final hash value
lenAvailable buffer size, should be >= size required by hash.
Returns
Size written
Examples
scclib/crypto/unittest/hash_digest.cc.

◆ init()

void scc::crypto::Hmac::init ( const void *  ,
int   
)

Initialize the hmac with a new key.

Parameters
keykey to set into the hmac
lenlength of key

◆ operator=()

Hmac& scc::crypto::Hmac::operator= ( Hmac &&  other)

Move assign.

Original hmac will throw an exception if operations are attempted.


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