MCPcopy Create free account
hub / github.com/ElementsProject/elements / Transform

Function Transform

src/crypto/sha1.cpp:46–141  ·  view source on GitHub ↗

Perform a SHA-1 transformation, processing a 64-byte chunk. */

Source from the content-addressed store, hash-verified

44
45/** Perform a SHA-1 transformation, processing a 64-byte chunk. */
46void Transform(uint32_t* s, const unsigned char* chunk)
47{
48 uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
49 uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
50
51 Round(a, b, c, d, e, f1(b, c, d), k1, w0 = ReadBE32(chunk + 0));
52 Round(e, a, b, c, d, f1(a, b, c), k1, w1 = ReadBE32(chunk + 4));
53 Round(d, e, a, b, c, f1(e, a, b), k1, w2 = ReadBE32(chunk + 8));
54 Round(c, d, e, a, b, f1(d, e, a), k1, w3 = ReadBE32(chunk + 12));
55 Round(b, c, d, e, a, f1(c, d, e), k1, w4 = ReadBE32(chunk + 16));
56 Round(a, b, c, d, e, f1(b, c, d), k1, w5 = ReadBE32(chunk + 20));
57 Round(e, a, b, c, d, f1(a, b, c), k1, w6 = ReadBE32(chunk + 24));
58 Round(d, e, a, b, c, f1(e, a, b), k1, w7 = ReadBE32(chunk + 28));
59 Round(c, d, e, a, b, f1(d, e, a), k1, w8 = ReadBE32(chunk + 32));
60 Round(b, c, d, e, a, f1(c, d, e), k1, w9 = ReadBE32(chunk + 36));
61 Round(a, b, c, d, e, f1(b, c, d), k1, w10 = ReadBE32(chunk + 40));
62 Round(e, a, b, c, d, f1(a, b, c), k1, w11 = ReadBE32(chunk + 44));
63 Round(d, e, a, b, c, f1(e, a, b), k1, w12 = ReadBE32(chunk + 48));
64 Round(c, d, e, a, b, f1(d, e, a), k1, w13 = ReadBE32(chunk + 52));
65 Round(b, c, d, e, a, f1(c, d, e), k1, w14 = ReadBE32(chunk + 56));
66 Round(a, b, c, d, e, f1(b, c, d), k1, w15 = ReadBE32(chunk + 60));
67
68 Round(e, a, b, c, d, f1(a, b, c), k1, w0 = left(w0 ^ w13 ^ w8 ^ w2));
69 Round(d, e, a, b, c, f1(e, a, b), k1, w1 = left(w1 ^ w14 ^ w9 ^ w3));
70 Round(c, d, e, a, b, f1(d, e, a), k1, w2 = left(w2 ^ w15 ^ w10 ^ w4));
71 Round(b, c, d, e, a, f1(c, d, e), k1, w3 = left(w3 ^ w0 ^ w11 ^ w5));
72 Round(a, b, c, d, e, f2(b, c, d), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6));
73 Round(e, a, b, c, d, f2(a, b, c), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7));
74 Round(d, e, a, b, c, f2(e, a, b), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8));
75 Round(c, d, e, a, b, f2(d, e, a), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9));
76 Round(b, c, d, e, a, f2(c, d, e), k2, w8 = left(w8 ^ w5 ^ w0 ^ w10));
77 Round(a, b, c, d, e, f2(b, c, d), k2, w9 = left(w9 ^ w6 ^ w1 ^ w11));
78 Round(e, a, b, c, d, f2(a, b, c), k2, w10 = left(w10 ^ w7 ^ w2 ^ w12));
79 Round(d, e, a, b, c, f2(e, a, b), k2, w11 = left(w11 ^ w8 ^ w3 ^ w13));
80 Round(c, d, e, a, b, f2(d, e, a), k2, w12 = left(w12 ^ w9 ^ w4 ^ w14));
81 Round(b, c, d, e, a, f2(c, d, e), k2, w13 = left(w13 ^ w10 ^ w5 ^ w15));
82 Round(a, b, c, d, e, f2(b, c, d), k2, w14 = left(w14 ^ w11 ^ w6 ^ w0));
83 Round(e, a, b, c, d, f2(a, b, c), k2, w15 = left(w15 ^ w12 ^ w7 ^ w1));
84
85 Round(d, e, a, b, c, f2(e, a, b), k2, w0 = left(w0 ^ w13 ^ w8 ^ w2));
86 Round(c, d, e, a, b, f2(d, e, a), k2, w1 = left(w1 ^ w14 ^ w9 ^ w3));
87 Round(b, c, d, e, a, f2(c, d, e), k2, w2 = left(w2 ^ w15 ^ w10 ^ w4));
88 Round(a, b, c, d, e, f2(b, c, d), k2, w3 = left(w3 ^ w0 ^ w11 ^ w5));
89 Round(e, a, b, c, d, f2(a, b, c), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6));
90 Round(d, e, a, b, c, f2(e, a, b), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7));
91 Round(c, d, e, a, b, f2(d, e, a), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8));
92 Round(b, c, d, e, a, f2(c, d, e), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9));
93 Round(a, b, c, d, e, f3(b, c, d), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10));
94 Round(e, a, b, c, d, f3(a, b, c), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11));
95 Round(d, e, a, b, c, f3(e, a, b), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12));
96 Round(c, d, e, a, b, f3(d, e, a), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13));
97 Round(b, c, d, e, a, f3(c, d, e), k3, w12 = left(w12 ^ w9 ^ w4 ^ w14));
98 Round(a, b, c, d, e, f3(b, c, d), k3, w13 = left(w13 ^ w10 ^ w5 ^ w15));
99 Round(e, a, b, c, d, f3(a, b, c), k3, w14 = left(w14 ^ w11 ^ w6 ^ w0));
100 Round(d, e, a, b, c, f3(e, a, b), k3, w15 = left(w15 ^ w12 ^ w7 ^ w1));
101
102 Round(c, d, e, a, b, f3(d, e, a), k3, w0 = left(w0 ^ w13 ^ w8 ^ w2));
103 Round(b, c, d, e, a, f3(c, d, e), k3, w1 = left(w1 ^ w14 ^ w9 ^ w3));

Callers 1

sha1.cppFile · 0.70

Calls 6

leftFunction · 0.85
RoundFunction · 0.70
f1Function · 0.70
ReadBE32Function · 0.70
f2Function · 0.70
f3Function · 0.70

Tested by

no test coverage detected