SHA3-256 hash algorithm.
More...
#include <SHA3.h>
|
| SHA3_256 () |
| Constructs a new SHA3-256 hash object.
|
|
virtual | ~SHA3_256 () |
| Destroys this hash object after clearing sensitive information.
|
|
size_t | hashSize () const |
| Size of the hash result from finalize(). More...
|
|
size_t | blockSize () const |
| Size of the internal block used by the hash algorithm. More...
|
|
void | reset () |
| Resets the hash ready for a new hashing process. More...
|
|
void | update (const void *data, size_t len) |
| Updates the hash with more data. More...
|
|
void | finalize (void *hash, size_t len) |
| Finalizes the hashing process and returns the hash. More...
|
|
void | clear () |
| Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing process. More...
|
|
void | resetHMAC (const void *key, size_t keyLen) |
| Resets the hash ready for a new HMAC hashing process. More...
|
|
void | finalizeHMAC (const void *key, size_t keyLen, void *hash, size_t hashLen) |
| Finalizes the HMAC hashing process and returns the hash. More...
|
|
| Hash () |
| Constructs a new hash object.
|
|
virtual | ~Hash () |
| Destroys this hash object. More...
|
|
|
static const size_t | HASH_SIZE = 32 |
| Constant for the size of the hash output of SHA3-256.
|
|
static const size_t | BLOCK_SIZE = 136 |
| Constant for the block size of SHA3-256.
|
|
|
void | formatHMACKey (void *block, const void *key, size_t len, uint8_t pad) |
| Formats a HMAC key into a block. More...
|
|
SHA3-256 hash algorithm.
Reference: http://en.wikipedia.org/wiki/SHA-3
- See also
- SHA3_512
Definition at line 29 of file SHA3.h.
◆ blockSize()
size_t SHA3_256::blockSize |
( |
| ) |
const |
|
virtual |
◆ clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing process.
- See also
- reset()
Implements Hash.
Definition at line 88 of file SHA3.cpp.
◆ finalize()
void SHA3_256::finalize |
( |
void * |
hash, |
|
|
size_t |
len |
|
) |
| |
|
virtual |
Finalizes the hashing process and returns the hash.
- Parameters
-
hash | The buffer to return the hash value in. |
len | The length of the hash buffer, normally hashSize(). |
If len is less than hashSize(), then the hash value will be truncated to the first len bytes. If len is greater than hashSize(), then the remaining bytes will left unchanged.
If finalize() is called again, then the returned hash value is undefined. Call reset() first to start a new hashing process.
- See also
- reset(), update(), finalizeHMAC()
Implements Hash.
Definition at line 81 of file SHA3.cpp.
◆ finalizeHMAC()
void SHA3_256::finalizeHMAC |
( |
const void * |
key, |
|
|
size_t |
keyLen, |
|
|
void * |
hash, |
|
|
size_t |
hashLen |
|
) |
| |
|
virtual |
Finalizes the HMAC hashing process and returns the hash.
- Parameters
-
key | Points to the HMAC key for the hashing process. The contents of this array must be identical to the value passed to resetHMAC(). |
keyLen | Size of the HMAC key in bytes. |
hash | The buffer to return the hash value in. |
hashLen | The length of the hash buffer, normally hashSize(). |
- See also
- resetHMAC(), finalize()
Implements Hash.
Definition at line 98 of file SHA3.cpp.
◆ hashSize()
size_t SHA3_256::hashSize |
( |
| ) |
const |
|
virtual |
◆ reset()
◆ resetHMAC()
void SHA3_256::resetHMAC |
( |
const void * |
key, |
|
|
size_t |
keyLen |
|
) |
| |
|
virtual |
Resets the hash ready for a new HMAC hashing process.
- Parameters
-
key | Points to the HMAC key for the hashing process. |
keyLen | Size of the HMAC key in bytes. |
The following example computes a HMAC over a series of data blocks with a specific key:
hash.resetHMAC(key, sizeof(key));
hash.update(data1, sizeof(data1));
hash.update(data2, sizeof(data2));
...
hash.update(dataN, sizeof(dataN));
hash.finalizeHMAC(key, sizeof(key), hmac, sizeof(hmac));
The same key must be passed to both resetHMAC() and finalizeHMAC().
- See also
- finalizeHMAC(), reset()
Implements Hash.
Definition at line 93 of file SHA3.cpp.
◆ update()
void SHA3_256::update |
( |
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
|
virtual |
Updates the hash with more data.
- Parameters
-
data | Data to be hashed. |
len | Number of bytes of data to be hashed. |
If finalize() has already been called, then the behavior of update() will be undefined. Call reset() first to start a new hashing process.
- See also
- reset(), finalize()
Implements Hash.
Definition at line 76 of file SHA3.cpp.
The documentation for this class was generated from the following files: