GNU libmicrohttpd
0.9.72
|
Calculation of SHA-256 digest as defined in FIPS PUB 180-4 (2015) More...
Go to the source code of this file.
Macros | |
#define | SHA256_BYTES_IN_WORD 4 |
#define | Ch(x, y, z) ( (z) ^ ((x) & ((y) ^ (z))) ) |
#define | Maj(x, y, z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) |
#define | SIG0(x) |
#define | SIG1(x) |
#define | sig0(x) (_MHD_ROTR32 ((x),7) ^ _MHD_ROTR32 ((x),18) ^ ((x) >> 3) ) |
#define | sig1(x) (_MHD_ROTR32 ((x),17) ^ _MHD_ROTR32 ((x),19) ^ ((x) >> 10) ) |
#define | SHA2STEP32(vA, vB, vC, vD, vE, vF, vG, vH, kt, wt) |
#define | GET_W_FROM_DATA(buf, t) _MHD_GET_32BIT_BE (((const uint8_t*) (buf)) + (t) * SHA256_BYTES_IN_WORD) |
#define | Wgen(w, t) |
#define | SHA256_SIZE_OF_LEN_ADD (64 / 8) |
Functions | |
void | MHD_SHA256_init (void *ctx_) |
static void | sha256_transform (uint32_t H[_SHA256_DIGEST_LENGTH], const uint8_t data[SHA256_BLOCK_SIZE]) |
void | MHD_SHA256_update (void *ctx_, const uint8_t *data, size_t length) |
void | sha256_finish (void *ctx_, uint8_t digest[SHA256_DIGEST_SIZE]) |
Calculation of SHA-256 digest as defined in FIPS PUB 180-4 (2015)
Definition in file sha256.c.
#define Ch | ( | x, | |
y, | |||
z | |||
) | ( (z) ^ ((x) & ((y) ^ (z))) ) |
#define GET_W_FROM_DATA | ( | buf, | |
t | |||
) | _MHD_GET_32BIT_BE (((const uint8_t*) (buf)) + (t) * SHA256_BYTES_IN_WORD) |
#define Maj | ( | x, | |
y, | |||
z | |||
) | ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) |
#define SHA256_BYTES_IN_WORD 4 |
#define SHA256_SIZE_OF_LEN_ADD (64 / 8) |
#define SHA2STEP32 | ( | vA, | |
vB, | |||
vC, | |||
vD, | |||
vE, | |||
vF, | |||
vG, | |||
vH, | |||
kt, | |||
wt | |||
) |
#define SIG0 | ( | x | ) |
#define sig0 | ( | x | ) | (_MHD_ROTR32 ((x),7) ^ _MHD_ROTR32 ((x),18) ^ ((x) >> 3) ) |
#define SIG1 | ( | x | ) |
#define sig1 | ( | x | ) | (_MHD_ROTR32 ((x),17) ^ _MHD_ROTR32 ((x),19) ^ ((x) >> 10) ) |
#define Wgen | ( | w, | |
t | |||
) |
void MHD_SHA256_init | ( | void * | ctx_ | ) |
Initialise structure for SHA256 calculation.
ctx_ | must be a struct sha256_ctx * |
Definition at line 45 of file sha256.c.
References sha256_ctx::count, and sha256_ctx::H.
void MHD_SHA256_update | ( | void * | ctx_, |
const uint8_t * | data, | ||
size_t | length | ||
) |
Process portion of bytes.
ctx_ | must be a struct sha256_ctx * |
data | bytes to add to hash |
length | number of bytes in data |
< Number of bytes in buffer
Definition at line 259 of file sha256.c.
References sha256_ctx::buffer, sha256_ctx::count, data, sha256_ctx::H, mhd_assert, NULL, SHA256_BLOCK_SIZE, and sha256_transform().
void sha256_finish | ( | void * | ctx_, |
uint8_t | digest[SHA256_DIGEST_SIZE] | ||
) |
Finalise SHA256 calculation, return digest.
ctx_ | must be a struct sha256_ctx * | |
[out] | digest | set to the hash, must be SHA256_DIGEST_SIZE bytes |
< Number of processed bits
< Number of bytes in buffer
Definition at line 321 of file sha256.c.
References _MHD_PUT_32BIT_BE, _MHD_PUT_64BIT_BE, sha256_ctx::buffer, sha256_ctx::count, sha256_ctx::H, SHA256_BLOCK_SIZE, SHA256_BYTES_IN_WORD, SHA256_SIZE_OF_LEN_ADD, and sha256_transform().
|
static |
Base of SHA-256 transformation. Gets full 64 bytes block of data and updates hash values;
H | hash values |
data | data, must be exactly 64 bytes long |
Definition at line 79 of file sha256.c.
References data, GET_W_FROM_DATA, sha256_ctx::H, SHA2STEP32, and Wgen.
Referenced by MHD_SHA256_update(), and sha256_finish().