5 #include "../TypeDefs.h" 9 #define SHA2_SHFR(x, n) ((x) >> (n)) 10 #define SHA2_ROTR(x, n) (((x) >> (n)) | ((x) << ((sizeof(x) << 3) - (n)))) 11 #define SHA2_ROTL(x, n) (((x) << (n)) | ((x) >> ((sizeof(x) << 3) - (n)))) 12 #define SHA2_CH(x, y, z) (((x) & (y)) ^ (~(x) & (z))) 13 #define SHA2_MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) 14 #define SHA256_F1(x) (SHA2_ROTR(x, 2) ^ SHA2_ROTR(x, 13) ^ SHA2_ROTR(x, 22)) 15 #define SHA256_F2(x) (SHA2_ROTR(x, 6) ^ SHA2_ROTR(x, 11) ^ SHA2_ROTR(x, 25)) 16 #define SHA256_F3(x) (SHA2_ROTR(x, 7) ^ SHA2_ROTR(x, 18) ^ SHA2_SHFR(x, 3)) 17 #define SHA256_F4(x) (SHA2_ROTR(x, 17) ^ SHA2_ROTR(x, 19) ^ SHA2_SHFR(x, 10)) 18 #define SHA2_UNPACK32(x, str) \ 20 *((str) + 3) = (uint8_t) ((x) ); \ 21 *((str) + 2) = (uint8_t) ((x) >> 8); \ 22 *((str) + 1) = (uint8_t) ((x) >> 16); \ 23 *((str) + 0) = (uint8_t) ((x) >> 24); \ 25 #define SHA2_PACK32(str, x) \ 27 *(x) = ((uint32_t) *((str) + 3) ) \ 28 | ((uint32_t) *((str) + 2) << 8) \ 29 | ((uint32_t) *((str) + 1) << 16) \ 30 | ((uint32_t) *((str) + 0) << 24); \ 40 const static uint32_t sha256_k[];
41 static const unsigned int SHA224_256_BLOCK_SIZE = (512 / 8);
44 unsigned char m_block[2 * SHA224_256_BLOCK_SIZE];
47 void transform(
const unsigned char *message,
unsigned int block_nb);
50 static const unsigned int DIGEST_SIZE = ( 256 / 8);
53 void update(
const unsigned char* message, uint len);
54 void final(uint8_t* digest);
57 extern uint8_t*
sha256(
unsigned char* input, uint inputLen, uint8_t* digest);
58 extern uint8_t*
sha256(std::string input, uint8_t* digest);
unsigned char uint8
Definition: SHA256.h:36
unsigned int m_tot_len
Definition: SHA256.h:42
unsigned int uint32
Definition: SHA256.h:37
unsigned int m_len
Definition: SHA256.h:43
uint8_t * sha256(unsigned char *input, uint inputLen, uint8_t *digest)
Definition: SHA256.cpp:102
unsigned long long uint64
Definition: SHA256.h:38