44 void update(
const unsigned char *message,
unsigned int len);
45 void final(
unsigned char *digest);
49 void transform(
const unsigned char *message,
unsigned int block_nb);
58 std::string
sha256(std::string input);
60 #define SHA2_SHFR(x, n) (x >> n)
61 #define SHA2_ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
62 #define SHA2_ROTL(x, n) ((x << n) | (x >> ((sizeof(x) << 3) - n)))
63 #define SHA2_CH(x, y, z) ((x & y) ^ (~x & z))
64 #define SHA2_MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
65 #define SHA256_F1(x) (SHA2_ROTR(x, 2) ^ SHA2_ROTR(x, 13) ^ SHA2_ROTR(x, 22))
66 #define SHA256_F2(x) (SHA2_ROTR(x, 6) ^ SHA2_ROTR(x, 11) ^ SHA2_ROTR(x, 25))
67 #define SHA256_F3(x) (SHA2_ROTR(x, 7) ^ SHA2_ROTR(x, 18) ^ SHA2_SHFR(x, 3))
68 #define SHA256_F4(x) (SHA2_ROTR(x, 17) ^ SHA2_ROTR(x, 19) ^ SHA2_SHFR(x, 10))
69 #define SHA2_UNPACK32(x, str) \
71 *((str) + 3) = (uint8) ((x) ); \
72 *((str) + 2) = (uint8) ((x) >> 8); \
73 *((str) + 1) = (uint8) ((x) >> 16); \
74 *((str) + 0) = (uint8) ((x) >> 24); \
76 #define SHA2_PACK32(str, x) \
78 *(x) = ((uint32) *((str) + 3) ) \
79 | ((uint32) *((str) + 2) << 8) \
80 | ((uint32) *((str) + 1) << 16) \
81 | ((uint32) *((str) + 0) << 24); \
static const unsigned int DIGEST_SIZE
unsigned char m_block[2 *SHA224_256_BLOCK_SIZE]
std::string sha256(std::string input)
void transform(const unsigned char *message, unsigned int block_nb)
static const unsigned int SHA224_256_BLOCK_SIZE
static const uint32 sha256_k[]
void update(const unsigned char *message, unsigned int len)
unsigned long long uint64