MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / SHA1Transform

Function SHA1Transform

tools/websocket_to_posix_proxy/src/sha1.cpp:54–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52/* Hash a single 512-bit block. This is the core of the algorithm. */
53
54void SHA1Transform(
55 uint32_t state[5],
56 const unsigned char buffer[64]
57)
58{
59 uint32_t a, b, c, d, e;
60
61 typedef union
62 {
63 unsigned char c[64];
64 uint32_t l[16];
65 } CHAR64LONG16;
66
67#ifdef SHA1HANDSOFF
68 CHAR64LONG16 block[1]; /* use array to appear as a pointer */
69
70 memcpy(block, buffer, 64);
71#else
72 /* The following had better never be used because it causes the
73 * pointer-to-const buffer to be cast into a pointer to non-const.
74 * And the result is written through. I threw a "const" in, hoping
75 * this will cause a diagnostic.
76 */
77 CHAR64LONG16 *block = (const CHAR64LONG16 *) buffer;
78#endif
79 /* Copy context->state[] to working vars */
80 a = state[0];
81 b = state[1];
82 c = state[2];
83 d = state[3];
84 e = state[4];
85 /* 4 rounds of 20 operations each. Loop unrolled. */
86 R0(a, b, c, d, e, 0);
87 R0(e, a, b, c, d, 1);
88 R0(d, e, a, b, c, 2);
89 R0(c, d, e, a, b, 3);
90 R0(b, c, d, e, a, 4);
91 R0(a, b, c, d, e, 5);
92 R0(e, a, b, c, d, 6);
93 R0(d, e, a, b, c, 7);
94 R0(c, d, e, a, b, 8);
95 R0(b, c, d, e, a, 9);
96 R0(a, b, c, d, e, 10);
97 R0(e, a, b, c, d, 11);
98 R0(d, e, a, b, c, 12);
99 R0(c, d, e, a, b, 13);
100 R0(b, c, d, e, a, 14);
101 R0(a, b, c, d, e, 15);
102 R1(e, a, b, c, d, 16);
103 R1(d, e, a, b, c, 17);
104 R1(c, d, e, a, b, 18);
105 R1(b, c, d, e, a, 19);
106 R2(a, b, c, d, e, 20);
107 R2(e, a, b, c, d, 21);
108 R2(d, e, a, b, c, 22);
109 R2(c, d, e, a, b, 23);
110 R2(b, c, d, e, a, 24);
111 R2(a, b, c, d, e, 25);

Callers 1

SHA1UpdateFunction · 0.85

Calls 2

memcpyFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected