FUNCTION DEFINITIONS ***********************/
| 42 | |
| 43 | /*********************** FUNCTION DEFINITIONS ***********************/ |
| 44 | void sha256_transform(SHA256_CTX *ctx, const BYTE data[]) |
| 45 | { |
| 46 | WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64]; |
| 47 | |
| 48 | for (i = 0, j = 0; i < 16; ++i, j += 4) |
| 49 | m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]); |
| 50 | for ( ; i < 64; ++i) |
| 51 | m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16]; |
| 52 | |
| 53 | a = ctx->state[0]; |
| 54 | b = ctx->state[1]; |
| 55 | c = ctx->state[2]; |
| 56 | d = ctx->state[3]; |
| 57 | e = ctx->state[4]; |
| 58 | f = ctx->state[5]; |
| 59 | g = ctx->state[6]; |
| 60 | h = ctx->state[7]; |
| 61 | |
| 62 | for (i = 0; i < 64; ++i) { |
| 63 | t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i]; |
| 64 | t2 = EP0(a) + MAJ(a,b,c); |
| 65 | h = g; |
| 66 | g = f; |
| 67 | f = e; |
| 68 | e = d + t1; |
| 69 | d = c; |
| 70 | c = b; |
| 71 | b = a; |
| 72 | a = t1 + t2; |
| 73 | } |
| 74 | |
| 75 | ctx->state[0] += a; |
| 76 | ctx->state[1] += b; |
| 77 | ctx->state[2] += c; |
| 78 | ctx->state[3] += d; |
| 79 | ctx->state[4] += e; |
| 80 | ctx->state[5] += f; |
| 81 | ctx->state[6] += g; |
| 82 | ctx->state[7] += h; |
| 83 | } |
| 84 | |
| 85 | void sha256_init(SHA256_CTX *ctx) |
| 86 | { |
no outgoing calls
no test coverage detected