Base class for all hash functions.
More...
#include <tsHash.h>
|
virtual | ~Hash () |
| Virtual destructor.
|
|
virtual bool | add (const void *data, size_t size) |
| Add some part of the message to hash.
|
|
virtual bool | getHash (void *hash, size_t bufsize, size_t *retsize=nullptr) |
| Get the resulting hash value.
|
|
bool | hash (const void *data, size_t data_size, ByteBlock &hash) |
| Compute a hash in one operation.
|
|
bool | hash (const void *data, size_t data_size, void *hash, size_t hash_maxsize, size_t *hash_retsize=nullptr) |
| Compute a hash in one operation.
|
|
size_t | hashSize () const |
| Size in bytes of the resulting hash.
|
|
virtual bool | init () |
| Reinitialize the computation of the hash.
|
|
UString | name () const |
| Algorithm name (informational only).
|
|
|
| Hash (const UChar *name, size_t hash_size) |
| Constructor for subclasses.
|
|
virtual void | getAlgorithm (::BCRYPT_ALG_HANDLE &algo, size_t &length) const |
| Get the algorithm handle and subobject size, when the subclass uses Microsoft BCrypt library.
|
|
virtual const EVP_MD_CTX * | referenceContext () const |
| Get reference hash context, when the subclass uses OpenSSL.
|
|
Base class for all hash functions.
◆ Hash()
ts::Hash::Hash |
( |
const UChar * |
name, |
|
|
size_t |
hash_size |
|
) |
| |
|
protected |
Constructor for subclasses.
- Parameters
-
[in] | name | Algorithm name. |
[in] | hash_size | Size in bytes of the hash value. |
◆ name()
Algorithm name (informational only).
- Returns
- The algorithm name.
◆ hashSize()
size_t ts::Hash::hashSize |
( |
| ) |
const |
|
inline |
Size in bytes of the resulting hash.
- Returns
- The size in bytes of the resulting hash.
◆ init()
virtual bool ts::Hash::init |
( |
| ) |
|
|
virtual |
Reinitialize the computation of the hash.
- Returns
- True on success, false on error.
◆ add()
virtual bool ts::Hash::add |
( |
const void * |
data, |
|
|
size_t |
size |
|
) |
| |
|
virtual |
Add some part of the message to hash.
Can be called several times.
- Parameters
-
[in] | data | Address of message part. |
[in] | size | Size in bytes of message part. |
- Returns
- True on success, false on error.
◆ getHash()
virtual bool ts::Hash::getHash |
( |
void * |
hash, |
|
|
size_t |
bufsize, |
|
|
size_t * |
retsize = nullptr |
|
) |
| |
|
virtual |
Get the resulting hash value.
- Parameters
-
[out] | hash | Address of returned hash buffer. |
[in] | bufsize | Size in bytes of hash buffer. |
[out] | retsize | Address of an integer receiving the actual returned hash size. Can be a null pointer (ignored). |
- Returns
- True on success, false on error.
◆ hash() [1/2]
bool ts::Hash::hash |
( |
const void * |
data, |
|
|
size_t |
data_size, |
|
|
void * |
hash, |
|
|
size_t |
hash_maxsize, |
|
|
size_t * |
hash_retsize = nullptr |
|
) |
| |
Compute a hash in one operation.
Same in init() + add() + getHash().
- Parameters
-
[in] | data | Address of message to hash. |
[in] | data_size | Size in bytes of message to hash. |
[out] | hash | Address of returned hash buffer. |
[in] | hash_maxsize | Size in bytes of hash buffer. |
[out] | hash_retsize | Address of an integer receiving the actual returned hash size. Can be a null pointer (ignored). |
- Returns
- True on success, false on error.
◆ hash() [2/2]
bool ts::Hash::hash |
( |
const void * |
data, |
|
|
size_t |
data_size, |
|
|
ByteBlock & |
hash |
|
) |
| |
Compute a hash in one operation.
Same in init() + add() + getHash().
- Parameters
-
[in] | data | Address of message to hash. |
[in] | data_size | Size in bytes of message to hash. |
[out] | hash | Returned hash buffer. |
- Returns
- True on success, false on error.
◆ getAlgorithm()
virtual void ts::Hash::getAlgorithm |
( |
::BCRYPT_ALG_HANDLE & |
algo, |
|
|
size_t & |
length |
|
) |
| const |
|
protectedvirtual |
Get the algorithm handle and subobject size, when the subclass uses Microsoft BCrypt library.
- Parameters
-
[out] | algo | Handle to hash algorithm. |
[out] | length | Length in bytes of the subobject to allocate. |
Reimplemented in ts::SHA1, ts::SHA256, and ts::SHA512.
◆ referenceContext()
virtual const EVP_MD_CTX * ts::Hash::referenceContext |
( |
| ) |
const |
|
protectedvirtual |
Get reference hash context, when the subclass uses OpenSSL.
- Returns
- Reference EVP hash context. To be copied into each new hash object.
The documentation for this class was generated from the following file: