Initial commit
[hashcat.git] / nv / m09100.cu
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _LOTUS8_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #ifdef  VLIW1
12 #define VECT_SIZE1
13 #endif
14
15 #ifdef  VLIW2
16 #define VECT_SIZE1
17 #endif
18
19 #define DGST_R0 0
20 #define DGST_R1 1
21 #define DGST_R2 2
22 #define DGST_R3 3
23
24 #include "include/kernel_functions.c"
25
26 #undef _SHA1_
27
28 #include "types_nv.c"
29 #include "common_nv.c"
30
31 #ifdef  VECT_SIZE1
32 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
33 #endif
34
35 #ifdef  VECT_SIZE2
36 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
37 #endif
38
39 __device__ __constant__ u32 lotus_magic_table[256] =
40 {
41   0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a,
42   0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0,
43   0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b,
44   0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a,
45   0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda,
46   0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36,
47   0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8,
48   0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c,
49   0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17,
50   0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60,
51   0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72,
52   0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa,
53   0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd,
54   0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e,
55   0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b,
56   0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf,
57   0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77,
58   0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6,
59   0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3,
60   0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3,
61   0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e,
62   0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c,
63   0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d,
64   0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2,
65   0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46,
66   0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5,
67   0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97,
68   0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5,
69   0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef,
70   0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f,
71   0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf,
72   0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab,
73 };
74
75 #ifdef VECT_SIZE1
76 #define BOX(S,i) u32x ((S)[(i)])
77 #endif
78
79 #ifdef VECT_SIZE2
80 #define BOX(S,i) u32x ((S)[(i).x], (S)[(i).y])
81 #endif
82
83 #ifdef VECT_SIZE1
84 #define uint_to_hex_upper8(i) l_bin2asc[(i)]
85 #endif
86
87 #ifdef VECT_SIZE2
88 #define uint_to_hex_upper8(i) u32x (l_bin2asc[(i).x], l_bin2asc[(i).y])
89 #endif
90
91 __device__ static void lotus_mix (u32x *in, u32 s_lotus_magic_table[256])
92 {
93   u32x p = 0;
94
95   for (int i = 0; i < 18; i++)
96   {
97     u32 s = 48;
98
99     #pragma unroll 12
100     for (int j = 0; j < 12; j++)
101     {
102       u32x tmp_in = in[j];
103       u32x tmp_out = 0;
104
105       p = (p + s--) & 0xff; p = ((tmp_in >>  0) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  0;
106       p = (p + s--) & 0xff; p = ((tmp_in >>  8) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  8;
107       p = (p + s--) & 0xff; p = ((tmp_in >> 16) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 16;
108       p = (p + s--) & 0xff; p = ((tmp_in >> 24) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 24;
109
110       in[j] = tmp_out;
111     }
112   }
113 }
114
115 __device__ static void lotus_transform_password (u32x *in, u32x *out, u32 s_lotus_magic_table[256])
116 {
117   u32x t = out[3] >> 24;
118
119   u32x c;
120
121   #pragma unroll 4
122   for (int i = 0; i < 4; i++)
123   {
124     t ^= (in[i] >>  0) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  0; t = ((out[i] >>  0) & 0xff);
125     t ^= (in[i] >>  8) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  8; t = ((out[i] >>  8) & 0xff);
126     t ^= (in[i] >> 16) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 16; t = ((out[i] >> 16) & 0xff);
127     t ^= (in[i] >> 24) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 24; t = ((out[i] >> 24) & 0xff);
128   }
129 }
130
131 __device__ static void pad (u32x w[4], const u32 len)
132 {
133   const u32 val = 16 - len;
134
135   const u32 mask1 = val << 24;
136
137   const u32 mask2 = val << 16
138                    | val << 24;
139
140   const u32 mask3 = val <<  8
141                    | val << 16
142                    | val << 24;
143
144   const u32 mask4 = val <<  0
145                    | val <<  8
146                    | val << 16
147                    | val << 24;
148
149   switch (len)
150   {
151     case  0:  w[0]  = mask4;
152               w[1]  = mask4;
153               w[2]  = mask4;
154               w[3]  = mask4;
155               break;
156     case  1:  w[0] |= mask3;
157               w[1]  = mask4;
158               w[2]  = mask4;
159               w[3]  = mask4;
160               break;
161     case  2:  w[0] |= mask2;
162               w[1]  = mask4;
163               w[2]  = mask4;
164               w[3]  = mask4;
165               break;
166     case  3:  w[0] |= mask1;
167               w[1]  = mask4;
168               w[2]  = mask4;
169               w[3]  = mask4;
170               break;
171     case  4:  w[1]  = mask4;
172               w[2]  = mask4;
173               w[3]  = mask4;
174               break;
175     case  5:  w[1] |= mask3;
176               w[2]  = mask4;
177               w[3]  = mask4;
178               break;
179     case  6:  w[1] |= mask2;
180               w[2]  = mask4;
181               w[3]  = mask4;
182               break;
183     case  7:  w[1] |= mask1;
184               w[2]  = mask4;
185               w[3]  = mask4;
186               break;
187     case  8:  w[2]  = mask4;
188               w[3]  = mask4;
189               break;
190     case  9:  w[2] |= mask3;
191               w[3]  = mask4;
192               break;
193     case 10:  w[2] |= mask2;
194               w[3]  = mask4;
195               break;
196     case 11:  w[2] |= mask1;
197               w[3]  = mask4;
198               break;
199     case 12:  w[3]  = mask4;
200               break;
201     case 13:  w[3] |= mask3;
202               break;
203     case 14:  w[3] |= mask2;
204               break;
205     case 15:  w[3] |= mask1;
206               break;
207   }
208 }
209
210 __device__ static void mdtransform_norecalc (u32x state[4], u32x block[4], u32 s_lotus_magic_table[256])
211 {
212   u32x x[12];
213
214   x[ 0] = state[0];
215   x[ 1] = state[1];
216   x[ 2] = state[2];
217   x[ 3] = state[3];
218   x[ 4] = block[0];
219   x[ 5] = block[1];
220   x[ 6] = block[2];
221   x[ 7] = block[3];
222   x[ 8] = state[0] ^ block[0];
223   x[ 9] = state[1] ^ block[1];
224   x[10] = state[2] ^ block[2];
225   x[11] = state[3] ^ block[3];
226
227   lotus_mix (x, s_lotus_magic_table);
228
229   state[0] = x[0];
230   state[1] = x[1];
231   state[2] = x[2];
232   state[3] = x[3];
233 }
234
235 __device__ static void mdtransform (u32x state[4], u32x checksum[4], u32x block[4], u32 s_lotus_magic_table[256])
236 {
237   mdtransform_norecalc (state, block, s_lotus_magic_table);
238
239   lotus_transform_password (block, checksum, s_lotus_magic_table);
240 }
241
242 __device__ static void domino_big_md (const u32x saved_key[16], const u32 size, u32x state[4], u32 s_lotus_magic_table[256])
243 {
244   u32x checksum[4];
245
246   checksum[0] = 0;
247   checksum[1] = 0;
248   checksum[2] = 0;
249   checksum[3] = 0;
250
251   u32x block[4];
252
253   block[0] = 0;
254   block[1] = 0;
255   block[2] = 0;
256   block[3] = 0;
257
258   u32 curpos;
259   u32 idx;
260
261   for (curpos = 0, idx = 0; curpos + 16 < size; curpos += 16, idx += 4)
262   {
263     block[0] = saved_key[idx + 0];
264     block[1] = saved_key[idx + 1];
265     block[2] = saved_key[idx + 2];
266     block[3] = saved_key[idx + 3];
267
268     mdtransform (state, checksum, block, s_lotus_magic_table);
269   }
270
271   block[0] = saved_key[idx + 0];
272   block[1] = saved_key[idx + 1];
273   block[2] = saved_key[idx + 2];
274   block[3] = saved_key[idx + 3];
275
276   mdtransform (state, checksum, block, s_lotus_magic_table);
277
278   mdtransform_norecalc (state, checksum, s_lotus_magic_table);
279 }
280
281 __device__ static void sha1_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[5])
282 {
283   u32x A = digest[0];
284   u32x B = digest[1];
285   u32x C = digest[2];
286   u32x D = digest[3];
287   u32x E = digest[4];
288
289   u32x w0_t = w0[0];
290   u32x w1_t = w0[1];
291   u32x w2_t = w0[2];
292   u32x w3_t = w0[3];
293   u32x w4_t = w1[0];
294   u32x w5_t = w1[1];
295   u32x w6_t = w1[2];
296   u32x w7_t = w1[3];
297   u32x w8_t = w2[0];
298   u32x w9_t = w2[1];
299   u32x wa_t = w2[2];
300   u32x wb_t = w2[3];
301   u32x wc_t = w3[0];
302   u32x wd_t = w3[1];
303   u32x we_t = w3[2];
304   u32x wf_t = w3[3];
305
306   #undef K
307   #define K SHA1C00
308
309   SHA1_STEP (SHA1_F0o, A, B, C, D, E, w0_t);
310   SHA1_STEP (SHA1_F0o, E, A, B, C, D, w1_t);
311   SHA1_STEP (SHA1_F0o, D, E, A, B, C, w2_t);
312   SHA1_STEP (SHA1_F0o, C, D, E, A, B, w3_t);
313   SHA1_STEP (SHA1_F0o, B, C, D, E, A, w4_t);
314   SHA1_STEP (SHA1_F0o, A, B, C, D, E, w5_t);
315   SHA1_STEP (SHA1_F0o, E, A, B, C, D, w6_t);
316   SHA1_STEP (SHA1_F0o, D, E, A, B, C, w7_t);
317   SHA1_STEP (SHA1_F0o, C, D, E, A, B, w8_t);
318   SHA1_STEP (SHA1_F0o, B, C, D, E, A, w9_t);
319   SHA1_STEP (SHA1_F0o, A, B, C, D, E, wa_t);
320   SHA1_STEP (SHA1_F0o, E, A, B, C, D, wb_t);
321   SHA1_STEP (SHA1_F0o, D, E, A, B, C, wc_t);
322   SHA1_STEP (SHA1_F0o, C, D, E, A, B, wd_t);
323   SHA1_STEP (SHA1_F0o, B, C, D, E, A, we_t);
324   SHA1_STEP (SHA1_F0o, A, B, C, D, E, wf_t);
325   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, E, A, B, C, D, w0_t);
326   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, D, E, A, B, C, w1_t);
327   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, C, D, E, A, B, w2_t);
328   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, B, C, D, E, A, w3_t);
329
330   #undef K
331   #define K SHA1C01
332
333   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w4_t);
334   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w5_t);
335   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w6_t);
336   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w7_t);
337   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w8_t);
338   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w9_t);
339   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wa_t);
340   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, wb_t);
341   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, wc_t);
342   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wd_t);
343   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, we_t);
344   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wf_t);
345   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w0_t);
346   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w1_t);
347   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w2_t);
348   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w3_t);
349   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w4_t);
350   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w5_t);
351   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w6_t);
352   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w7_t);
353
354   #undef K
355   #define K SHA1C02
356
357   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w8_t);
358   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w9_t);
359   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, wa_t);
360   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, wb_t);
361   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, wc_t);
362   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, wd_t);
363   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, we_t);
364   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, wf_t);
365   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, w0_t);
366   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, w1_t);
367   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w2_t);
368   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w3_t);
369   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, w4_t);
370   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, w5_t);
371   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, w6_t);
372   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w7_t);
373   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w8_t);
374   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, w9_t);
375   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, wa_t);
376   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, wb_t);
377
378   #undef K
379   #define K SHA1C03
380
381   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, wc_t);
382   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wd_t);
383   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, we_t);
384   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, wf_t);
385   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w0_t);
386   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w1_t);
387   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w2_t);
388   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w3_t);
389   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w4_t);
390   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w5_t);
391   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w6_t);
392   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w7_t);
393   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w8_t);
394   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w9_t);
395   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wa_t);
396   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, wb_t);
397   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wc_t);
398   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, wd_t);
399   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, we_t);
400   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wf_t);
401
402   digest[0] += A;
403   digest[1] += B;
404   digest[2] += C;
405   digest[3] += D;
406   digest[4] += E;
407 }
408
409 __device__ static void hmac_sha1_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[5], u32x opad[5])
410 {
411   w0[0] = w0[0] ^ 0x36363636;
412   w0[1] = w0[1] ^ 0x36363636;
413   w0[2] = w0[2] ^ 0x36363636;
414   w0[3] = w0[3] ^ 0x36363636;
415   w1[0] = w1[0] ^ 0x36363636;
416   w1[1] = w1[1] ^ 0x36363636;
417   w1[2] = w1[2] ^ 0x36363636;
418   w1[3] = w1[3] ^ 0x36363636;
419   w2[0] = w2[0] ^ 0x36363636;
420   w2[1] = w2[1] ^ 0x36363636;
421   w2[2] = w2[2] ^ 0x36363636;
422   w2[3] = w2[3] ^ 0x36363636;
423   w3[0] = w3[0] ^ 0x36363636;
424   w3[1] = w3[1] ^ 0x36363636;
425   w3[2] = w3[2] ^ 0x36363636;
426   w3[3] = w3[3] ^ 0x36363636;
427
428   ipad[0] = SHA1M_A;
429   ipad[1] = SHA1M_B;
430   ipad[2] = SHA1M_C;
431   ipad[3] = SHA1M_D;
432   ipad[4] = SHA1M_E;
433
434   sha1_transform (w0, w1, w2, w3, ipad);
435
436   w0[0] = w0[0] ^ 0x6a6a6a6a;
437   w0[1] = w0[1] ^ 0x6a6a6a6a;
438   w0[2] = w0[2] ^ 0x6a6a6a6a;
439   w0[3] = w0[3] ^ 0x6a6a6a6a;
440   w1[0] = w1[0] ^ 0x6a6a6a6a;
441   w1[1] = w1[1] ^ 0x6a6a6a6a;
442   w1[2] = w1[2] ^ 0x6a6a6a6a;
443   w1[3] = w1[3] ^ 0x6a6a6a6a;
444   w2[0] = w2[0] ^ 0x6a6a6a6a;
445   w2[1] = w2[1] ^ 0x6a6a6a6a;
446   w2[2] = w2[2] ^ 0x6a6a6a6a;
447   w2[3] = w2[3] ^ 0x6a6a6a6a;
448   w3[0] = w3[0] ^ 0x6a6a6a6a;
449   w3[1] = w3[1] ^ 0x6a6a6a6a;
450   w3[2] = w3[2] ^ 0x6a6a6a6a;
451   w3[3] = w3[3] ^ 0x6a6a6a6a;
452
453   opad[0] = SHA1M_A;
454   opad[1] = SHA1M_B;
455   opad[2] = SHA1M_C;
456   opad[3] = SHA1M_D;
457   opad[4] = SHA1M_E;
458
459   sha1_transform (w0, w1, w2, w3, opad);
460 }
461
462 __device__ static void hmac_sha1_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[5], u32x opad[5], u32x digest[5])
463 {
464   digest[0] = ipad[0];
465   digest[1] = ipad[1];
466   digest[2] = ipad[2];
467   digest[3] = ipad[3];
468   digest[4] = ipad[4];
469
470   sha1_transform (w0, w1, w2, w3, digest);
471
472   w0[0] = digest[0];
473   w0[1] = digest[1];
474   w0[2] = digest[2];
475   w0[3] = digest[3];
476   w1[0] = digest[4];
477   w1[1] = 0x80000000;
478   w1[2] = 0;
479   w1[3] = 0;
480   w2[0] = 0;
481   w2[1] = 0;
482   w2[2] = 0;
483   w2[3] = 0;
484   w3[0] = 0;
485   w3[1] = 0;
486   w3[2] = 0;
487   w3[3] = (64 + 20) * 8;
488
489   digest[0] = opad[0];
490   digest[1] = opad[1];
491   digest[2] = opad[2];
492   digest[3] = opad[3];
493   digest[4] = opad[4];
494
495   sha1_transform (w0, w1, w2, w3, digest);
496 }
497
498 __device__ static void base64_encode (u8 *base64_hash, const u32 len, const u8 *base64_plain)
499 {
500   u8 *out_ptr = (u8 *) base64_hash;
501   u8 *in_ptr  = (u8 *) base64_plain;
502
503   char *lotus64_table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
504
505   u32 i;
506
507   for (i = 0; i < len; i += 3)
508   {
509     char out_val0 = lotus64_table [                            ((in_ptr[0] >> 2) & 0x3f)];
510     char out_val1 = lotus64_table [((in_ptr[0] << 4) & 0x30) | ((in_ptr[1] >> 4) & 0x0f)];
511     char out_val2 = lotus64_table [((in_ptr[1] << 2) & 0x3c) | ((in_ptr[2] >> 6) & 0x03)];
512     char out_val3 = lotus64_table [                            ((in_ptr[2] >> 0) & 0x3f)];
513
514     out_ptr[0] = out_val0 & 0x7f;
515     out_ptr[1] = out_val1 & 0x7f;
516     out_ptr[2] = out_val2 & 0x7f;
517     out_ptr[3] = out_val3 & 0x7f;
518
519     in_ptr  += 3;
520     out_ptr += 4;
521   }
522 }
523
524 __device__ static void lotus6_base64_encode (u8 base64_hash[24], const u32 salt0, const u32 salt1, u32x a, u32x b, u32x c)
525 {
526   u8 *salt0_ptr = (u8 *) &salt0;
527   u8 *salt1_ptr = (u8 *) &salt1;
528
529   u8 *a_ptr = (u8 *) &a;
530   u8 *b_ptr = (u8 *) &b;
531   u8 *c_ptr = (u8 *) &c;
532
533   /*
534    * Copy $salt.$digest to a tmp buffer
535    */
536
537   u8 base64_plain[16];
538
539   base64_plain[ 0] = salt0_ptr[0];
540   base64_plain[ 1] = salt0_ptr[1];
541   base64_plain[ 2] = salt0_ptr[2];
542   base64_plain[ 3] = salt0_ptr[3];
543
544   base64_plain[3] -= -4; // dont ask!
545
546   base64_plain[ 4] = salt1_ptr[0];
547
548   base64_plain[ 5] = a_ptr[0];
549   base64_plain[ 6] = a_ptr[1];
550   base64_plain[ 7] = a_ptr[2];
551   base64_plain[ 8] = a_ptr[3];
552
553   base64_plain[ 9] = b_ptr[0];
554   base64_plain[10] = b_ptr[1];
555   base64_plain[11] = b_ptr[2];
556   base64_plain[12] = b_ptr[3];
557
558   base64_plain[13] = c_ptr[0];
559   base64_plain[14] = c_ptr[1];
560   base64_plain[15] = c_ptr[2];
561
562   /*
563    * base64 encode the $salt.$digest string
564    */
565
566   base64_hash[ 0] = '(';
567   base64_hash[ 1] = 'G';
568
569   base64_encode (base64_hash + 2, 14, base64_plain);
570
571   base64_hash[21] = ')';
572 }
573
574 __device__ __constant__ char c_bin2asc[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
575
576 __device__ __shared__ short l_bin2asc[256];
577
578 extern "C" __global__ void __launch_bounds__ (256, 1) m09100_init (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, lotus8_tmp_t *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
579 {
580   /**
581    * base
582    */
583
584   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
585   const u32 lid = threadIdx.x;
586
587   /**
588    * bin2asc table
589    */
590
591   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
592                  | c_bin2asc[(lid >> 4) & 15] << 0;
593
594   __syncthreads ();
595
596   /**
597    * sbox
598    */
599
600   __shared__ u32 s_lotus_magic_table[256];
601
602   s_lotus_magic_table[lid] = lotus_magic_table[lid];
603
604   __syncthreads ();
605
606   if (gid >= gid_max) return;
607
608
609   u32x w[16];
610
611   w[ 0] = pws[gid].i[ 0];
612   w[ 1] = pws[gid].i[ 1];
613   w[ 2] = pws[gid].i[ 2];
614   w[ 3] = pws[gid].i[ 3];
615
616   w[ 4] = pws[gid].i[ 4];
617   w[ 5] = pws[gid].i[ 5];
618   w[ 6] = pws[gid].i[ 6];
619   w[ 7] = pws[gid].i[ 7];
620
621   w[ 8] = pws[gid].i[ 8];
622   w[ 9] = pws[gid].i[ 9];
623   w[10] = pws[gid].i[10];
624   w[11] = pws[gid].i[11];
625
626   w[12] = pws[gid].i[12];
627   w[13] = pws[gid].i[13];
628   w[14] = pws[gid].i[14];
629   w[15] = pws[gid].i[15];
630
631   /**
632    * pad
633    */
634
635   u32 pw_len = pws[gid].pw_len;
636
637   if (pw_len < 16)
638   {
639     pad (&w[ 0], pw_len & 0xf);
640   }
641   else if (pw_len < 32)
642   {
643     pad (&w[ 4], pw_len & 0xf);
644   }
645   else if (pw_len < 48)
646   {
647     pad (&w[ 8], pw_len & 0xf);
648   }
649   else if (pw_len < 64)
650   {
651     pad (&w[12], pw_len & 0xf);
652   }
653
654   /**
655    * salt
656    */
657
658   u32 salt_len = salt_bufs[salt_pos].salt_len;
659
660   u32 salt_buf0[4];
661
662   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
663   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
664   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
665   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
666
667   u32 salt_buf1[4];
668
669   salt_buf1[0] = 0x01000000;
670   salt_buf1[1] = 0x00000080;
671   salt_buf1[2] = 0;
672   salt_buf1[3] = 0;
673
674   u32 salt_buf2[4];
675
676   salt_buf2[0] = 0;
677   salt_buf2[1] = 0;
678   salt_buf2[2] = 0;
679   salt_buf2[3] = 0;
680
681   u32 salt_buf3[4];
682
683   salt_buf3[0] = 0;
684   salt_buf3[1] = 0;
685   salt_buf3[2] = 0;
686   salt_buf3[3] = 0;
687
688   const u32 salt0 = salt_buf0[0];
689   const u32 salt1 = salt_buf0[1] & 0xff | '(' << 8;
690
691   /**
692    * Lotus 6 hash - SEC_pwddigest_V2
693    */
694
695   u32x w_tmp[16];
696
697   w_tmp[ 0] = w[ 0];
698   w_tmp[ 1] = w[ 1];
699   w_tmp[ 2] = w[ 2];
700   w_tmp[ 3] = w[ 3];
701   w_tmp[ 4] = w[ 4];
702   w_tmp[ 5] = w[ 5];
703   w_tmp[ 6] = w[ 6];
704   w_tmp[ 7] = w[ 7];
705   w_tmp[ 8] = w[ 8];
706   w_tmp[ 9] = w[ 9];
707   w_tmp[10] = w[10];
708   w_tmp[11] = w[11];
709   w_tmp[12] = w[12];
710   w_tmp[13] = w[13];
711   w_tmp[14] = w[14];
712   w_tmp[15] = w[15];
713
714   u32x state[4];
715
716   state[0] = 0;
717   state[1] = 0;
718   state[2] = 0;
719   state[3] = 0;
720
721   domino_big_md (w_tmp, pw_len, state, s_lotus_magic_table);
722
723   const u32x w0_t = uint_to_hex_upper8 ((state[0] >>  0) & 255) <<  0
724                    | uint_to_hex_upper8 ((state[0] >>  8) & 255) << 16;
725   const u32x w1_t = uint_to_hex_upper8 ((state[0] >> 16) & 255) <<  0
726                    | uint_to_hex_upper8 ((state[0] >> 24) & 255) << 16;
727   const u32x w2_t = uint_to_hex_upper8 ((state[1] >>  0) & 255) <<  0
728                    | uint_to_hex_upper8 ((state[1] >>  8) & 255) << 16;
729   const u32x w3_t = uint_to_hex_upper8 ((state[1] >> 16) & 255) <<  0
730                    | uint_to_hex_upper8 ((state[1] >> 24) & 255) << 16;
731   const u32x w4_t = uint_to_hex_upper8 ((state[2] >>  0) & 255) <<  0
732                    | uint_to_hex_upper8 ((state[2] >>  8) & 255) << 16;
733   const u32x w5_t = uint_to_hex_upper8 ((state[2] >> 16) & 255) <<  0
734                    | uint_to_hex_upper8 ((state[2] >> 24) & 255) << 16;
735   const u32x w6_t = uint_to_hex_upper8 ((state[3] >>  0) & 255) <<  0
736                    | uint_to_hex_upper8 ((state[3] >>  8) & 255) << 16;
737
738   const u32 pade = 0x0e0e0e0e;
739
740   w_tmp[ 0] = salt0;
741   w_tmp[ 1] = salt1      | w0_t << 16;
742   w_tmp[ 2] = w0_t >> 16 | w1_t << 16;
743   w_tmp[ 3] = w1_t >> 16 | w2_t << 16;
744   w_tmp[ 4] = w2_t >> 16 | w3_t << 16;
745   w_tmp[ 5] = w3_t >> 16 | w4_t << 16;
746   w_tmp[ 6] = w4_t >> 16 | w5_t << 16;
747   w_tmp[ 7] = w5_t >> 16 | w6_t << 16;
748   w_tmp[ 8] = w6_t >> 16 | pade << 16;
749   w_tmp[ 9] = pade;
750   w_tmp[10] = pade;
751   w_tmp[11] = pade;
752   w_tmp[12] = 0;
753   w_tmp[13] = 0;
754   w_tmp[14] = 0;
755   w_tmp[15] = 0;
756
757   state[0] = 0;
758   state[1] = 0;
759   state[2] = 0;
760   state[3] = 0;
761
762   domino_big_md (w_tmp, 34, state, s_lotus_magic_table);
763
764   u32x a = state[0];
765   u32x b = state[1];
766   u32x c = state[2];
767
768   /**
769    * Base64 encode
770    */
771
772   pw_len = 22;
773
774   u8 base64_hash[24]; // size 22 (=pw_len) is needed but base64 needs size divisible by 4
775
776   lotus6_base64_encode (base64_hash, salt_buf0[0], salt_buf0[1], a, b, c);
777
778
779   /**
780    * PBKDF2 - HMACSHA1 - 1st iteration
781    */
782
783   u32x w0[4];
784
785   w0[0] = (base64_hash[ 0] << 24) | (base64_hash[ 1] << 16) | (base64_hash[ 2] << 8) | base64_hash[ 3];
786   w0[1] = (base64_hash[ 4] << 24) | (base64_hash[ 5] << 16) | (base64_hash[ 6] << 8) | base64_hash[ 7];
787   w0[2] = (base64_hash[ 8] << 24) | (base64_hash[ 9] << 16) | (base64_hash[10] << 8) | base64_hash[11];
788   w0[3] = (base64_hash[12] << 24) | (base64_hash[13] << 16) | (base64_hash[14] << 8) | base64_hash[15];
789
790   u32x w1[4];
791
792   w1[0] = (base64_hash[16] << 24) | (base64_hash[17] << 16) | (base64_hash[18] << 8) | base64_hash[19];
793   w1[1] = (base64_hash[20] << 24) | (base64_hash[21] << 16);
794   w1[2] = 0;
795   w1[3] = 0;
796
797   u32x w2[4];
798
799   w2[0] = 0;
800   w2[1] = 0;
801   w2[2] = 0;
802   w2[3] = 0;
803
804   u32x w3[4];
805
806   w3[0] = 0;
807   w3[1] = 0;
808   w3[2] = 0;
809   w3[3] = 0;
810
811   /**
812    * pads
813    */
814
815   u32x ipad[5];
816   u32x opad[5];
817
818   hmac_sha1_pad (w0, w1, w2, w3, ipad, opad);
819
820   tmps[gid].ipad[0] = ipad[0];
821   tmps[gid].ipad[1] = ipad[1];
822   tmps[gid].ipad[2] = ipad[2];
823   tmps[gid].ipad[3] = ipad[3];
824   tmps[gid].ipad[4] = ipad[4];
825
826   tmps[gid].opad[0] = opad[0];
827   tmps[gid].opad[1] = opad[1];
828   tmps[gid].opad[2] = opad[2];
829   tmps[gid].opad[3] = opad[3];
830   tmps[gid].opad[4] = opad[4];
831
832   w0[0] = salt_buf0[0];
833   w0[1] = salt_buf0[1];
834   w0[2] = salt_buf0[2];
835   w0[3] = salt_buf0[3];
836   w1[0] = salt_buf1[0];
837   w1[1] = salt_buf1[1];
838   w1[2] = salt_buf1[2];
839   w1[3] = salt_buf1[3];
840   w2[0] = salt_buf2[0];
841   w2[1] = salt_buf2[1];
842   w2[2] = salt_buf2[2];
843   w2[3] = salt_buf2[3];
844   w3[0] = salt_buf3[0];
845   w3[1] = salt_buf3[1];
846   w3[2] = salt_buf3[2];
847   //w3[3] = salt_buf3[3];
848
849   w0[0] = swap_workaround (w0[0]);
850   w0[1] = swap_workaround (w0[1]);
851   w0[2] = swap_workaround (w0[2]);
852   w0[3] = swap_workaround (w0[3]);
853   w1[0] = swap_workaround (w1[0]);
854   w1[1] = swap_workaround (w1[1]);
855   w1[2] = swap_workaround (w1[2]);
856   w1[3] = swap_workaround (w1[3]);
857   w2[0] = swap_workaround (w2[0]);
858   w2[1] = swap_workaround (w2[1]);
859   w2[2] = swap_workaround (w2[2]);
860   w2[3] = swap_workaround (w2[3]);
861   w3[0] = swap_workaround (w3[0]);
862   w3[1] = swap_workaround (w3[1]);
863   w3[2] = swap_workaround (w3[2]);
864   w3[3] = (64 + salt_len + 4) * 8;
865
866   u32x dgst[5];
867
868   hmac_sha1_run (w0, w1, w2, w3, ipad, opad, dgst);
869
870   tmps[gid].dgst[0] = dgst[0];
871   tmps[gid].dgst[1] = dgst[1];
872   tmps[gid].dgst[2] = dgst[2];
873   tmps[gid].dgst[3] = dgst[3];
874   tmps[gid].dgst[4] = dgst[4];
875
876   tmps[gid].out[0] = dgst[0];
877   tmps[gid].out[1] = dgst[1];
878   tmps[gid].out[2] = dgst[2];
879   tmps[gid].out[3] = dgst[3];
880   tmps[gid].out[4] = dgst[4];
881 }
882
883 extern "C" __global__ void __launch_bounds__ (256, 1) m09100_loop (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, lotus8_tmp_t *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
884 {
885   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
886
887   if (gid >= gid_max) return;
888
889   u32x ipad[5];
890   u32x opad[5];
891
892   ipad[0] = tmps[gid].ipad[0];
893   ipad[1] = tmps[gid].ipad[1];
894   ipad[2] = tmps[gid].ipad[2];
895   ipad[3] = tmps[gid].ipad[3];
896   ipad[4] = tmps[gid].ipad[4];
897
898   opad[0] = tmps[gid].opad[0];
899   opad[1] = tmps[gid].opad[1];
900   opad[2] = tmps[gid].opad[2];
901   opad[3] = tmps[gid].opad[3];
902   opad[4] = tmps[gid].opad[4];
903
904   u32x dgst[5];
905   u32x out[5];
906
907   dgst[0] = tmps[gid].dgst[0];
908   dgst[1] = tmps[gid].dgst[1];
909   dgst[2] = tmps[gid].dgst[2];
910   dgst[3] = tmps[gid].dgst[3];
911   dgst[4] = tmps[gid].dgst[4];
912
913   out[0] = tmps[gid].out[0];
914   out[1] = tmps[gid].out[1];
915   out[2] = tmps[gid].out[2];
916   out[3] = tmps[gid].out[3];
917   out[4] = tmps[gid].out[4];
918
919   for (u32 j = 0; j < loop_cnt; j++)
920   {
921     u32x w0[4];
922     u32x w1[4];
923     u32x w2[4];
924     u32x w3[4];
925
926     w0[0] = dgst[0];
927     w0[1] = dgst[1];
928     w0[2] = dgst[2];
929     w0[3] = dgst[3];
930     w1[0] = dgst[4];
931     w1[1] = 0x80000000;
932     w1[2] = 0;
933     w1[3] = 0;
934     w2[0] = 0;
935     w2[1] = 0;
936     w2[2] = 0;
937     w2[3] = 0;
938     w3[0] = 0;
939     w3[1] = 0;
940     w3[2] = 0;
941     w3[3] = (64 + 20) * 8;
942
943     hmac_sha1_run (w0, w1, w2, w3, ipad, opad, dgst);
944
945     out[0] ^= dgst[0];
946     out[1] ^= dgst[1];
947     out[2] ^= dgst[2];
948     out[3] ^= dgst[3];
949     out[4] ^= dgst[4];
950   }
951
952   tmps[gid].dgst[0] = dgst[0];
953   tmps[gid].dgst[1] = dgst[1];
954   tmps[gid].dgst[2] = dgst[2];
955   tmps[gid].dgst[3] = dgst[3];
956   tmps[gid].dgst[4] = dgst[4];
957
958   tmps[gid].out[0] = out[0];
959   tmps[gid].out[1] = out[1];
960   tmps[gid].out[2] = out[2];
961   tmps[gid].out[3] = out[3];
962   tmps[gid].out[4] = out[4];
963 }
964
965 extern "C" __global__ void __launch_bounds__ (256, 1) m09100_comp (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, lotus8_tmp_t *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
966 {
967   /**
968    * base
969    */
970
971   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
972
973   if (gid >= gid_max) return;
974
975   const u32 lid = threadIdx.x;
976
977   /**
978    * digest
979    */
980
981   const u32x r0 = tmps[gid].out[DGST_R0];
982   const u32x r1 = tmps[gid].out[DGST_R1];
983   const u32x r2 = 0;
984   const u32x r3 = 0;
985
986   #define il_pos 0
987
988   #include VECT_COMPARE_M
989 }