return (a >> b) | (a << (32 - b));
}
-static uint32_t foleo_sha256_init[] =
-{
- 0x6a09e667,
- 0xbb67ae85,
- 0x3c6ef372,
- 0xa54ff53a,
- 0x510e527f,
- 0x9b05688c,
- 0x1f83d9ab,
- 0x5be0cd19
-};
-
static uint32_t foleo_sha256_h[] =
{
0x6a09e667,
uint8_t* foleo_sha256(uint8_t* msg, uint32_t size)
{
//set initial state
- uint32_t* h = malloc(sizeof(foleo_sha256_init));
- for (uint8_t i = 0; i < sizeof(foleo_sha256_init) / sizeof(uint32_t); i++)
+ uint32_t* h = malloc(sizeof(foleo_sha256_h));
+ for (uint8_t i = 0; i < sizeof(foleo_sha256_h) / sizeof(uint32_t); i++)
{
- h[i] = foleo_sha256_init[i];
+ h[i] = foleo_sha256_h[i];
}
//pad the message
free(padded);
//breakout
- uint8_t* out = malloc(sizeof(foleo_sha256_init));
- for (uint32_t i = 0; i < sizeof(foleo_sha256_init) / sizeof(uint32_t); i++)
+ uint8_t* out = malloc(sizeof(foleo_sha256_h));
+ for (uint32_t i = 0; i < sizeof(foleo_sha256_h) / sizeof(uint32_t); i++)
{
out[i * sizeof(uint32_t) + 0] = h[i] >> 24;
out[i * sizeof(uint32_t) + 1] = h[i] >> 16;