emsha 1.1.0
A compact HMAC-SHA-256 C++11 library.
|
#include <sha256.h>
Public Member Functions | |
SHA256 () | |
A SHA256 context does not need any special construction. More... | |
~SHA256 () | |
EMSHAResult | Reset () override |
Clear the internal state of the SHA256 context, returning it to its initial state. More... | |
EMSHAResult | Update (const std::uint8_t *message, std::uint32_t messageLength) override |
Writes data into the SHA256. More... | |
EMSHAResult | Finalise (std::uint8_t *digest) override |
Complete the digest. More... | |
EMSHAResult | Result (std::uint8_t *digest) override |
Copy the result from the SHA-256 context into the buffer pointed to by d, running Finalise if needed. Once called, the context cannot be updated until the context is reset. More... | |
std::uint32_t | Size () override |
Returns the output size of SHA-256. More... | |
emsha::SHA256::SHA256 | ( | ) |
A SHA256 context does not need any special construction.
It can be declared and immediately start being used.
emsha::SHA256::~SHA256 | ( | ) |
The SHA256 destructor will clear out its internal message buffer; all the members are local and not resource handles, so cleanup is minimal.
|
overridevirtual |
Complete the digest.
Once this method is called, the context cannot be updated unless the context is reset.
digest | byte buffer that must be at least SHA256.size() in length. |
Implements emsha::Hash.
|
overridevirtual |
Clear the internal state of the SHA256 context, returning it to its initial state.
Implements emsha::Hash.
|
overridevirtual |
Copy the result from the SHA-256 context into the buffer pointed to by d, 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 SHA256.size() in length. |
Implements emsha::Hash.
|
overridevirtual |
Returns the output size of SHA-256.
The buffers passed to Update and Finalise should be at least this size.
Implements emsha::Hash.
|
overridevirtual |
Writes data into the SHA256.
While there is an upper limit on the size of data that SHA-256 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 thought to be a concern.
message | A byte array containing the message to be written. It must not be NULL (unless the message length is zero). |
messageLength | The message length, in bytes. |
Implements emsha::Hash.