emsha 1.1.1
A compact HMAC-SHA-256 C++11 library.
|
#include <hmac.h>
Public Member Functions | |
HMAC (const uint8_t *k, uint32_t kl) | |
Construct an HMAC with its initial key. More... | |
EMSHAResult | Reset () override |
Clear any data written to the HMAC. More... | |
EMSHAResult | Update (const std::uint8_t *message, std::uint32_t messageLength) override |
Write data into the context. More... | |
EMSHAResult | Finalise (std::uint8_t *digest) override |
Complete the HMAC computation. More... | |
EMSHAResult | Result (std::uint8_t *digest) override |
Copy the current digest into a destination buffer. More... | |
std::uint32_t | Size () override |
Returns the output size of HMAC-SHA-256. More... | |
~HMAC () | |
HMAC is a keyed hash that can be used to produce an authenticated hash of some data. The HMAC is built on (and uses internally) the SHA256 class; it's helpful to note that faults that occur in the SHA-256 code will be propagated up as the return value from many of the HMAC functions.
emsha::HMAC::HMAC | ( | const uint8_t * | k, |
uint32_t | kl | ||
) |
emsha::HMAC::~HMAC | ( | ) |
When an HMAC context is destroyed, it is reset and the key material is zeroised using the STL fill
function.
|
overridevirtual |
Complete the HMAC computation.
digest | A byte buffer that must be at least Size() in length. |
Implements emsha::Hash.
|
overridevirtual |
Clear any data written to the HMAC.
This is equivalent to constructing a new HMAC, but it preserves the keys.
Implements emsha::Hash.
|
overridevirtual |
Copy the current digest into a destination buffer.
Copy the current digest from the HMAC context into digest
, running Finalise if needed. Once called, the context cannot be updated until the context is reset.
digest | A byte buffer that must be at least Size() in length. |
Implements emsha::Hash.
|
overridevirtual |
Returns the output size of HMAC-SHA-256.
The buffers passed to Update and Finalise should be at least this size.
Implements emsha::Hash.
|
overridevirtual |
Write data into the context.
While there is an upper limit on the size of data that the underlying hash can operate on, this package is designed for small systems that will not approach that level of data (which is on the order of 2 exabytes), so it is not a concern for this library.
message | A byte array containing the message to be written. |
messageLength | The message length, in bytes. |
Implements emsha::Hash.