#include <cstring>
#include <cassert>
#include "SHA256.h"
Go to the source code of this file.
|
#define | Ch(x, y, z) (z ^ (x & (y ^ z))) |
|
#define | Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) |
|
#define | Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) |
|
#define | LOAD32H(x, y) |
|
#define | Maj(x, y, z) (((x | y) & z) | (x & y)) |
|
#define | MIN(x, y) ( ((x)<(y))?(x):(y) ) |
|
#define | R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) |
|
#define | RND(a, b, c, d, e, f, g, h, i, ki) |
|
#define | RORc(x, y) ( ((((ulong32)(x)&0xFFFFFFFFUL)>>(ulong32)((y)&31)) | ((ulong32)(x)<<(ulong32)(32-((y)&31)))) & 0xFFFFFFFFUL) |
|
#define | S(x, n) RORc((x),(n)) |
|
#define | Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) |
|
#define | Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) |
|
#define | STORE32H(x, y) |
|
#define | STORE64H(x, y) |
|
#define | XMEMCMP memcmp |
|
#define | XMEMCPY memcpy |
|
◆ Ch
#define Ch |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| (z ^ (x & (y ^ z))) |
◆ Gamma0
#define Gamma0 |
( |
|
x | ) |
(S(x, 7) ^ S(x, 18) ^ R(x, 3)) |
◆ Gamma1
#define Gamma1 |
( |
|
x | ) |
(S(x, 17) ^ S(x, 19) ^ R(x, 10)) |
◆ LOAD32H
◆ Maj
#define Maj |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| (((x | y) & z) | (x & y)) |
◆ MIN
#define MIN |
( |
|
x, |
|
|
|
y |
|
) |
| ( ((x)<(y))?(x):(y) ) |
#define R |
( |
|
x, |
|
|
|
n |
|
) |
| (((x)&0xFFFFFFFFUL)>>(n)) |
◆ RND
#define RND |
( |
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
d, |
|
|
|
e, |
|
|
|
f, |
|
|
|
g, |
|
|
|
h, |
|
|
|
i, |
|
|
|
ki |
|
) |
| |
Value: t0 = h +
Sigma1(e) +
Ch(e, f, g) + ki + W[
i]; \
d += t0; \
h = t0 + t1;
◆ RORc
#define S |
( |
|
x, |
|
|
|
n |
|
) |
| RORc((x),(n)) |
◆ Sigma0
#define Sigma0 |
( |
|
x | ) |
(S(x, 2) ^ S(x, 13) ^ S(x, 22)) |
◆ Sigma1
#define Sigma1 |
( |
|
x | ) |
(S(x, 6) ^ S(x, 11) ^ S(x, 25)) |
◆ STORE32H
#define STORE32H |
( |
|
x, |
|
|
|
y |
|
) |
| |
Value: { (y)[0] = (
ulong8)(((x)>>24)&255); (y)[1] = (
ulong8)(((x)>>16)&255); \
(y)[2] = (
ulong8)(((x)>>8)&255); (y)[3] = (
ulong8)((x)&255); }
Definition at line 25 of file SHA256.cpp.
◆ STORE64H
#define STORE64H |
( |
|
x, |
|
|
|
y |
|
) |
| |
Value: { (y)[0] = (
ulong8)(((x)>>56)&255); (y)[1] = (
ulong8)(((x)>>48)&255); \
(y)[2] = (
ulong8)(((x)>>40)&255); (y)[3] = (
ulong8)(((x)>>32)&255); \
(y)[4] = (
ulong8)(((x)>>24)&255); (y)[5] = (
ulong8)(((x)>>16)&255); \
(y)[6] = (
ulong8)(((x)>>8)&255); (y)[7] = (
ulong8)((x)&255); }
Definition at line 29 of file SHA256.cpp.
◆ XMEMCMP
◆ XMEMCPY
◆ sha256_compress()
static int sha256_compress |
( |
hash_state * |
md, |
|
|
const unsigned char * |
buf |
|
) |
| |
|
static |
◆ sha256_done()
int sha256_done |
( |
hash_state * |
md, |
|
|
unsigned char * |
out |
|
) |
| |
Terminate the hash to get the digest
- Parameters
-
md | The hash state |
out | [out] The destination of the hash (32 bytes) |
- Returns
- CRYPT_OK if successful
Definition at line 249 of file SHA256.cpp.
◆ sha256_init()
Initialize the hash state
- Parameters
-
md | The hash state you wish to initialize |
- Returns
- CRYPT_OK if successful
Definition at line 163 of file SHA256.cpp.
◆ sha256_process()
Process a block of memory though the hash
- Parameters
-
md | The hash state |
in | The data to hash |
inlen | The length of the data (octets) |
- Returns
- CRYPT_OK if successful Process a block of memory though the hash
- Parameters
-
md | The hash state |
in | The data to hash |
inlen | The length of the data (octets) |
- Returns
- CRYPT_OK if successful
Definition at line 195 of file SHA256.cpp.