Implements the SHA256 hashfunction, i.e. sha-256. Inherits from SHAx. More...
#include <sha256.hpp>
Public Member Functions | |
void | preprocess (std::vector< uint8_t > initialMessage) |
Parses a vector of bytes and applies to it the transformations specified in the NIST's specification. | |
void | round (unsigned int counter) |
Performs a round over the 16 message bytes contained in M, starting at counter and finishing at counter+"something". In the end, the internal state H is updated to the new value. | |
void | hash (std::vector< uint8_t > initialMessage) |
Performs all the steps necessary to hash the message given on the input. In the end, the internal state H contains the digest of the message. | |
std::vector< uint8_t > | getHash () |
Returns a vector of uint8_t containing the hash. | |
std::string | getType () |
To know which hashfunction it is. | |
uint32_t | getHashLength () |
To know the bitlength of the hash we should expect. |
Private Attributes | |
uint32_t | H [8] |
The internal state; 8 words of 32 bits. It is modified during each call to the round method. | |
std::vector< uint32_t > | M |
The message to hash. | |
uint64_t | l |
The length of the message in bits. | |
32 bits temporary variables | |
uint32_t | a |
uint32_t | b |
uint32_t | c |
uint32_t | d |
uint32_t | e |
uint32_t | f |
uint32_t | g |
uint32_t | h |
Implements the SHA256 hashfunction, i.e. sha-256. Inherits from SHAx.
Definition at line 25 of file sha256.hpp.
|
virtual |
Returns a vector of uint8_t containing the hash.
Reimplemented from cryptoTools::SHAx.
Definition at line 136 of file sha256.cpp.
|
virtual |
To know the bitlength of the hash we should expect.
Reimplemented from cryptoTools::SHAx.
Definition at line 156 of file sha256.cpp.
|
virtual |
To know which hashfunction it is.
Reimplemented from cryptoTools::SHAx.
Definition at line 150 of file sha256.cpp.
|
virtual |
Performs all the steps necessary to hash the message given on the input. In the end, the internal state H contains the digest of the message.
Calls preprocess over its input and then uses a loop over the length of the message to call round on each of its blocks.
initialMessage | A byte vector containing the message to hash. |
Reimplemented from cryptoTools::SHAx.
Definition at line 128 of file sha256.cpp.
|
virtual |
Parses a vector of bytes and applies to it the transformations specified in the NIST's specification.
Once the call to this function is finished, the M attribute is correctly assigned i.e. it contains 32 bits words, the padding and the length of the initial input. The internal state is also initialised.
initialMessage | A byte vector containing the message to hash. |
Reimplemented from cryptoTools::SHAx.
Definition at line 66 of file sha256.cpp.
|
virtual |
Performs a round over the 16 message bytes contained in M, starting at counter and finishing at counter+"something". In the end, the internal state H is updated to the new value.
Reimplemented from cryptoTools::SHAx.
Definition at line 99 of file sha256.cpp.
|
private |
Definition at line 38 of file sha256.hpp.
|
private |
Definition at line 39 of file sha256.hpp.
|
private |
Definition at line 40 of file sha256.hpp.
|
private |
Definition at line 41 of file sha256.hpp.
|
private |
Definition at line 42 of file sha256.hpp.
|
private |
Definition at line 43 of file sha256.hpp.
|
private |
Definition at line 44 of file sha256.hpp.
|
private |
The internal state; 8 words of 32 bits. It is modified during each call to the round method.
Definition at line 32 of file sha256.hpp.
|
private |
Definition at line 45 of file sha256.hpp.
|
private |
The length of the message in bits.
Definition at line 56 of file sha256.hpp.
|
private |
The message to hash.
Definition at line 51 of file sha256.hpp.