MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / process_block

Function process_block

core/sha256.c:34–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34static void process_block() {
35 static const uint32_t k[64] = {
36 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
37 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
38 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
39 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
40 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
41 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
42 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
43 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
44 };
45
46 uint32_t a, b, c, d, e, f, g, h;
47 uint32_t w[64];
48 int i;
49
50 memcpy(w, sha256.block, 64);
51 for (i = 16; i < 64; i++) {
52 uint32_t s0 = ROR(w[i-15], 7) ^ ROR(w[i-15], 18) ^ (w[i-15] >> 3);
53 uint32_t s1 = ROR(w[i-2], 17) ^ ROR(w[i-2], 19) ^ (w[i-2] >> 10);
54 w[i] = w[i-16] + s0 + w[i-7] + s1;
55 }
56
57 a = sha256.state[0];
58 b = sha256.state[1];
59 c = sha256.state[2];
60 d = sha256.state[3];
61 e = sha256.state[4];
62 f = sha256.state[5];
63 g = sha256.state[6];
64 h = sha256.state[7];
65
66 for (i = 0; i < 64; i++) {
67 uint32_t s0 = ROR(a, 2) ^ ROR(a, 13) ^ ROR(a, 22);
68 uint32_t maj = (a & b) ^ (a & c) ^ (b & c);
69 uint32_t t2 = s0 + maj;
70 uint32_t s1 = ROR(e, 6) ^ ROR(e, 11) ^ ROR(e, 25);
71 uint32_t ch = (e & f) ^ (~e & g);
72 uint32_t t1 = h + s1 + ch + k[i] + w[i];
73
74 h = g;
75 g = f;
76 f = e;
77 e = d + t1;
78 d = c;
79 c = b;
80 b = a;
81 a = t1 + t2;
82 }
83
84 sha256.state[0] += a;
85 sha256.state[1] += b;
86 sha256.state[2] += c;
87 sha256.state[3] += d;
88 sha256.state[4] += e;
89 sha256.state[5] += f;
90 sha256.state[6] += g;
91 sha256.state[7] += h;

Callers 1

sha256_writeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected