34 extern void sha256_compress(uint32_t state[8],
const uint8_t block[64]);
39 uint8_t block[64], uint32_t *len_block, uint32_t action) {
54 hash[0] = UINT32_C(0x6A09E667);
55 hash[1] = UINT32_C(0xBB67AE85);
56 hash[2] = UINT32_C(0x3C6EF372);
57 hash[3] = UINT32_C(0xA54FF53A);
58 hash[4] = UINT32_C(0x510E527F);
59 hash[5] = UINT32_C(0x9B05688C);
60 hash[6] = UINT32_C(0x1F83D9AB);
61 hash[7] = UINT32_C(0x5BE0CD19);
68 istart = 64 - *len_block;
73 memcpy(block+*len_block, message, istart);
80 memcpy(block+*len_block, message, len);
90 for (i = istart; len - i >= 64; i += 64)
95 memcpy(block, message + i, rem);
104 if (action==0 || action==3) {
110 memset(block + rem, 0, 56 - rem);
112 memset(block + rem, 0, 64 - rem);
114 memset(block, 0, 56);
118 for (i = 0; i < 8; i++)
119 block[64 - 1 - i] = (uint8_t)(longLen >> (i * 8));
void sha256_compress(uint32_t state[8], const uint8_t block[64])
void sha256_hash(const uint8_t *message, uint64_t len, uint32_t hash[8], uint8_t block[64], uint32_t *len_block, uint32_t action)