SHA1 / SHA256 and HMAC-SHA1 / HMAC-SHA256 Hash library
SHA1 / SHA256 and HMAC-SHA1 / HMACSHA256 Hash library
|
#include <sha256.h>
Classes | |
union | _buffer |
union | _state |
Public Member Functions | |
void | init (void) |
void | initHmac (const uint8_t *secret, int secretLength) |
uint8_t * | result (void) |
uint8_t * | resultHmac (void) |
virtual size_t | write (uint8_t) |
size_t | write_L (const char *str) |
size_t | write_L (const uint8_t *buffer, size_t size) |
size_t | print (const char *str) |
double | millis () |
virtual size_t | write (uint8_t) |
Private Member Functions | |
void | pad () |
void | addUncounted (uint8_t data) |
void | hashBlock () |
uint32_t | ror32 (uint32_t number, uint8_t bits) |
Private Attributes | |
_buffer | buffer |
uint8_t | bufferOffset |
_state | state |
uint32_t | byteCount |
uint8_t | keyBuffer [BLOCK_LENGTH] |
uint8_t | innerHash [HASH_LENGTH] |
timeval | tv |
void Sha256Class::init | ( | void | ) |
Initialized the SHA256 process Set the counter and buffers
void Sha256Class::initHmac | ( | const uint8_t * | secret, |
int | secretLength | ||
) |
initializes the HMAC process for SHA-256
secret | The key to be used |
secretLength | The length of the key |
uint8_t * Sha256Class::result | ( | void | ) |
Pads the last block and finalizes the hash.
uint8_t * Sha256Class::resultHmac | ( | void | ) |
Pads the last block and finalizes the hash.
|
virtual |
Adds data to the buffer. Also increases the byteCount variable
size_t Sha256Class::write_L | ( | const char * | str | ) |
Adds the str to the buffer Calles function in order to add the data into the buffer.
str | The string to be added |
size_t Sha256Class::write_L | ( | const uint8_t * | buffer, |
size_t | size | ||
) |
Adds the string to the buffer Calles function in order to add the data into the buffer.
*buffer | The string to be added |
*size | The size of the string |
size_t Sha256Class::print | ( | const char * | str | ) |
Adds the str to the buffer Calles functions in order to add the data into the buffer.
str | The string to be added |
double Sha256Class::millis | ( | ) |
used in linux in order to retrieve the time in milliseconds.
|
virtual |
Adds data to the buffer. Also increases the byteCount variable
|
private |
Implement SHA-1 padding (fips180-2 ยง5.1.1). Pad with 0x80 followed by 0x00 until the end of the block
|
private |
adds the data to the buffer
data |
|
private |
Hash a single block of data
|
private |
ror32 - rotate a 32-bit value left
number | value to rotate |
bits | bits to roll |
|
private |
hold the buffer for the hashing process
|
private |
indicates the position on the buffer
|
private |
identical structure with buffer
|
private |
Byte counter in order to initialize the hash process for a block
|
private |
Hold the key for the HMAC process
|
private |
holds the inner hash for the HMAC process
|
private |
hold the time value on linux machines (ex Raspberry Pi)