MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sha256_transform

Function sha256_transform

src/foundation/sha256.c:26–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#define SIG1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ ((x) >> 10))
25
26static void sha256_transform(cbm_sha256_ctx *c, const uint8_t *data) {
27 uint32_t m[64];
28 for (int i = 0, j = 0; i < 16; i++, j += 4) {
29 m[i] = ((uint32_t)data[j] << 24) | ((uint32_t)data[j + 1] << 16) |
30 ((uint32_t)data[j + 2] << 8) | (uint32_t)data[j + 3];
31 }
32 for (int i = 16; i < 64; i++) {
33 m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
34 }
35
36 uint32_t a = c->state[0], b = c->state[1], cc = c->state[2], d = c->state[3];
37 uint32_t e = c->state[4], f = c->state[5], g = c->state[6], h = c->state[7];
38
39 for (int i = 0; i < 64; i++) {
40 uint32_t t1 = h + EP1(e) + CH(e, f, g) + K[i] + m[i];
41 uint32_t t2 = EP0(a) + MAJ(a, b, cc);
42 h = g;
43 g = f;
44 f = e;
45 e = d + t1;
46 d = cc;
47 cc = b;
48 b = a;
49 a = t1 + t2;
50 }
51
52 c->state[0] += a;
53 c->state[1] += b;
54 c->state[2] += cc;
55 c->state[3] += d;
56 c->state[4] += e;
57 c->state[5] += f;
58 c->state[6] += g;
59 c->state[7] += h;
60}
61
62void cbm_sha256_init(cbm_sha256_ctx *c) {
63 c->bitlen = 0;

Callers 2

cbm_sha256_updateFunction · 0.85
cbm_sha256_finalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected