Virgil Security Crypto library
2.0.7
|
Provides hashing (message digest) algorithms. More...
#include <VirgilHash.h>
Public Types | |
enum | Algorithm { Algorithm::MD5, Algorithm::SHA1, Algorithm::SHA224, Algorithm::SHA256, Algorithm::SHA384, Algorithm::SHA512 } |
Enumerates possible Hash algorithms. More... | |
Public Member Functions | |
Constructor / Destructor | |
VirgilHash () | |
Create object with undefined algorithm. More... | |
VirgilHash (Algorithm alg) | |
Create object with specific algorithm type. | |
VirgilHash (const std::string &name) | |
Create object with given algorithm name. More... | |
VirgilHash (const char *name) | |
Create object with given algorithm name. More... | |
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 &data) 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 &data) |
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 &data) 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 &data) |
Update / process message HMAC hash. More... | |
virgil::crypto::VirgilByteArray | hmacFinish () |
Return final message HMAC hash. More... | |
VirgilAsn1Compatible implementation | |
size_t | asn1Write (virgil::crypto::foundation::asn1::VirgilAsn1Writer &asn1Writer, size_t childWrittenBytes=0) const override |
Write object state to the writer. More... | |
void | asn1Read (virgil::crypto::foundation::asn1::VirgilAsn1Reader &asn1Reader) override |
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 () noexcept |
Polymorphic destructor. | |
Additional Inherited Members | |
Protected Member Functions inherited from virgil::crypto::foundation::asn1::VirgilAsn1Compatible | |
virtual void | checkRequiredField (const VirgilByteArray ¶m) const |
If given parameter is empty exception will be thrown. More... | |
Provides hashing (message digest) algorithms.
virgil::crypto::foundation::VirgilHash::VirgilHash | ( | ) |
Create object with undefined algorithm.
|
explicit |
Create object with given algorithm name.
|
explicit |
Create object with given algorithm name.
|
overridevirtual |
Read object state from the reader.
asn1Reader | reader payloaded with ASN.1 to be read. |
Implements virgil::crypto::foundation::asn1::VirgilAsn1Compatible.
|
overridevirtual |
Write object state to the writer.
asn1Writer | writer that should be payloaded by subclasses. |
childWrittenBytes | count of bytes that was written by subclasses. |
Implements virgil::crypto::foundation::asn1::VirgilAsn1Compatible.
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::finish | ( | ) |
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::hash | ( | const virgil::crypto::VirgilByteArray & | data | ) | const |
Produce hash.
Process the given message immediately and return it's hash.
data | - message to be hashed. |
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::hmac | ( | const virgil::crypto::VirgilByteArray & | key, |
const virgil::crypto::VirgilByteArray & | data | ||
) | const |
Produce HMAC hash.
Process the given message immediately and return it's HMAC hash.
key | - secret key. |
data | - message to be hashed. |
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilHash::hmacFinish | ( | ) |
Return final message HMAC hash.
void virgil::crypto::foundation::VirgilHash::hmacStart | ( | const virgil::crypto::VirgilByteArray & | key | ) |
Initialize HMAC hashing for the new message hash.
key | - secret key. |
void virgil::crypto::foundation::VirgilHash::hmacUpdate | ( | const virgil::crypto::VirgilByteArray & | data | ) |
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.
data | - message to be hashed. |
std::string virgil::crypto::foundation::VirgilHash::name | ( | ) | const |
Returns name of the hash function.
int virgil::crypto::foundation::VirgilHash::type | ( | ) | const |
Return underlying hash type.
void virgil::crypto::foundation::VirgilHash::update | ( | const virgil::crypto::VirgilByteArray & | data | ) |