Macros | |
#define | _CRT_SECURE_NO_DEPRECATE 1 |
#define | GET_UINT32_BE(n, b, i) |
#define | PUT_UINT32_BE(n, b, i) |
#define | SHR(x, n) ((x & 0xFFFFFFFF) >> n) |
#define | ROTR(x, n) (SHR(x, n) | (x << (32 - n))) |
#define | S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3)) |
#define | S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10)) |
#define | S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22)) |
#define | S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25)) |
#define | F0(x, y, z) ((x & y) | (z & (x | y))) |
#define | F1(x, y, z) (z ^ (x & (y ^ z))) |
#define | R(t) |
#define | P(a, b, c, d, e, f, g, h, x, K) |
Functions | |
void | sha2_starts (sha2_context *ctx) |
SHA-256 context setup. | |
static void | sha2_process (sha2_context *ctx, unsigned char data[64]) |
void | sha2_update (sha2_context *ctx, unsigned char *input, int ilen) |
SHA-256 process buffer. | |
void | sha2_finish (sha2_context *ctx, unsigned char output[32]) |
SHA-256 final digest. | |
int | sha2_file (char *path, unsigned char output[32]) |
Output = SHA-256( file contents ) | |
void | sha2_csum (unsigned char *input, int ilen, unsigned char output[32]) |
Output = SHA-256( input buffer ) | |
void | sha2_hmac (unsigned char *key, int keylen, unsigned char *input, int ilen, unsigned char output[32]) |
Output = HMAC-SHA-256( input buffer, hmac key ) | |
int | sha2_self_test (void) |
Checkup routine. | |
Variables | |
static const unsigned char | sha2_padding [64] |
#define _CRT_SECURE_NO_DEPRECATE 1 |
#define F0 | ( | x, | |
y, | |||
z | |||
) | ((x & y) | (z & (x | y))) |
#define F1 | ( | x, | |
y, | |||
z | |||
) | (z ^ (x & (y ^ z))) |
#define GET_UINT32_BE | ( | n, | |
b, | |||
i | |||
) |
#define P | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
x, | |||
K | |||
) |
#define PUT_UINT32_BE | ( | n, | |
b, | |||
i | |||
) |
#define R | ( | t | ) |
#define ROTR | ( | x, | |
n | |||
) | (SHR(x, n) | (x << (32 - n))) |
#define SHR | ( | x, | |
n | |||
) | ((x & 0xFFFFFFFF) >> n) |
void sha2_csum | ( | unsigned char * | input, |
int | ilen, | ||
unsigned char | output[32] | ||
) |
Output = SHA-256( input buffer )
input | buffer holding the data |
ilen | length of the input data |
output | SHA-256 checksum result |
int sha2_file | ( | char * | path, |
unsigned char | output[32] | ||
) |
Output = SHA-256( file contents )
path | input file name |
output | SHA-256 checksum result |
void sha2_finish | ( | sha2_context * | ctx, |
unsigned char | output[32] | ||
) |
SHA-256 final digest.
ctx | SHA-256 context |
output | SHA-256 checksum result |
void sha2_hmac | ( | unsigned char * | key, |
int | keylen, | ||
unsigned char * | input, | ||
int | ilen, | ||
unsigned char | output[32] | ||
) |
Output = HMAC-SHA-256( input buffer, hmac key )
key | HMAC secret key |
keylen | length of the HMAC key |
input | buffer holding the data |
ilen | length of the input data |
output | HMAC-SHA-256 result |
|
static |
int sha2_self_test | ( | void | ) |
Checkup routine.
void sha2_starts | ( | sha2_context * | ctx | ) |
SHA-256 context setup.
ctx | SHA-256 context to be initialized |
void sha2_update | ( | sha2_context * | ctx, |
unsigned char * | input, | ||
int | ilen | ||
) |
SHA-256 process buffer.
ctx | SHA-256 context |
input | buffer holding the data |
ilen | length of the input data |
|
static |