Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

sha256_sse41.cpp
Go to the documentation of this file.
1 #ifdef ENABLE_SSE41
2 
3 #include <stdint.h>
4 #include <immintrin.h>
5 
6 #include <crypto/sha256.h>
7 #include <crypto/common.h>
8 
9 namespace sha256d64_sse41 {
10 namespace {
11 
12 __m128i inline K(uint32_t x) { return _mm_set1_epi32(x); }
13 
14 __m128i inline Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
15 __m128i inline Add(__m128i x, __m128i y, __m128i z) { return Add(Add(x, y), z); }
16 __m128i inline Add(__m128i x, __m128i y, __m128i z, __m128i w) { return Add(Add(x, y), Add(z, w)); }
17 __m128i inline Add(__m128i x, __m128i y, __m128i z, __m128i w, __m128i v) { return Add(Add(x, y, z), Add(w, v)); }
18 __m128i inline Inc(__m128i& x, __m128i y) { x = Add(x, y); return x; }
19 __m128i inline Inc(__m128i& x, __m128i y, __m128i z) { x = Add(x, y, z); return x; }
20 __m128i inline Inc(__m128i& x, __m128i y, __m128i z, __m128i w) { x = Add(x, y, z, w); return x; }
21 __m128i inline Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
22 __m128i inline Xor(__m128i x, __m128i y, __m128i z) { return Xor(Xor(x, y), z); }
23 __m128i inline Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
24 __m128i inline And(__m128i x, __m128i y) { return _mm_and_si128(x, y); }
25 __m128i inline ShR(__m128i x, int n) { return _mm_srli_epi32(x, n); }
26 __m128i inline ShL(__m128i x, int n) { return _mm_slli_epi32(x, n); }
27 
28 __m128i inline Ch(__m128i x, __m128i y, __m128i z) { return Xor(z, And(x, Xor(y, z))); }
29 __m128i inline Maj(__m128i x, __m128i y, __m128i z) { return Or(And(x, y), And(z, Or(x, y))); }
30 __m128i inline Sigma0(__m128i x) { return Xor(Or(ShR(x, 2), ShL(x, 30)), Or(ShR(x, 13), ShL(x, 19)), Or(ShR(x, 22), ShL(x, 10))); }
31 __m128i inline Sigma1(__m128i x) { return Xor(Or(ShR(x, 6), ShL(x, 26)), Or(ShR(x, 11), ShL(x, 21)), Or(ShR(x, 25), ShL(x, 7))); }
32 __m128i inline sigma0(__m128i x) { return Xor(Or(ShR(x, 7), ShL(x, 25)), Or(ShR(x, 18), ShL(x, 14)), ShR(x, 3)); }
33 __m128i inline sigma1(__m128i x) { return Xor(Or(ShR(x, 17), ShL(x, 15)), Or(ShR(x, 19), ShL(x, 13)), ShR(x, 10)); }
34 
36 void inline __attribute__((always_inline)) Round(__m128i a, __m128i b, __m128i c, __m128i& d, __m128i e, __m128i f, __m128i g, __m128i& h, __m128i k)
37 {
38  __m128i t1 = Add(h, Sigma1(e), Ch(e, f, g), k);
39  __m128i t2 = Add(Sigma0(a), Maj(a, b, c));
40  d = Add(d, t1);
41  h = Add(t1, t2);
42 }
43 
44 __m128i inline Read4(const unsigned char* chunk, int offset) {
45  __m128i ret = _mm_set_epi32(
46  ReadLE32(chunk + 0 + offset),
47  ReadLE32(chunk + 64 + offset),
48  ReadLE32(chunk + 128 + offset),
49  ReadLE32(chunk + 192 + offset)
50  );
51  return _mm_shuffle_epi8(ret, _mm_set_epi32(0x0C0D0E0FUL, 0x08090A0BUL, 0x04050607UL, 0x00010203UL));
52 }
53 
54 void inline Write4(unsigned char* out, int offset, __m128i v) {
55  v = _mm_shuffle_epi8(v, _mm_set_epi32(0x0C0D0E0FUL, 0x08090A0BUL, 0x04050607UL, 0x00010203UL));
56  WriteLE32(out + 0 + offset, _mm_extract_epi32(v, 3));
57  WriteLE32(out + 32 + offset, _mm_extract_epi32(v, 2));
58  WriteLE32(out + 64 + offset, _mm_extract_epi32(v, 1));
59  WriteLE32(out + 96 + offset, _mm_extract_epi32(v, 0));
60 }
61 
62 }
63 
64 void Transform_4way(unsigned char* out, const unsigned char* in)
65 {
66  // Transform 1
67  __m128i a = K(0x6a09e667ul);
68  __m128i b = K(0xbb67ae85ul);
69  __m128i c = K(0x3c6ef372ul);
70  __m128i d = K(0xa54ff53aul);
71  __m128i e = K(0x510e527ful);
72  __m128i f = K(0x9b05688cul);
73  __m128i g = K(0x1f83d9abul);
74  __m128i h = K(0x5be0cd19ul);
75 
76  __m128i w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
77 
78  Round(a, b, c, d, e, f, g, h, Add(K(0x428a2f98ul), w0 = Read4(in, 0)));
79  Round(h, a, b, c, d, e, f, g, Add(K(0x71374491ul), w1 = Read4(in, 4)));
80  Round(g, h, a, b, c, d, e, f, Add(K(0xb5c0fbcful), w2 = Read4(in, 8)));
81  Round(f, g, h, a, b, c, d, e, Add(K(0xe9b5dba5ul), w3 = Read4(in, 12)));
82  Round(e, f, g, h, a, b, c, d, Add(K(0x3956c25bul), w4 = Read4(in, 16)));
83  Round(d, e, f, g, h, a, b, c, Add(K(0x59f111f1ul), w5 = Read4(in, 20)));
84  Round(c, d, e, f, g, h, a, b, Add(K(0x923f82a4ul), w6 = Read4(in, 24)));
85  Round(b, c, d, e, f, g, h, a, Add(K(0xab1c5ed5ul), w7 = Read4(in, 28)));
86  Round(a, b, c, d, e, f, g, h, Add(K(0xd807aa98ul), w8 = Read4(in, 32)));
87  Round(h, a, b, c, d, e, f, g, Add(K(0x12835b01ul), w9 = Read4(in, 36)));
88  Round(g, h, a, b, c, d, e, f, Add(K(0x243185beul), w10 = Read4(in, 40)));
89  Round(f, g, h, a, b, c, d, e, Add(K(0x550c7dc3ul), w11 = Read4(in, 44)));
90  Round(e, f, g, h, a, b, c, d, Add(K(0x72be5d74ul), w12 = Read4(in, 48)));
91  Round(d, e, f, g, h, a, b, c, Add(K(0x80deb1feul), w13 = Read4(in, 52)));
92  Round(c, d, e, f, g, h, a, b, Add(K(0x9bdc06a7ul), w14 = Read4(in, 56)));
93  Round(b, c, d, e, f, g, h, a, Add(K(0xc19bf174ul), w15 = Read4(in, 60)));
94  Round(a, b, c, d, e, f, g, h, Add(K(0xe49b69c1ul), Inc(w0, sigma1(w14), w9, sigma0(w1))));
95  Round(h, a, b, c, d, e, f, g, Add(K(0xefbe4786ul), Inc(w1, sigma1(w15), w10, sigma0(w2))));
96  Round(g, h, a, b, c, d, e, f, Add(K(0x0fc19dc6ul), Inc(w2, sigma1(w0), w11, sigma0(w3))));
97  Round(f, g, h, a, b, c, d, e, Add(K(0x240ca1ccul), Inc(w3, sigma1(w1), w12, sigma0(w4))));
98  Round(e, f, g, h, a, b, c, d, Add(K(0x2de92c6ful), Inc(w4, sigma1(w2), w13, sigma0(w5))));
99  Round(d, e, f, g, h, a, b, c, Add(K(0x4a7484aaul), Inc(w5, sigma1(w3), w14, sigma0(w6))));
100  Round(c, d, e, f, g, h, a, b, Add(K(0x5cb0a9dcul), Inc(w6, sigma1(w4), w15, sigma0(w7))));
101  Round(b, c, d, e, f, g, h, a, Add(K(0x76f988daul), Inc(w7, sigma1(w5), w0, sigma0(w8))));
102  Round(a, b, c, d, e, f, g, h, Add(K(0x983e5152ul), Inc(w8, sigma1(w6), w1, sigma0(w9))));
103  Round(h, a, b, c, d, e, f, g, Add(K(0xa831c66dul), Inc(w9, sigma1(w7), w2, sigma0(w10))));
104  Round(g, h, a, b, c, d, e, f, Add(K(0xb00327c8ul), Inc(w10, sigma1(w8), w3, sigma0(w11))));
105  Round(f, g, h, a, b, c, d, e, Add(K(0xbf597fc7ul), Inc(w11, sigma1(w9), w4, sigma0(w12))));
106  Round(e, f, g, h, a, b, c, d, Add(K(0xc6e00bf3ul), Inc(w12, sigma1(w10), w5, sigma0(w13))));
107  Round(d, e, f, g, h, a, b, c, Add(K(0xd5a79147ul), Inc(w13, sigma1(w11), w6, sigma0(w14))));
108  Round(c, d, e, f, g, h, a, b, Add(K(0x06ca6351ul), Inc(w14, sigma1(w12), w7, sigma0(w15))));
109  Round(b, c, d, e, f, g, h, a, Add(K(0x14292967ul), Inc(w15, sigma1(w13), w8, sigma0(w0))));
110  Round(a, b, c, d, e, f, g, h, Add(K(0x27b70a85ul), Inc(w0, sigma1(w14), w9, sigma0(w1))));
111  Round(h, a, b, c, d, e, f, g, Add(K(0x2e1b2138ul), Inc(w1, sigma1(w15), w10, sigma0(w2))));
112  Round(g, h, a, b, c, d, e, f, Add(K(0x4d2c6dfcul), Inc(w2, sigma1(w0), w11, sigma0(w3))));
113  Round(f, g, h, a, b, c, d, e, Add(K(0x53380d13ul), Inc(w3, sigma1(w1), w12, sigma0(w4))));
114  Round(e, f, g, h, a, b, c, d, Add(K(0x650a7354ul), Inc(w4, sigma1(w2), w13, sigma0(w5))));
115  Round(d, e, f, g, h, a, b, c, Add(K(0x766a0abbul), Inc(w5, sigma1(w3), w14, sigma0(w6))));
116  Round(c, d, e, f, g, h, a, b, Add(K(0x81c2c92eul), Inc(w6, sigma1(w4), w15, sigma0(w7))));
117  Round(b, c, d, e, f, g, h, a, Add(K(0x92722c85ul), Inc(w7, sigma1(w5), w0, sigma0(w8))));
118  Round(a, b, c, d, e, f, g, h, Add(K(0xa2bfe8a1ul), Inc(w8, sigma1(w6), w1, sigma0(w9))));
119  Round(h, a, b, c, d, e, f, g, Add(K(0xa81a664bul), Inc(w9, sigma1(w7), w2, sigma0(w10))));
120  Round(g, h, a, b, c, d, e, f, Add(K(0xc24b8b70ul), Inc(w10, sigma1(w8), w3, sigma0(w11))));
121  Round(f, g, h, a, b, c, d, e, Add(K(0xc76c51a3ul), Inc(w11, sigma1(w9), w4, sigma0(w12))));
122  Round(e, f, g, h, a, b, c, d, Add(K(0xd192e819ul), Inc(w12, sigma1(w10), w5, sigma0(w13))));
123  Round(d, e, f, g, h, a, b, c, Add(K(0xd6990624ul), Inc(w13, sigma1(w11), w6, sigma0(w14))));
124  Round(c, d, e, f, g, h, a, b, Add(K(0xf40e3585ul), Inc(w14, sigma1(w12), w7, sigma0(w15))));
125  Round(b, c, d, e, f, g, h, a, Add(K(0x106aa070ul), Inc(w15, sigma1(w13), w8, sigma0(w0))));
126  Round(a, b, c, d, e, f, g, h, Add(K(0x19a4c116ul), Inc(w0, sigma1(w14), w9, sigma0(w1))));
127  Round(h, a, b, c, d, e, f, g, Add(K(0x1e376c08ul), Inc(w1, sigma1(w15), w10, sigma0(w2))));
128  Round(g, h, a, b, c, d, e, f, Add(K(0x2748774cul), Inc(w2, sigma1(w0), w11, sigma0(w3))));
129  Round(f, g, h, a, b, c, d, e, Add(K(0x34b0bcb5ul), Inc(w3, sigma1(w1), w12, sigma0(w4))));
130  Round(e, f, g, h, a, b, c, d, Add(K(0x391c0cb3ul), Inc(w4, sigma1(w2), w13, sigma0(w5))));
131  Round(d, e, f, g, h, a, b, c, Add(K(0x4ed8aa4aul), Inc(w5, sigma1(w3), w14, sigma0(w6))));
132  Round(c, d, e, f, g, h, a, b, Add(K(0x5b9cca4ful), Inc(w6, sigma1(w4), w15, sigma0(w7))));
133  Round(b, c, d, e, f, g, h, a, Add(K(0x682e6ff3ul), Inc(w7, sigma1(w5), w0, sigma0(w8))));
134  Round(a, b, c, d, e, f, g, h, Add(K(0x748f82eeul), Inc(w8, sigma1(w6), w1, sigma0(w9))));
135  Round(h, a, b, c, d, e, f, g, Add(K(0x78a5636ful), Inc(w9, sigma1(w7), w2, sigma0(w10))));
136  Round(g, h, a, b, c, d, e, f, Add(K(0x84c87814ul), Inc(w10, sigma1(w8), w3, sigma0(w11))));
137  Round(f, g, h, a, b, c, d, e, Add(K(0x8cc70208ul), Inc(w11, sigma1(w9), w4, sigma0(w12))));
138  Round(e, f, g, h, a, b, c, d, Add(K(0x90befffaul), Inc(w12, sigma1(w10), w5, sigma0(w13))));
139  Round(d, e, f, g, h, a, b, c, Add(K(0xa4506cebul), Inc(w13, sigma1(w11), w6, sigma0(w14))));
140  Round(c, d, e, f, g, h, a, b, Add(K(0xbef9a3f7ul), Inc(w14, sigma1(w12), w7, sigma0(w15))));
141  Round(b, c, d, e, f, g, h, a, Add(K(0xc67178f2ul), Inc(w15, sigma1(w13), w8, sigma0(w0))));
142 
143  a = Add(a, K(0x6a09e667ul));
144  b = Add(b, K(0xbb67ae85ul));
145  c = Add(c, K(0x3c6ef372ul));
146  d = Add(d, K(0xa54ff53aul));
147  e = Add(e, K(0x510e527ful));
148  f = Add(f, K(0x9b05688cul));
149  g = Add(g, K(0x1f83d9abul));
150  h = Add(h, K(0x5be0cd19ul));
151 
152  __m128i t0 = a, t1 = b, t2 = c, t3 = d, t4 = e, t5 = f, t6 = g, t7 = h;
153 
154  // Transform 2
155  Round(a, b, c, d, e, f, g, h, K(0xc28a2f98ul));
156  Round(h, a, b, c, d, e, f, g, K(0x71374491ul));
157  Round(g, h, a, b, c, d, e, f, K(0xb5c0fbcful));
158  Round(f, g, h, a, b, c, d, e, K(0xe9b5dba5ul));
159  Round(e, f, g, h, a, b, c, d, K(0x3956c25bul));
160  Round(d, e, f, g, h, a, b, c, K(0x59f111f1ul));
161  Round(c, d, e, f, g, h, a, b, K(0x923f82a4ul));
162  Round(b, c, d, e, f, g, h, a, K(0xab1c5ed5ul));
163  Round(a, b, c, d, e, f, g, h, K(0xd807aa98ul));
164  Round(h, a, b, c, d, e, f, g, K(0x12835b01ul));
165  Round(g, h, a, b, c, d, e, f, K(0x243185beul));
166  Round(f, g, h, a, b, c, d, e, K(0x550c7dc3ul));
167  Round(e, f, g, h, a, b, c, d, K(0x72be5d74ul));
168  Round(d, e, f, g, h, a, b, c, K(0x80deb1feul));
169  Round(c, d, e, f, g, h, a, b, K(0x9bdc06a7ul));
170  Round(b, c, d, e, f, g, h, a, K(0xc19bf374ul));
171  Round(a, b, c, d, e, f, g, h, K(0x649b69c1ul));
172  Round(h, a, b, c, d, e, f, g, K(0xf0fe4786ul));
173  Round(g, h, a, b, c, d, e, f, K(0x0fe1edc6ul));
174  Round(f, g, h, a, b, c, d, e, K(0x240cf254ul));
175  Round(e, f, g, h, a, b, c, d, K(0x4fe9346ful));
176  Round(d, e, f, g, h, a, b, c, K(0x6cc984beul));
177  Round(c, d, e, f, g, h, a, b, K(0x61b9411eul));
178  Round(b, c, d, e, f, g, h, a, K(0x16f988faul));
179  Round(a, b, c, d, e, f, g, h, K(0xf2c65152ul));
180  Round(h, a, b, c, d, e, f, g, K(0xa88e5a6dul));
181  Round(g, h, a, b, c, d, e, f, K(0xb019fc65ul));
182  Round(f, g, h, a, b, c, d, e, K(0xb9d99ec7ul));
183  Round(e, f, g, h, a, b, c, d, K(0x9a1231c3ul));
184  Round(d, e, f, g, h, a, b, c, K(0xe70eeaa0ul));
185  Round(c, d, e, f, g, h, a, b, K(0xfdb1232bul));
186  Round(b, c, d, e, f, g, h, a, K(0xc7353eb0ul));
187  Round(a, b, c, d, e, f, g, h, K(0x3069bad5ul));
188  Round(h, a, b, c, d, e, f, g, K(0xcb976d5ful));
189  Round(g, h, a, b, c, d, e, f, K(0x5a0f118ful));
190  Round(f, g, h, a, b, c, d, e, K(0xdc1eeefdul));
191  Round(e, f, g, h, a, b, c, d, K(0x0a35b689ul));
192  Round(d, e, f, g, h, a, b, c, K(0xde0b7a04ul));
193  Round(c, d, e, f, g, h, a, b, K(0x58f4ca9dul));
194  Round(b, c, d, e, f, g, h, a, K(0xe15d5b16ul));
195  Round(a, b, c, d, e, f, g, h, K(0x007f3e86ul));
196  Round(h, a, b, c, d, e, f, g, K(0x37088980ul));
197  Round(g, h, a, b, c, d, e, f, K(0xa507ea32ul));
198  Round(f, g, h, a, b, c, d, e, K(0x6fab9537ul));
199  Round(e, f, g, h, a, b, c, d, K(0x17406110ul));
200  Round(d, e, f, g, h, a, b, c, K(0x0d8cd6f1ul));
201  Round(c, d, e, f, g, h, a, b, K(0xcdaa3b6dul));
202  Round(b, c, d, e, f, g, h, a, K(0xc0bbbe37ul));
203  Round(a, b, c, d, e, f, g, h, K(0x83613bdaul));
204  Round(h, a, b, c, d, e, f, g, K(0xdb48a363ul));
205  Round(g, h, a, b, c, d, e, f, K(0x0b02e931ul));
206  Round(f, g, h, a, b, c, d, e, K(0x6fd15ca7ul));
207  Round(e, f, g, h, a, b, c, d, K(0x521afacaul));
208  Round(d, e, f, g, h, a, b, c, K(0x31338431ul));
209  Round(c, d, e, f, g, h, a, b, K(0x6ed41a95ul));
210  Round(b, c, d, e, f, g, h, a, K(0x6d437890ul));
211  Round(a, b, c, d, e, f, g, h, K(0xc39c91f2ul));
212  Round(h, a, b, c, d, e, f, g, K(0x9eccabbdul));
213  Round(g, h, a, b, c, d, e, f, K(0xb5c9a0e6ul));
214  Round(f, g, h, a, b, c, d, e, K(0x532fb63cul));
215  Round(e, f, g, h, a, b, c, d, K(0xd2c741c6ul));
216  Round(d, e, f, g, h, a, b, c, K(0x07237ea3ul));
217  Round(c, d, e, f, g, h, a, b, K(0xa4954b68ul));
218  Round(b, c, d, e, f, g, h, a, K(0x4c191d76ul));
219 
220  w0 = Add(t0, a);
221  w1 = Add(t1, b);
222  w2 = Add(t2, c);
223  w3 = Add(t3, d);
224  w4 = Add(t4, e);
225  w5 = Add(t5, f);
226  w6 = Add(t6, g);
227  w7 = Add(t7, h);
228 
229  // Transform 3
230  a = K(0x6a09e667ul);
231  b = K(0xbb67ae85ul);
232  c = K(0x3c6ef372ul);
233  d = K(0xa54ff53aul);
234  e = K(0x510e527ful);
235  f = K(0x9b05688cul);
236  g = K(0x1f83d9abul);
237  h = K(0x5be0cd19ul);
238 
239  Round(a, b, c, d, e, f, g, h, Add(K(0x428a2f98ul), w0));
240  Round(h, a, b, c, d, e, f, g, Add(K(0x71374491ul), w1));
241  Round(g, h, a, b, c, d, e, f, Add(K(0xb5c0fbcful), w2));
242  Round(f, g, h, a, b, c, d, e, Add(K(0xe9b5dba5ul), w3));
243  Round(e, f, g, h, a, b, c, d, Add(K(0x3956c25bul), w4));
244  Round(d, e, f, g, h, a, b, c, Add(K(0x59f111f1ul), w5));
245  Round(c, d, e, f, g, h, a, b, Add(K(0x923f82a4ul), w6));
246  Round(b, c, d, e, f, g, h, a, Add(K(0xab1c5ed5ul), w7));
247  Round(a, b, c, d, e, f, g, h, K(0x5807aa98ul));
248  Round(h, a, b, c, d, e, f, g, K(0x12835b01ul));
249  Round(g, h, a, b, c, d, e, f, K(0x243185beul));
250  Round(f, g, h, a, b, c, d, e, K(0x550c7dc3ul));
251  Round(e, f, g, h, a, b, c, d, K(0x72be5d74ul));
252  Round(d, e, f, g, h, a, b, c, K(0x80deb1feul));
253  Round(c, d, e, f, g, h, a, b, K(0x9bdc06a7ul));
254  Round(b, c, d, e, f, g, h, a, K(0xc19bf274ul));
255  Round(a, b, c, d, e, f, g, h, Add(K(0xe49b69c1ul), Inc(w0, sigma0(w1))));
256  Round(h, a, b, c, d, e, f, g, Add(K(0xefbe4786ul), Inc(w1, K(0xa00000ul), sigma0(w2))));
257  Round(g, h, a, b, c, d, e, f, Add(K(0x0fc19dc6ul), Inc(w2, sigma1(w0), sigma0(w3))));
258  Round(f, g, h, a, b, c, d, e, Add(K(0x240ca1ccul), Inc(w3, sigma1(w1), sigma0(w4))));
259  Round(e, f, g, h, a, b, c, d, Add(K(0x2de92c6ful), Inc(w4, sigma1(w2), sigma0(w5))));
260  Round(d, e, f, g, h, a, b, c, Add(K(0x4a7484aaul), Inc(w5, sigma1(w3), sigma0(w6))));
261  Round(c, d, e, f, g, h, a, b, Add(K(0x5cb0a9dcul), Inc(w6, sigma1(w4), K(0x100ul), sigma0(w7))));
262  Round(b, c, d, e, f, g, h, a, Add(K(0x76f988daul), Inc(w7, sigma1(w5), w0, K(0x11002000ul))));
263  Round(a, b, c, d, e, f, g, h, Add(K(0x983e5152ul), w8 = Add(K(0x80000000ul), sigma1(w6), w1)));
264  Round(h, a, b, c, d, e, f, g, Add(K(0xa831c66dul), w9 = Add(sigma1(w7), w2)));
265  Round(g, h, a, b, c, d, e, f, Add(K(0xb00327c8ul), w10 = Add(sigma1(w8), w3)));
266  Round(f, g, h, a, b, c, d, e, Add(K(0xbf597fc7ul), w11 = Add(sigma1(w9), w4)));
267  Round(e, f, g, h, a, b, c, d, Add(K(0xc6e00bf3ul), w12 = Add(sigma1(w10), w5)));
268  Round(d, e, f, g, h, a, b, c, Add(K(0xd5a79147ul), w13 = Add(sigma1(w11), w6)));
269  Round(c, d, e, f, g, h, a, b, Add(K(0x06ca6351ul), w14 = Add(sigma1(w12), w7, K(0x400022ul))));
270  Round(b, c, d, e, f, g, h, a, Add(K(0x14292967ul), w15 = Add(K(0x100ul), sigma1(w13), w8, sigma0(w0))));
271  Round(a, b, c, d, e, f, g, h, Add(K(0x27b70a85ul), Inc(w0, sigma1(w14), w9, sigma0(w1))));
272  Round(h, a, b, c, d, e, f, g, Add(K(0x2e1b2138ul), Inc(w1, sigma1(w15), w10, sigma0(w2))));
273  Round(g, h, a, b, c, d, e, f, Add(K(0x4d2c6dfcul), Inc(w2, sigma1(w0), w11, sigma0(w3))));
274  Round(f, g, h, a, b, c, d, e, Add(K(0x53380d13ul), Inc(w3, sigma1(w1), w12, sigma0(w4))));
275  Round(e, f, g, h, a, b, c, d, Add(K(0x650a7354ul), Inc(w4, sigma1(w2), w13, sigma0(w5))));
276  Round(d, e, f, g, h, a, b, c, Add(K(0x766a0abbul), Inc(w5, sigma1(w3), w14, sigma0(w6))));
277  Round(c, d, e, f, g, h, a, b, Add(K(0x81c2c92eul), Inc(w6, sigma1(w4), w15, sigma0(w7))));
278  Round(b, c, d, e, f, g, h, a, Add(K(0x92722c85ul), Inc(w7, sigma1(w5), w0, sigma0(w8))));
279  Round(a, b, c, d, e, f, g, h, Add(K(0xa2bfe8a1ul), Inc(w8, sigma1(w6), w1, sigma0(w9))));
280  Round(h, a, b, c, d, e, f, g, Add(K(0xa81a664bul), Inc(w9, sigma1(w7), w2, sigma0(w10))));
281  Round(g, h, a, b, c, d, e, f, Add(K(0xc24b8b70ul), Inc(w10, sigma1(w8), w3, sigma0(w11))));
282  Round(f, g, h, a, b, c, d, e, Add(K(0xc76c51a3ul), Inc(w11, sigma1(w9), w4, sigma0(w12))));
283  Round(e, f, g, h, a, b, c, d, Add(K(0xd192e819ul), Inc(w12, sigma1(w10), w5, sigma0(w13))));
284  Round(d, e, f, g, h, a, b, c, Add(K(0xd6990624ul), Inc(w13, sigma1(w11), w6, sigma0(w14))));
285  Round(c, d, e, f, g, h, a, b, Add(K(0xf40e3585ul), Inc(w14, sigma1(w12), w7, sigma0(w15))));
286  Round(b, c, d, e, f, g, h, a, Add(K(0x106aa070ul), Inc(w15, sigma1(w13), w8, sigma0(w0))));
287  Round(a, b, c, d, e, f, g, h, Add(K(0x19a4c116ul), Inc(w0, sigma1(w14), w9, sigma0(w1))));
288  Round(h, a, b, c, d, e, f, g, Add(K(0x1e376c08ul), Inc(w1, sigma1(w15), w10, sigma0(w2))));
289  Round(g, h, a, b, c, d, e, f, Add(K(0x2748774cul), Inc(w2, sigma1(w0), w11, sigma0(w3))));
290  Round(f, g, h, a, b, c, d, e, Add(K(0x34b0bcb5ul), Inc(w3, sigma1(w1), w12, sigma0(w4))));
291  Round(e, f, g, h, a, b, c, d, Add(K(0x391c0cb3ul), Inc(w4, sigma1(w2), w13, sigma0(w5))));
292  Round(d, e, f, g, h, a, b, c, Add(K(0x4ed8aa4aul), Inc(w5, sigma1(w3), w14, sigma0(w6))));
293  Round(c, d, e, f, g, h, a, b, Add(K(0x5b9cca4ful), Inc(w6, sigma1(w4), w15, sigma0(w7))));
294  Round(b, c, d, e, f, g, h, a, Add(K(0x682e6ff3ul), Inc(w7, sigma1(w5), w0, sigma0(w8))));
295  Round(a, b, c, d, e, f, g, h, Add(K(0x748f82eeul), Inc(w8, sigma1(w6), w1, sigma0(w9))));
296  Round(h, a, b, c, d, e, f, g, Add(K(0x78a5636ful), Inc(w9, sigma1(w7), w2, sigma0(w10))));
297  Round(g, h, a, b, c, d, e, f, Add(K(0x84c87814ul), Inc(w10, sigma1(w8), w3, sigma0(w11))));
298  Round(f, g, h, a, b, c, d, e, Add(K(0x8cc70208ul), Inc(w11, sigma1(w9), w4, sigma0(w12))));
299  Round(e, f, g, h, a, b, c, d, Add(K(0x90befffaul), Inc(w12, sigma1(w10), w5, sigma0(w13))));
300  Round(d, e, f, g, h, a, b, c, Add(K(0xa4506cebul), Inc(w13, sigma1(w11), w6, sigma0(w14))));
301  Round(c, d, e, f, g, h, a, b, Add(K(0xbef9a3f7ul), w14, sigma1(w12), w7, sigma0(w15)));
302  Round(b, c, d, e, f, g, h, a, Add(K(0xc67178f2ul), w15, sigma1(w13), w8, sigma0(w0)));
303 
304  // Output
305  Write4(out, 0, Add(a, K(0x6a09e667ul)));
306  Write4(out, 4, Add(b, K(0xbb67ae85ul)));
307  Write4(out, 8, Add(c, K(0x3c6ef372ul)));
308  Write4(out, 12, Add(d, K(0xa54ff53aul)));
309  Write4(out, 16, Add(e, K(0x510e527ful)));
310  Write4(out, 20, Add(f, K(0x9b05688cul)));
311  Write4(out, 24, Add(g, K(0x1f83d9abul)));
312  Write4(out, 28, Add(h, K(0x5be0cd19ul)));
313 }
314 
315 }
316 
317 #endif
#define Round(a, b, c, d, e, f, g, h, k, w)
Definition: hash_impl.h:23
#define Maj(x, y, z)
Definition: hash_impl.h:17
static __attribute__((noinline)) std
static void WriteLE32(unsigned char *ptr, uint32_t x)
Definition: common.h:44
#define sigma1(x)
Definition: hash_impl.h:21
#define sigma0(x)
Definition: hash_impl.h:20
#define Sigma0(x)
Definition: hash_impl.h:18
static uint32_t ReadLE32(const unsigned char *ptr)
Definition: common.h:24
#define Sigma1(x)
Definition: hash_impl.h:19
#define Ch(x, y, z)
Definition: hash_impl.h:16
void Transform_4way(unsigned char *out, const unsigned char *in)
Released under the MIT license