satsolver
0.17.2
|
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <sysexits.h>
#include <sys/uio.h>
#include <unistd.h>
#include <inttypes.h>
#include "sha2.h"
Go to the source code of this file.
Macros | |
#define | SHA2_UNROLL_TRANSFORM |
#define | SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) |
#define | SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16) |
#define | SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) |
#define | REVERSE32(w, x) |
#define | REVERSE64(w, x) |
#define | ADDINC128(w, n) |
#define | SHA2_USE_MEMSET_MEMCPY 1 |
#define | MEMSET_BZERO(p, l) memset((p), 0, (l)) |
#define | MEMCPY_BCOPY(d, s, l) memcpy((d), (s), (l)) |
#define | R(b, x) ((x) >> (b)) |
#define | S32(b, x) (((x) >> (b)) | ((x) << (32 - (b)))) |
#define | S64(b, x) (((x) >> (b)) | ((x) << (64 - (b)))) |
#define | Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) |
#define | Maj(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) |
#define | Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) |
#define | Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) |
#define | sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) |
#define | sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) |
#define | Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) |
#define | Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) |
#define | sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) |
#define | sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) |
#define | ROUND256_0_TO_15(a, b, c, d, e, f, g, h) |
#define | ROUND256(a, b, c, d, e, f, g, h) |
#define | ROUND512_0_TO_15(a, b, c, d, e, f, g, h) |
#define | ROUND512(a, b, c, d, e, f, g, h) |
Typedefs | |
typedef uint8_t | sha2_byte |
typedef uint32_t | sha2_word32 |
typedef uint64_t | sha2_word64 |
Functions | |
static void | SHA512_Last (SHA512_CTX *) |
static void | SHA256_Transform (SHA256_CTX *, const sha2_word32 *) |
static void | SHA512_Transform (SHA512_CTX *, const sha2_word64 *) |
void | sat_SHA256_Init (SHA256_CTX *context) |
void | sat_SHA256_Update (SHA256_CTX *context, const sha2_byte *data, size_t len) |
void | sat_SHA256_Final (sha2_byte digest[], SHA256_CTX *context) |
char * | sat_SHA256_End (SHA256_CTX *context, char buffer[]) |
char * | sat_SHA256_Data (const sha2_byte *data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) |
void | sat_SHA512_Init (SHA512_CTX *context) |
void | sat_SHA512_Update (SHA512_CTX *context, const sha2_byte *data, size_t len) |
void | sat_SHA512_Final (sha2_byte digest[], SHA512_CTX *context) |
char * | sat_SHA512_End (SHA512_CTX *context, char buffer[]) |
char * | sat_SHA512_Data (const sha2_byte *data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) |
void | sat_SHA384_Init (SHA384_CTX *context) |
void | sat_SHA384_Update (SHA384_CTX *context, const sha2_byte *data, size_t len) |
void | sat_SHA384_Final (sha2_byte digest[], SHA384_CTX *context) |
char * | sat_SHA384_End (SHA384_CTX *context, char buffer[]) |
char * | sat_SHA384_Data (const sha2_byte *data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) |
Variables | |
static const sha2_word32 | K256 [64] |
static const sha2_word32 | sha256_initial_hash_value [8] |
static const sha2_word64 | K512 [80] |
static const sha2_word64 | sha384_initial_hash_value [8] |
static const sha2_word64 | sha512_initial_hash_value [8] |
static const char * | sha2_hex_digits = "0123456789abcdef" |
#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) |
Definition at line 120 of file sha2.c.
Referenced by sat_SHA256_Final().
#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16) |
#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) |
Definition at line 122 of file sha2.c.
Referenced by SHA512_Last().
#define REVERSE32 | ( | w, | |
x | |||
) |
Definition at line 127 of file sha2.c.
Referenced by sat_SHA256_Final().
#define REVERSE64 | ( | w, | |
x | |||
) |
Definition at line 132 of file sha2.c.
Referenced by sat_SHA256_Final(), sat_SHA384_Final(), sat_SHA512_Final(), and SHA512_Last().
#define ADDINC128 | ( | w, | |
n | |||
) |
Definition at line 147 of file sha2.c.
Referenced by sat_SHA512_Update().
#define MEMSET_BZERO | ( | p, | |
l | |||
) | memset((p), 0, (l)) |
Definition at line 173 of file sha2.c.
Referenced by sat_SHA256_End(), sat_SHA256_Final(), sat_SHA256_Init(), sat_SHA384_End(), sat_SHA384_Final(), sat_SHA384_Init(), sat_SHA512_End(), sat_SHA512_Final(), sat_SHA512_Init(), and SHA512_Last().
#define MEMCPY_BCOPY | ( | d, | |
s, | |||
l | |||
) | memcpy((d), (s), (l)) |
Definition at line 174 of file sha2.c.
Referenced by sat_SHA256_Final(), sat_SHA256_Init(), sat_SHA256_Update(), sat_SHA384_Final(), sat_SHA384_Init(), sat_SHA512_Final(), sat_SHA512_Init(), sat_SHA512_Update(), and SHA512_Last().
#define Maj | ( | x, | |
y, | |||
z | |||
) | (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) |
#define ROUND256_0_TO_15 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h | |||
) |
Definition at line 348 of file sha2.c.
Referenced by SHA256_Transform().
#define ROUND256 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h | |||
) |
Definition at line 368 of file sha2.c.
Referenced by SHA256_Transform().
#define ROUND512_0_TO_15 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h | |||
) |
Definition at line 675 of file sha2.c.
Referenced by SHA512_Transform().
#define ROUND512 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h | |||
) |
Definition at line 695 of file sha2.c.
Referenced by SHA512_Transform().
typedef uint32_t sha2_word32 |
typedef uint64_t sha2_word64 |
|
static |
Definition at line 887 of file sha2.c.
References _SHA512_CTX::bitcount, _SHA512_CTX::buffer, MEMCPY_BCOPY, MEMSET_BZERO, REVERSE64, SHA512_BLOCK_LENGTH, SHA512_SHORT_BLOCK_LENGTH, and SHA512_Transform().
Referenced by sat_SHA384_Final(), and sat_SHA512_Final().
|
static |
Definition at line 379 of file sha2.c.
References _SHA256_CTX::buffer, ROUND256, ROUND256_0_TO_15, and _SHA256_CTX::state.
Referenced by sat_SHA256_Final(), and sat_SHA256_Update().
|
static |
Definition at line 706 of file sha2.c.
References _SHA512_CTX::buffer, ROUND512, ROUND512_0_TO_15, and _SHA512_CTX::state.
Referenced by sat_SHA512_Update(), and SHA512_Last().
void sat_SHA256_Init | ( | SHA256_CTX * | context) |
Definition at line 333 of file sha2.c.
References _SHA256_CTX::bitcount, _SHA256_CTX::buffer, MEMCPY_BCOPY, MEMSET_BZERO, SHA256_BLOCK_LENGTH, SHA256_DIGEST_LENGTH, sha256_initial_hash_value, and _SHA256_CTX::state.
Referenced by sat_chksum_create(), and sat_SHA256_Data().
void sat_SHA256_Update | ( | SHA256_CTX * | context, |
const sha2_byte * | data, | ||
size_t | len | ||
) |
Definition at line 517 of file sha2.c.
References _SHA256_CTX::bitcount, _SHA256_CTX::buffer, MEMCPY_BCOPY, SHA256_BLOCK_LENGTH, and SHA256_Transform().
Referenced by sat_chksum_add(), and sat_SHA256_Data().
void sat_SHA256_Final | ( | sha2_byte | digest[], |
SHA256_CTX * | context | ||
) |
Definition at line 565 of file sha2.c.
References _SHA256_CTX::bitcount, _SHA256_CTX::buffer, MEMCPY_BCOPY, MEMSET_BZERO, REVERSE32, REVERSE64, SHA256_BLOCK_LENGTH, SHA256_DIGEST_LENGTH, SHA256_SHORT_BLOCK_LENGTH, SHA256_Transform(), and _SHA256_CTX::state.
Referenced by sat_chksum_get(), and sat_SHA256_End().
char* sat_SHA256_End | ( | SHA256_CTX * | context, |
char | buffer[] | ||
) |
Definition at line 628 of file sha2.c.
References MEMSET_BZERO, sat_SHA256_Final(), SHA256_DIGEST_LENGTH, and sha2_hex_digits.
Referenced by sat_SHA256_Data().
char* sat_SHA256_Data | ( | const sha2_byte * | data, |
size_t | len, | ||
char | digest[SHA256_DIGEST_STRING_LENGTH] | ||
) |
Definition at line 651 of file sha2.c.
References sat_SHA256_End(), sat_SHA256_Init(), and sat_SHA256_Update().
void sat_SHA512_Init | ( | SHA512_CTX * | context) |
Definition at line 661 of file sha2.c.
References _SHA512_CTX::bitcount, _SHA512_CTX::buffer, MEMCPY_BCOPY, MEMSET_BZERO, SHA512_BLOCK_LENGTH, SHA512_DIGEST_LENGTH, sha512_initial_hash_value, and _SHA512_CTX::state.
Referenced by sat_SHA512_Data().
void sat_SHA512_Update | ( | SHA512_CTX * | context, |
const sha2_byte * | data, | ||
size_t | len | ||
) |
Definition at line 839 of file sha2.c.
References ADDINC128, _SHA512_CTX::bitcount, _SHA512_CTX::buffer, MEMCPY_BCOPY, SHA512_BLOCK_LENGTH, and SHA512_Transform().
Referenced by sat_SHA384_Update(), and sat_SHA512_Data().
void sat_SHA512_Final | ( | sha2_byte | digest[], |
SHA512_CTX * | context | ||
) |
Definition at line 928 of file sha2.c.
References MEMCPY_BCOPY, MEMSET_BZERO, REVERSE64, SHA512_DIGEST_LENGTH, SHA512_Last(), and _SHA512_CTX::state.
Referenced by sat_SHA512_End().
char* sat_SHA512_End | ( | SHA512_CTX * | context, |
char | buffer[] | ||
) |
Definition at line 957 of file sha2.c.
References MEMSET_BZERO, sat_SHA512_Final(), sha2_hex_digits, and SHA512_DIGEST_LENGTH.
Referenced by sat_SHA512_Data().
char* sat_SHA512_Data | ( | const sha2_byte * | data, |
size_t | len, | ||
char | digest[SHA512_DIGEST_STRING_LENGTH] | ||
) |
Definition at line 980 of file sha2.c.
References sat_SHA512_End(), sat_SHA512_Init(), and sat_SHA512_Update().
void sat_SHA384_Init | ( | SHA384_CTX * | context) |
Definition at line 990 of file sha2.c.
References _SHA512_CTX::bitcount, _SHA512_CTX::buffer, MEMCPY_BCOPY, MEMSET_BZERO, SHA384_BLOCK_LENGTH, sha384_initial_hash_value, SHA512_DIGEST_LENGTH, and _SHA512_CTX::state.
Referenced by sat_SHA384_Data().
void sat_SHA384_Update | ( | SHA384_CTX * | context, |
const sha2_byte * | data, | ||
size_t | len | ||
) |
Definition at line 999 of file sha2.c.
References sat_SHA512_Update().
Referenced by sat_SHA384_Data().
void sat_SHA384_Final | ( | sha2_byte | digest[], |
SHA384_CTX * | context | ||
) |
Definition at line 1003 of file sha2.c.
References MEMCPY_BCOPY, MEMSET_BZERO, REVERSE64, SHA384_DIGEST_LENGTH, SHA512_Last(), and _SHA512_CTX::state.
Referenced by sat_SHA384_End().
char* sat_SHA384_End | ( | SHA384_CTX * | context, |
char | buffer[] | ||
) |
Definition at line 1032 of file sha2.c.
References MEMSET_BZERO, sat_SHA384_Final(), sha2_hex_digits, and SHA384_DIGEST_LENGTH.
Referenced by sat_SHA384_Data().
char* sat_SHA384_Data | ( | const sha2_byte * | data, |
size_t | len, | ||
char | digest[SHA384_DIGEST_STRING_LENGTH] | ||
) |
Definition at line 1055 of file sha2.c.
References sat_SHA384_End(), sat_SHA384_Init(), and sat_SHA384_Update().
|
static |
|
static |
Definition at line 246 of file sha2.c.
Referenced by sat_SHA256_Init().
|
static |
|
static |
Definition at line 302 of file sha2.c.
Referenced by sat_SHA384_Init().
|
static |
Definition at line 314 of file sha2.c.
Referenced by sat_SHA512_Init().
|
static |
Definition at line 329 of file sha2.c.
Referenced by sat_SHA256_End(), sat_SHA384_End(), and sat_SHA512_End().