#include <sha256.h>
A SHA256 context.
Definition at line 28 of file sha256.h.
|
| Context () |
| Construct a SHA256 context. More...
|
|
void | reset () |
| Reset the SHA256 context. More...
|
|
void | update (uint8_t const *buffer, size_t buffer_size) |
| Add data to the SHA256 context. More...
|
|
void | update (const std::string &buffer) |
| Add data to the SHA256 context. More...
|
|
Hash | finalize () |
| Performs the final calculation of the hash and returns the digest (32 byte buffer containing 256bit hash). More...
|
|
◆ Context()
smash::sha256::Context::Context |
( |
| ) |
|
|
inline |
Construct a SHA256 context.
Definition at line 46 of file sha256.h.
void reset()
Reset the SHA256 context.
◆ transform_function()
void smash::sha256::Context::transform_function |
( |
uint8_t const * |
buffer | ) |
|
|
private |
Compress 512-bits.
Definition at line 95 of file sha256.cc.
104 for (i = 0; i < 8; i++) {
109 for (i = 0; i < 16; i++) {
110 LOAD32H(W[i], buffer + (4 * i));
114 for (i = 16; i < 64; i++) {
115 W[i] =
Gamma1(W[i - 2]) + W[i - 7] +
Gamma0(W[i - 15]) + W[i - 16];
119 for (i = 0; i < 64; i++) {
133 for (i = 0; i < 8; i++) {
uint32_t state_[8]
State of the SHA256 hash.
#define Sha256Round(a, b, c, d, e, f, g, h, i)
◆ reset()
void smash::sha256::Context::reset |
( |
| ) |
|
Reset the SHA256 context.
Definition at line 140 of file sha256.cc.
size_t curlen_
Current length of the SHA256 hash.
uint64_t length_
Length of the SHA256 hash.
◆ update() [1/2]
void smash::sha256::Context::update |
( |
uint8_t const * |
buffer, |
|
|
size_t |
buffer_size |
|
) |
| |
Add data to the SHA256 context.
This will process the data and update the internal state of the context. Keep on calling this function until all the data has been added. Then call finalize
to calculate the hash.
Definition at line 153 of file sha256.cc.
160 while (buffer_size > 0) {
void transform_function(uint8_t const *buffer)
Compress 512-bits.
uint8_t buf_[64]
Buffer of the SHA256 hash.
constexpr size_t BLOCK_SIZE
◆ update() [2/2]
void smash::sha256::Context::update |
( |
const std::string & |
buffer | ) |
|
Add data to the SHA256 context.
This will process the data and update the internal state of the context. Keep on calling this function until all the data has been added. Then call finalize
to calculate the hash.
Definition at line 181 of file sha256.cc.
182 update(
reinterpret_cast<const uint8_t*
>(buffer.c_str()), buffer.size());
void update(uint8_t const *buffer, size_t buffer_size)
Add data to the SHA256 context.
◆ finalize()
Hash smash::sha256::Context::finalize |
( |
| ) |
|
Performs the final calculation of the hash and returns the digest (32 byte buffer containing 256bit hash).
After calling this, reset
must be used to reuse the context.
Definition at line 185 of file sha256.cc.
218 for (
int i = 0; i < 8; i++) {
std::array< uint8_t, HASH_SIZE > Hash
A SHA256 hash.
◆ length_
uint64_t smash::sha256::Context::length_ |
|
private |
Length of the SHA256 hash.
Definition at line 31 of file sha256.h.
◆ state_
uint32_t smash::sha256::Context::state_[8] |
|
private |
State of the SHA256 hash.
Definition at line 33 of file sha256.h.
◆ curlen_
size_t smash::sha256::Context::curlen_ |
|
private |
Current length of the SHA256 hash.
Definition at line 35 of file sha256.h.
◆ buf_
uint8_t smash::sha256::Context::buf_[64] |
|
private |
Buffer of the SHA256 hash.
Definition at line 37 of file sha256.h.
The documentation for this class was generated from the following files: