# class Hasher | An abstract hashing class. More...
Contains pure virtuals
Full name | `TelEngine::Hasher`
Definition | `#include <yateclass.h>`
Inherited by | MD5, SHA1, SHA256
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- virtual ~Hasher ()
- virtual void clear ()
- virtual void finalize ()
- virtual const unsigned char* rawDigest ()
- inline const String& hexDigest ()
- inline bool update (const void* buf, unsigned int len)
- inline bool update (const DataBlock& data)
- inline bool update (const String& str)
- inline Hasher& operator<< (const String& value)
- inline Hasher& operator<< (const DataBlock& data)
- Hasher& operator<< (const char* value)
- bool hmacStart (DataBlock& opad, const void* key, unsigned int keyLen)
- inline bool hmacStart (DataBlock& opad, const DataBlock& key)
- inline bool hmacStart (DataBlock& opad, const String& key)
- bool hmacFinal (const DataBlock& opad)
- bool hmac (const void* key, unsigned int keyLen, const void* msg, unsigned int msgLen)
- inline bool hmac (const DataBlock& key, const DataBlock& msg)
- inline bool hmac (const String& key, const String& msg)
- virtual unsigned int hashLength () const
- virtual unsigned int hmacBlockSize () const

#### Protected Methods

- inline Hasher ()
- virtual bool updateInternal (const void* buf, unsigned int len)

#### Protected Members

- void* m_private
- String m_hex

## Detailed Description

Abstract base class representing a hash calculator

~Hasher () | ### ~Hasher

[virtual]

Destroy the instance, free allocated memory

void clear () | ### clear

[pure virtual]

Clear the digest and prepare for reuse

void finalize () | ### finalize

[pure virtual]

Finalize the digest computation, make result ready. Subsequent calls to update() will fail

const unsigned char* rawDigest () | ### rawDigest

[pure virtual]

Returns a pointer to the raw 16-byte binary value of the message digest. The digest is finalized if if wasn't already

Returns: Pointer to the raw digest data or NULL if some error occured

inline const String& hexDigest () | ### hexDigest

Returns the standard hexadecimal representation of the message digest. The digest is finalized if if wasn't already

Returns: A String which holds the hex digest or a null one if some error occured

inline bool update (const void* buf, unsigned int len) | ### update

Update the digest from a buffer of data

Parameters:

buf | Pointer to the data to be included in digest
len | Length of data in the buffer

Returns: True if success, false if finalize() was already called

inline bool update (const DataBlock& data) | ### update

Update the digest from the content of a DataBlock

Parameters:

data | Data to be included in digest

Returns: True if success, false if finalize() was already called

inline bool update (const String& str) | ### update

Update the digest from the content of a String

Parameters:

str | String to be included in digest

Returns: True if success, false if finalize() was already called

inline Hasher& operator<< (const String& value) | ### operator<<

Digest updating operator for Strings

Parameters:

value | String to be included in digest

inline Hasher& operator<< (const DataBlock& data) | ### operator<<

Digest updating operator for DataBlocks

Parameters:

data | Data to be included in digest

Hasher& operator<< (const char* value) | ### operator<<

Digest updating operator for C strings

Parameters:

value | String to be included in digest

bool hmacStart (DataBlock& opad, const void* key, unsigned int keyLen) | ### hmacStart

Start a HMAC calculation, initialize the hash and the outer pad

Parameters:

opad | Outer pad to be filled from key
key | Secret key
keyLen | Secret key length

Returns: True if hash and outer pad were successfully initialized

inline bool hmacStart (DataBlock& opad, const DataBlock& key) | ### hmacStart

Start a HMAC calculation, initialize the hash and the outer pad

Parameters:

opad | Outer pad to be filled from key
key | Secret key

Returns: True if hash and outer pad were successfully initialized

inline bool hmacStart (DataBlock& opad, const String& key) | ### hmacStart

Start a HMAC calculation, initialize the hash and the outer pad

Parameters:

opad | Outer pad to be filled from key
key | Secret key string

Returns: True if hash and outer pad were successfully initialized

bool hmacFinal (const DataBlock& opad) | ### hmacFinal

Finalize a HMAC calculation with this hash

Parameters:

opad | Outer pad as filled by hmacStart

Returns: True on success, HMAC result is left in hasher

bool hmac (const void* key, unsigned int keyLen, const void* msg, unsigned int msgLen) | ### hmac

Compute a Message Authentication Code with this hash

Parameters:

key | Secret key
keyLen | Secret key length
msg | Message to authenticate
msgLen | Message length

Returns: True if HMAC was computed correctly, result is left in hasher

inline bool hmac (const DataBlock& key, const DataBlock& msg) | ### hmac

Compute a Message Authentication Code with this hash

Parameters:

key | Secret key
msg | Message to authenticate

Returns: True if HMAC was computed correctly, result is left in hasher

inline bool hmac (const String& key, const String& msg) | ### hmac

Compute a Message Authentication Code with this hash

Parameters:

key | Secret key string
msg | Message string to authenticate

Returns: True if HMAC was computed correctly, result is left in hasher

unsigned int hashLength () | ### hashLength

[const pure virtual]

Return the length of the raw binary digest

Returns: Length of the digest in octets

unsigned int hmacBlockSize () | ### hmacBlockSize

[const virtual]

Return the size of the block used in HMAC calculations

Returns: HMAC block size in octets, usually 64

inline Hasher () | ### Hasher

[protected]

Default constructor

bool updateInternal (const void* buf, unsigned int len) | ### updateInternal

[protected pure virtual]

Update the digest from a buffer of data

Parameters:

buf | Pointer to the data to be included in digest
len | Length of data in the buffer

Returns: True if success, false if finalize() was already called

void* m_private | ### m_private

[protected]

String m_hex | ### m_hex

[protected]

Generated by: paulc on bussard on Fri May 8 12:37:22 2015, using kdoc 2.0a54.