Virgil Security Crypto library  1.8.2
List of all members
virgil::crypto::foundation::VirgilHash Class Reference

Provides hashing (message digest) algorithms. More...

#include <VirgilHash.h>

Inheritance diagram for virgil::crypto::foundation::VirgilHash:
virgil::crypto::foundation::asn1::VirgilAsn1Compatible

Public Member Functions

Constructor / Destructor
 VirgilHash ()
 Create object with undefined algorithm. More...
 
virtual ~VirgilHash () throw ()
 Polymorphic destructor.
 
Info

Provide detail information about object.

std::string name () const
 Returns name of the hash function. More...
 
int type () const
 Return underlying hash type. More...
 
Immediate Hashing

This methods can be used to get the message hash immediately.

virgil::crypto::VirgilByteArray hash (const virgil::crypto::VirgilByteArray &bytes) const
 Produce hash. More...
 
Chain Hashing

This methods provide mechanism to hash long message, that can be splitted to a shorter chunks and be processed separately.

void start ()
 Initialize hashing for the new message hash.
 
void update (const virgil::crypto::VirgilByteArray &bytes)
 Update / process message hash. More...
 
virgil::crypto::VirgilByteArray finish ()
 Return final message hash. More...
 
HMAC Immediate Hashing

This methods can be used to get the message HMAC hash immediately.

virgil::crypto::VirgilByteArray hmac (const virgil::crypto::VirgilByteArray &key, const virgil::crypto::VirgilByteArray &bytes) const
 Produce HMAC hash. More...
 
HMAC Chain Hashing

This methods provide mechanism to get HMAC hash of the long message, that can be splitted to a shorter chunks and be processed separately.

void hmacStart (const virgil::crypto::VirgilByteArray &key)
 Initialize HMAC hashing for the new message hash. More...
 
void hmacReset ()
 Reset HMAC hashing for the new message hash.
 
void hmacUpdate (const virgil::crypto::VirgilByteArray &bytes)
 Update / process message HMAC hash. More...
 
virgil::crypto::VirgilByteArray hmacFinish ()
 Return final message HMAC hash. More...
 
Copy constructor / assignment operator
Warning
Copy constructor and assignment operator create copy of the object as it was created by on of the creation methods. All changes in the internal state, that was made after creation, are not copied!
 VirgilHash (const VirgilHash &other)
 
VirgilHashoperator= (const VirgilHash &rhs)
 
VirgilAsn1Compatible implementation
virtual size_t asn1Write (virgil::crypto::foundation::asn1::VirgilAsn1Writer &asn1Writer, size_t childWrittenBytes=0) const
 Write object state to the writer. More...
 
virtual void asn1Read (virgil::crypto::foundation::asn1::VirgilAsn1Reader &asn1Reader)
 Read object state from the reader. More...
 
- Public Member Functions inherited from virgil::crypto::foundation::asn1::VirgilAsn1Compatible
virgil::crypto::VirgilByteArray toAsn1 () const
 Save object state to the ASN.1 structure.
 
void fromAsn1 (const virgil::crypto::VirgilByteArray &asn1)
 Restore object state from the ASN.1 structure.
 
virtual ~VirgilAsn1Compatible () throw ()
 Polymorphic destructor.
 

Static Public Member Functions

Creation methods

Object creation with specific hash function.

static VirgilHash md5 ()
 
static VirgilHash sha256 ()
 
static VirgilHash sha384 ()
 
static VirgilHash sha512 ()
 
static VirgilHash withName (const virgil::crypto::VirgilByteArray &name)
 

Additional Inherited Members

- Protected Member Functions inherited from virgil::crypto::foundation::asn1::VirgilAsn1Compatible
virtual void checkAsn1ParamNotEmpty (const virgil::crypto::VirgilByteArray &param, const char *paramName=0) const
 If given parameter is empty exception will be thrown. More...
 

Detailed Description

Provides hashing (message digest) algorithms.

Constructor & Destructor Documentation

virgil::crypto::foundation::VirgilHash::VirgilHash ( )

Create object with undefined algorithm.

Warning
SHOULD be used in conjunction with VirgilAsn1Compatible interface, i.e. VirgilHash hash = VirgilHash().fromAsn1(asn1);

Member Function Documentation

virtual void virgil::crypto::foundation::VirgilHash::asn1Read ( virgil::crypto::foundation::asn1::VirgilAsn1Reader asn1Reader)
virtual

Read object state from the reader.

Parameters
asn1Readerreader payloaded with ASN.1 to be read.

Implements virgil::crypto::foundation::asn1::VirgilAsn1Compatible.

virtual size_t virgil::crypto::foundation::VirgilHash::asn1Write ( virgil::crypto::foundation::asn1::VirgilAsn1Writer asn1Writer,
size_t  childWrittenBytes = 0 
) const
virtual

Write object state to the writer.

Parameters
asn1Writerwriter that should be payloaded by subclasses.
childWrittenBytescount of bytes that was written by subclasses.
Returns
Writen bytes count.

Implements virgil::crypto::foundation::asn1::VirgilAsn1Compatible.

virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::finish ( )

Return final message hash.

Returns
Message hash processed by series of update() method.
See also
start()
update()
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::hash ( const virgil::crypto::VirgilByteArray &  bytes) const

Produce hash.

Process the given message immediately and return it's hash.

Parameters
bytes- message to be hashed.
Returns
Hash of the given message.
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::hmac ( const virgil::crypto::VirgilByteArray &  key,
const virgil::crypto::VirgilByteArray &  bytes 
) const

Produce HMAC hash.

Process the given message immediately and return it's HMAC hash.

Parameters
key- secret key.
bytes- message to be hashed.
Returns
HMAC hash of the given message.
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::hmacFinish ( )

Return final message HMAC hash.

Returns
Message HMAC hash processed by series of hmacUpdate() method.
See also
hmacStart()
hmacReset()
hmacUpdate()
void virgil::crypto::foundation::VirgilHash::hmacStart ( const virgil::crypto::VirgilByteArray &  key)

Initialize HMAC hashing for the new message hash.

Parameters
key- secret key.
void virgil::crypto::foundation::VirgilHash::hmacUpdate ( const virgil::crypto::VirgilByteArray &  bytes)

Update / process message HMAC hash.

This method MUST be used after hmacStart() or hmacReset() methods only. This method MAY be called multiple times to process long message splitted to a shorter chunks.

Parameters
bytes- message to be hashed.
See also
hmacStart()
hmacReset()
std::string virgil::crypto::foundation::VirgilHash::name ( ) const

Returns name of the hash function.

Returns
Name of the hash function.
int virgil::crypto::foundation::VirgilHash::type ( ) const

Return underlying hash type.

Note
Used for internal purposes only
void virgil::crypto::foundation::VirgilHash::update ( const virgil::crypto::VirgilByteArray &  bytes)

Update / process message hash.

This method MUST be used after start() method only. This method MAY be called multiple times to process long message splitted to a shorter chunks.

Parameters
bytes- message to be hashed.
See also
start()

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