Initial commit
[hashcat.git] / nv / m08700_a3.cu
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _LOTUS6_
7 #define _SCALAR_
8
9 #include "include/constants.h"
10 #include "include/kernel_vendor.h"
11
12 #ifdef  VLIW1
13 #define VECT_SIZE1
14 #endif
15
16 #ifdef  VLIW2
17 #define VECT_SIZE1
18 #endif
19
20 #define DGST_R0 0
21 #define DGST_R1 1
22 #define DGST_R2 2
23 #define DGST_R3 3
24
25 #include "include/kernel_functions.c"
26 #include "types_nv.c"
27 #include "common_nv.c"
28
29 #ifdef  VECT_SIZE1
30 #define VECT_COMPARE_S "check_single_vect1_comp4_warp.c"
31 #define VECT_COMPARE_M "check_multi_vect1_comp4_warp.c"
32 #endif
33
34 #ifdef  VECT_SIZE2
35 #define VECT_COMPARE_S "check_single_vect2_comp4_warp.c"
36 #define VECT_COMPARE_M "check_multi_vect2_comp4_warp.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__ __constant__ char c_bin2asc[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
92
93 __device__ __shared__ short l_bin2asc[256];
94
95 __device__ static void lotus_mix (u32x *in, u32 s_lotus_magic_table[256])
96 {
97   u32x p = 0;
98
99   for (int i = 0; i < 18; i++)
100   {
101     u32 s = 48;
102
103     #pragma unroll 12
104     for (int j = 0; j < 12; j++)
105     {
106       u32x tmp_in = in[j];
107       u32x tmp_out = 0;
108
109       p = (p + s--) & 0xff; p = ((tmp_in >>  0) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  0;
110       p = (p + s--) & 0xff; p = ((tmp_in >>  8) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  8;
111       p = (p + s--) & 0xff; p = ((tmp_in >> 16) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 16;
112       p = (p + s--) & 0xff; p = ((tmp_in >> 24) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 24;
113
114       in[j] = tmp_out;
115     }
116   }
117 }
118
119 __device__ static void lotus_transform_password (u32x *in, u32x *out, u32 s_lotus_magic_table[256])
120 {
121   u32x t = out[3] >> 24;
122
123   u32x c;
124
125   for (int i = 0; i < 4; i++)
126   {
127     t ^= (in[i] >>  0) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  0; t = ((out[i] >>  0) & 0xff);
128     t ^= (in[i] >>  8) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  8; t = ((out[i] >>  8) & 0xff);
129     t ^= (in[i] >> 16) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 16; t = ((out[i] >> 16) & 0xff);
130     t ^= (in[i] >> 24) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 24; t = ((out[i] >> 24) & 0xff);
131   }
132 }
133
134 __device__ static void pad (u32 w[4], const u32 len)
135 {
136   const u32 val = 16 - len;
137
138   const u32 mask1 = val << 24;
139
140   const u32 mask2 = val << 16
141                    | val << 24;
142
143   const u32 mask3 = val <<  8
144                    | val << 16
145                    | val << 24;
146
147   const u32 mask4 = val <<  0
148                    | val <<  8
149                    | val << 16
150                    | val << 24;
151
152   switch (len)
153   {
154     case  0:  w[0]  = mask4;
155               w[1]  = mask4;
156               w[2]  = mask4;
157               w[3]  = mask4;
158               break;
159     case  1:  w[0] |= mask3;
160               w[1]  = mask4;
161               w[2]  = mask4;
162               w[3]  = mask4;
163               break;
164     case  2:  w[0] |= mask2;
165               w[1]  = mask4;
166               w[2]  = mask4;
167               w[3]  = mask4;
168               break;
169     case  3:  w[0] |= mask1;
170               w[1]  = mask4;
171               w[2]  = mask4;
172               w[3]  = mask4;
173               break;
174     case  4:  w[1]  = mask4;
175               w[2]  = mask4;
176               w[3]  = mask4;
177               break;
178     case  5:  w[1] |= mask3;
179               w[2]  = mask4;
180               w[3]  = mask4;
181               break;
182     case  6:  w[1] |= mask2;
183               w[2]  = mask4;
184               w[3]  = mask4;
185               break;
186     case  7:  w[1] |= mask1;
187               w[2]  = mask4;
188               w[3]  = mask4;
189               break;
190     case  8:  w[2]  = mask4;
191               w[3]  = mask4;
192               break;
193     case  9:  w[2] |= mask3;
194               w[3]  = mask4;
195               break;
196     case 10:  w[2] |= mask2;
197               w[3]  = mask4;
198               break;
199     case 11:  w[2] |= mask1;
200               w[3]  = mask4;
201               break;
202     case 12:  w[3]  = mask4;
203               break;
204     case 13:  w[3] |= mask3;
205               break;
206     case 14:  w[3] |= mask2;
207               break;
208     case 15:  w[3] |= mask1;
209               break;
210   }
211 }
212
213 __device__ static void mdtransform_norecalc (u32x state[4], u32x block[4], u32 s_lotus_magic_table[256])
214 {
215         u32x x[12];
216
217   x[ 0] = state[0];
218   x[ 1] = state[1];
219   x[ 2] = state[2];
220   x[ 3] = state[3];
221   x[ 4] = block[0];
222   x[ 5] = block[1];
223   x[ 6] = block[2];
224   x[ 7] = block[3];
225   x[ 8] = state[0] ^ block[0];
226   x[ 9] = state[1] ^ block[1];
227   x[10] = state[2] ^ block[2];
228   x[11] = state[3] ^ block[3];
229
230   lotus_mix (x, s_lotus_magic_table);
231
232   state[0] = x[0];
233   state[1] = x[1];
234   state[2] = x[2];
235   state[3] = x[3];
236 }
237
238 __device__ static void mdtransform (u32x state[4], u32x checksum[4], u32x block[4], u32 s_lotus_magic_table[256])
239 {
240   mdtransform_norecalc (state, block, s_lotus_magic_table);
241
242   lotus_transform_password (block, checksum, s_lotus_magic_table);
243 }
244
245 __device__ static void domino_big_md (const u32x saved_key[16], const u32 size, u32x state[4], u32 s_lotus_magic_table[256])
246 {
247         u32x checksum[4];
248
249   checksum[0] = 0;
250   checksum[1] = 0;
251   checksum[2] = 0;
252   checksum[3] = 0;
253
254         u32x block[4];
255
256   block[0] = 0;
257   block[1] = 0;
258   block[2] = 0;
259   block[3] = 0;
260
261   u32 curpos;
262   u32 idx;
263
264   for (curpos = 0, idx = 0; curpos + 16 < size; curpos += 16, idx += 4)
265   {
266     block[0] = saved_key[idx + 0];
267     block[1] = saved_key[idx + 1];
268     block[2] = saved_key[idx + 2];
269     block[3] = saved_key[idx + 3];
270
271     mdtransform (state, checksum, block, s_lotus_magic_table);
272   }
273
274         u32 left = size - curpos;
275
276   block[0] = saved_key[idx + 0];
277   block[1] = saved_key[idx + 1];
278   block[2] = saved_key[idx + 2];
279   block[3] = saved_key[idx + 3];
280
281   mdtransform (state, checksum, block, s_lotus_magic_table);
282
283         mdtransform_norecalc (state, checksum, s_lotus_magic_table);
284 }
285
286 __device__ __constant__ u32x c_bfs[1024];
287
288 __device__ static void m08700m (u32 s_lotus_magic_table[256], u32 w[16], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
289 {
290   /**
291    * modifier
292    */
293
294   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
295   const u32 lid = threadIdx.x;
296
297   /**
298    * padding
299    */
300
301   if (pw_len < 16)
302   {
303     pad (&w[ 0], pw_len & 0xf);
304   }
305   else if (pw_len < 32)
306   {
307     pad (&w[ 4], pw_len & 0xf);
308   }
309   else if (pw_len < 48)
310   {
311     pad (&w[ 8], pw_len & 0xf);
312   }
313   else if (pw_len < 64)
314   {
315     pad (&w[12], pw_len & 0xf);
316   }
317
318   /**
319    * salt
320    */
321
322   const u32 salt0 = salt_bufs[salt_pos].salt_buf[0];
323   const u32 salt1 = salt_bufs[salt_pos].salt_buf[1] & 0xff | '(' << 8;
324
325   /**
326    * loop
327    */
328
329   const u32 bf_loops = ceil ((float) bfs_cnt / VECT_DIV);
330
331   u32x w0l = w[0];
332
333   for (u32 il_pos = 0; il_pos < bf_loops; il_pos++)
334   {
335     const u32x w0r = c_bfs[il_pos];
336
337     const u32x w0 = w0l | w0r;
338
339     u32x w_tmp[16];
340
341     w_tmp[ 0] = w0;
342     w_tmp[ 1] = w[ 1];
343     w_tmp[ 2] = w[ 2];
344     w_tmp[ 3] = w[ 3];
345     w_tmp[ 4] = w[ 4];
346     w_tmp[ 5] = w[ 5];
347     w_tmp[ 6] = w[ 6];
348     w_tmp[ 7] = w[ 7];
349     w_tmp[ 8] = w[ 8];
350     w_tmp[ 9] = w[ 9];
351     w_tmp[10] = w[10];
352     w_tmp[11] = w[11];
353     w_tmp[12] = w[12];
354     w_tmp[13] = w[13];
355     w_tmp[14] = w[14];
356     w_tmp[15] = w[15];
357
358     u32x state[4];
359
360     state[0] = 0;
361     state[1] = 0;
362     state[2] = 0;
363     state[3] = 0;
364
365     domino_big_md (w_tmp, pw_len, state, s_lotus_magic_table);
366
367     const u32x w0_t = uint_to_hex_upper8 ((state[0] >>  0) & 255) <<  0
368                      | uint_to_hex_upper8 ((state[0] >>  8) & 255) << 16;
369     const u32x w1_t = uint_to_hex_upper8 ((state[0] >> 16) & 255) <<  0
370                      | uint_to_hex_upper8 ((state[0] >> 24) & 255) << 16;
371     const u32x w2_t = uint_to_hex_upper8 ((state[1] >>  0) & 255) <<  0
372                      | uint_to_hex_upper8 ((state[1] >>  8) & 255) << 16;
373     const u32x w3_t = uint_to_hex_upper8 ((state[1] >> 16) & 255) <<  0
374                      | uint_to_hex_upper8 ((state[1] >> 24) & 255) << 16;
375     const u32x w4_t = uint_to_hex_upper8 ((state[2] >>  0) & 255) <<  0
376                      | uint_to_hex_upper8 ((state[2] >>  8) & 255) << 16;
377     const u32x w5_t = uint_to_hex_upper8 ((state[2] >> 16) & 255) <<  0
378                      | uint_to_hex_upper8 ((state[2] >> 24) & 255) << 16;
379     const u32x w6_t = uint_to_hex_upper8 ((state[3] >>  0) & 255) <<  0
380                      | uint_to_hex_upper8 ((state[3] >>  8) & 255) << 16;
381     //const u32x w7_t = uint_to_hex_upper8 ((state[3] >> 16) & 255) <<  0
382     //                 | uint_to_hex_upper8 ((state[3] >> 24) & 255) << 16;
383
384     const u32 pade = 0x0e0e0e0e;
385
386     w_tmp[ 0] = salt0;
387     w_tmp[ 1] = salt1      | w0_t << 16;
388     w_tmp[ 2] = w0_t >> 16 | w1_t << 16;
389     w_tmp[ 3] = w1_t >> 16 | w2_t << 16;
390     w_tmp[ 4] = w2_t >> 16 | w3_t << 16;
391     w_tmp[ 5] = w3_t >> 16 | w4_t << 16;
392     w_tmp[ 6] = w4_t >> 16 | w5_t << 16;
393     w_tmp[ 7] = w5_t >> 16 | w6_t << 16;
394     w_tmp[ 8] = w6_t >> 16 | pade << 16; // | w7_t <<  8;
395     w_tmp[ 9] = pade;
396     w_tmp[10] = pade;
397     w_tmp[11] = pade;
398     w_tmp[12] = 0;
399     w_tmp[13] = 0;
400     w_tmp[14] = 0;
401     w_tmp[15] = 0;
402
403     state[0] = 0;
404     state[1] = 0;
405     state[2] = 0;
406     state[3] = 0;
407
408     domino_big_md (w_tmp, 34, state, s_lotus_magic_table);
409
410     u32x a = state[0] & 0xffffffff;
411     u32x b = state[1] & 0xffffffff;
412     u32x c = state[2] & 0x000000ff;
413     u32x d = state[3] & 0x00000000;
414
415     const u32x r0 = a;
416     const u32x r1 = b;
417     const u32x r2 = c;
418     const u32x r3 = d;
419
420     #include VECT_COMPARE_M
421   }
422 }
423
424 __device__ static void m08700s (u32 s_lotus_magic_table[256], u32 w[16], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
425 {
426   /**
427    * modifier
428    */
429
430   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
431   const u32 lid = threadIdx.x;
432
433   /**
434    * padding
435    */
436
437   if (pw_len < 16)
438   {
439     pad (&w[ 0], pw_len & 0xf);
440   }
441   else if (pw_len < 32)
442   {
443     pad (&w[ 4], pw_len & 0xf);
444   }
445   else if (pw_len < 48)
446   {
447     pad (&w[ 8], pw_len & 0xf);
448   }
449   else if (pw_len < 64)
450   {
451     pad (&w[12], pw_len & 0xf);
452   }
453
454
455   /**
456    * salt
457    */
458
459   const u32 salt0 = salt_bufs[salt_pos].salt_buf[0];
460   const u32 salt1 = salt_bufs[salt_pos].salt_buf[1] & 0xff | '(' << 8;
461
462   /**
463    * digest
464    */
465
466   const u32 search[4] =
467   {
468     digests_buf[digests_offset].digest_buf[DGST_R0],
469     digests_buf[digests_offset].digest_buf[DGST_R1],
470     digests_buf[digests_offset].digest_buf[DGST_R2],
471     digests_buf[digests_offset].digest_buf[DGST_R3]
472   };
473
474   /**
475    * loop
476    */
477
478   const u32 bf_loops = ceil ((float) bfs_cnt / VECT_DIV);
479
480   u32x w0l = w[0];
481
482   for (u32 il_pos = 0; il_pos < bf_loops; il_pos++)
483   {
484     const u32x w0r = c_bfs[il_pos];
485
486     const u32x w0 = w0l | w0r;
487
488     u32x w_tmp[16];
489
490     w_tmp[ 0] = w0;
491     w_tmp[ 1] = w[ 1];
492     w_tmp[ 2] = w[ 2];
493     w_tmp[ 3] = w[ 3];
494     w_tmp[ 4] = w[ 4];
495     w_tmp[ 5] = w[ 5];
496     w_tmp[ 6] = w[ 6];
497     w_tmp[ 7] = w[ 7];
498     w_tmp[ 8] = w[ 8];
499     w_tmp[ 9] = w[ 9];
500     w_tmp[10] = w[10];
501     w_tmp[11] = w[11];
502     w_tmp[12] = w[12];
503     w_tmp[13] = w[13];
504     w_tmp[14] = w[14];
505     w_tmp[15] = w[15];
506
507     u32x state[4];
508
509     state[0] = 0;
510     state[1] = 0;
511     state[2] = 0;
512     state[3] = 0;
513
514     domino_big_md (w_tmp, pw_len, state, s_lotus_magic_table);
515
516     const u32x w0_t = uint_to_hex_upper8 ((state[0] >>  0) & 255) <<  0
517                      | uint_to_hex_upper8 ((state[0] >>  8) & 255) << 16;
518     const u32x w1_t = uint_to_hex_upper8 ((state[0] >> 16) & 255) <<  0
519                      | uint_to_hex_upper8 ((state[0] >> 24) & 255) << 16;
520     const u32x w2_t = uint_to_hex_upper8 ((state[1] >>  0) & 255) <<  0
521                      | uint_to_hex_upper8 ((state[1] >>  8) & 255) << 16;
522     const u32x w3_t = uint_to_hex_upper8 ((state[1] >> 16) & 255) <<  0
523                      | uint_to_hex_upper8 ((state[1] >> 24) & 255) << 16;
524     const u32x w4_t = uint_to_hex_upper8 ((state[2] >>  0) & 255) <<  0
525                      | uint_to_hex_upper8 ((state[2] >>  8) & 255) << 16;
526     const u32x w5_t = uint_to_hex_upper8 ((state[2] >> 16) & 255) <<  0
527                      | uint_to_hex_upper8 ((state[2] >> 24) & 255) << 16;
528     const u32x w6_t = uint_to_hex_upper8 ((state[3] >>  0) & 255) <<  0
529                      | uint_to_hex_upper8 ((state[3] >>  8) & 255) << 16;
530     //const u32x w7_t = uint_to_hex_upper8 ((state[3] >> 16) & 255) <<  0
531     //                 | uint_to_hex_upper8 ((state[3] >> 24) & 255) << 16;
532
533     const u32 pade = 0x0e0e0e0e;
534
535     w_tmp[ 0] = salt0;
536     w_tmp[ 1] = salt1      | w0_t << 16;
537     w_tmp[ 2] = w0_t >> 16 | w1_t << 16;
538     w_tmp[ 3] = w1_t >> 16 | w2_t << 16;
539     w_tmp[ 4] = w2_t >> 16 | w3_t << 16;
540     w_tmp[ 5] = w3_t >> 16 | w4_t << 16;
541     w_tmp[ 6] = w4_t >> 16 | w5_t << 16;
542     w_tmp[ 7] = w5_t >> 16 | w6_t << 16;
543     w_tmp[ 8] = w6_t >> 16 | pade << 16; // | w7_t <<  8;
544     w_tmp[ 9] = pade;
545     w_tmp[10] = pade;
546     w_tmp[11] = pade;
547     w_tmp[12] = 0;
548     w_tmp[13] = 0;
549     w_tmp[14] = 0;
550     w_tmp[15] = 0;
551
552     state[0] = 0;
553     state[1] = 0;
554     state[2] = 0;
555     state[3] = 0;
556
557     domino_big_md (w_tmp, 34, state, s_lotus_magic_table);
558
559     u32x a = state[0] & 0xffffffff;
560     u32x b = state[1] & 0xffffffff;
561     u32x c = state[2] & 0x000000ff;
562     u32x d = state[3] & 0x00000000;
563
564     const u32x r0 = a;
565     const u32x r1 = b;
566     const u32x r2 = c;
567     const u32x r3 = d;
568
569     #include VECT_COMPARE_S
570   }
571 }
572
573 extern "C" __global__ void __launch_bounds__ (256, 1) m08700_m04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
574 {
575   /**
576    * base
577    */
578
579   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
580   const u32 lid = threadIdx.x;
581
582   u32 w[16];
583
584   w[ 0] = pws[gid].i[ 0];
585   w[ 1] = pws[gid].i[ 1];
586   w[ 2] = pws[gid].i[ 2];
587   w[ 3] = pws[gid].i[ 3];
588   w[ 4] = 0;
589   w[ 5] = 0;
590   w[ 6] = 0;
591   w[ 7] = 0;
592   w[ 8] = 0;
593   w[ 9] = 0;
594   w[10] = 0;
595   w[11] = 0;
596   w[12] = 0;
597   w[13] = 0;
598   w[14] = 0;
599   w[15] = 0;
600
601   const u32 pw_len = pws[gid].pw_len;
602
603   /**
604    * bin2asc table
605    */
606
607   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
608                  | c_bin2asc[(lid >> 4) & 15] << 0;
609
610   __syncthreads ();
611
612   /**
613    * sbox
614    */
615
616   __shared__ u32 s_lotus_magic_table[256];
617
618   s_lotus_magic_table[lid] = lotus_magic_table[lid];
619
620   __syncthreads ();
621
622   if (gid >= gid_max) return;
623
624   /**
625    * main
626    */
627
628   m08700m (s_lotus_magic_table, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
629 }
630
631 extern "C" __global__ void __launch_bounds__ (256, 1) m08700_m08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
632 {
633   /**
634    * base
635    */
636
637   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
638   const u32 lid = threadIdx.x;
639
640   u32 w[16];
641
642   w[ 0] = pws[gid].i[ 0];
643   w[ 1] = pws[gid].i[ 1];
644   w[ 2] = pws[gid].i[ 2];
645   w[ 3] = pws[gid].i[ 3];
646   w[ 4] = pws[gid].i[ 4];
647   w[ 5] = pws[gid].i[ 5];
648   w[ 6] = pws[gid].i[ 6];
649   w[ 7] = pws[gid].i[ 7];
650   w[ 8] = 0;
651   w[ 9] = 0;
652   w[10] = 0;
653   w[11] = 0;
654   w[12] = 0;
655   w[13] = 0;
656   w[14] = 0;
657   w[15] = 0;
658
659   const u32 pw_len = pws[gid].pw_len;
660
661   /**
662    * bin2asc table
663    */
664
665   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
666                  | c_bin2asc[(lid >> 4) & 15] << 0;
667
668   __syncthreads ();
669
670   /**
671    * sbox
672    */
673
674   __shared__ u32 s_lotus_magic_table[256];
675
676   s_lotus_magic_table[lid] = lotus_magic_table[lid];
677
678   __syncthreads ();
679
680   if (gid >= gid_max) return;
681
682   /**
683    * main
684    */
685
686   m08700m (s_lotus_magic_table, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
687 }
688
689 extern "C" __global__ void __launch_bounds__ (256, 1) m08700_m16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
690 {
691   /**
692    * base
693    */
694
695   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
696   const u32 lid = threadIdx.x;
697
698   u32 w[16];
699
700   w[ 0] = pws[gid].i[ 0];
701   w[ 1] = pws[gid].i[ 1];
702   w[ 2] = pws[gid].i[ 2];
703   w[ 3] = pws[gid].i[ 3];
704   w[ 4] = pws[gid].i[ 4];
705   w[ 5] = pws[gid].i[ 5];
706   w[ 6] = pws[gid].i[ 6];
707   w[ 7] = pws[gid].i[ 7];
708   w[ 8] = pws[gid].i[ 8];
709   w[ 9] = pws[gid].i[ 9];
710   w[10] = pws[gid].i[10];
711   w[11] = pws[gid].i[11];
712   w[12] = pws[gid].i[12];
713   w[13] = pws[gid].i[13];
714   w[14] = pws[gid].i[14];
715   w[15] = pws[gid].i[15];
716
717   const u32 pw_len = pws[gid].pw_len;
718
719   /**
720    * bin2asc table
721    */
722
723   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
724                  | c_bin2asc[(lid >> 4) & 15] << 0;
725
726   __syncthreads ();
727
728   /**
729    * sbox
730    */
731
732   __shared__ u32 s_lotus_magic_table[256];
733
734   s_lotus_magic_table[lid] = lotus_magic_table[lid];
735
736   __syncthreads ();
737
738   if (gid >= gid_max) return;
739
740   /**
741    * main
742    */
743
744   m08700m (s_lotus_magic_table, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
745 }
746
747 extern "C" __global__ void __launch_bounds__ (256, 1) m08700_s04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
748 {
749   /**
750    * base
751    */
752
753   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
754   const u32 lid = threadIdx.x;
755
756   u32 w[16];
757
758   w[ 0] = pws[gid].i[ 0];
759   w[ 1] = pws[gid].i[ 1];
760   w[ 2] = pws[gid].i[ 2];
761   w[ 3] = pws[gid].i[ 3];
762   w[ 4] = 0;
763   w[ 5] = 0;
764   w[ 6] = 0;
765   w[ 7] = 0;
766   w[ 8] = 0;
767   w[ 9] = 0;
768   w[10] = 0;
769   w[11] = 0;
770   w[12] = 0;
771   w[13] = 0;
772   w[14] = 0;
773   w[15] = 0;
774
775   const u32 pw_len = pws[gid].pw_len;
776
777   /**
778    * bin2asc table
779    */
780
781   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
782                  | c_bin2asc[(lid >> 4) & 15] << 0;
783
784   __syncthreads ();
785
786   /**
787    * sbox
788    */
789
790   __shared__ u32 s_lotus_magic_table[256];
791
792   s_lotus_magic_table[lid] = lotus_magic_table[lid];
793
794   __syncthreads ();
795
796   if (gid >= gid_max) return;
797
798   /**
799    * main
800    */
801
802   m08700s (s_lotus_magic_table, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
803 }
804
805 extern "C" __global__ void __launch_bounds__ (256, 1) m08700_s08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
806 {
807   /**
808    * base
809    */
810
811   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
812   const u32 lid = threadIdx.x;
813
814   u32 w[16];
815
816   w[ 0] = pws[gid].i[ 0];
817   w[ 1] = pws[gid].i[ 1];
818   w[ 2] = pws[gid].i[ 2];
819   w[ 3] = pws[gid].i[ 3];
820   w[ 4] = pws[gid].i[ 4];
821   w[ 5] = pws[gid].i[ 5];
822   w[ 6] = pws[gid].i[ 6];
823   w[ 7] = pws[gid].i[ 7];
824   w[ 8] = 0;
825   w[ 9] = 0;
826   w[10] = 0;
827   w[11] = 0;
828   w[12] = 0;
829   w[13] = 0;
830   w[14] = 0;
831   w[15] = 0;
832
833   const u32 pw_len = pws[gid].pw_len;
834
835   /**
836    * bin2asc table
837    */
838
839   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
840                  | c_bin2asc[(lid >> 4) & 15] << 0;
841
842   __syncthreads ();
843
844   /**
845    * sbox
846    */
847
848   __shared__ u32 s_lotus_magic_table[256];
849
850   s_lotus_magic_table[lid] = lotus_magic_table[lid];
851
852   __syncthreads ();
853
854   if (gid >= gid_max) return;
855
856   /**
857    * main
858    */
859
860   m08700s (s_lotus_magic_table, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
861 }
862
863 extern "C" __global__ void __launch_bounds__ (256, 1) m08700_s16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const u32x * words_buf_r, void *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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
864 {
865   /**
866    * base
867    */
868
869   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
870   const u32 lid = threadIdx.x;
871
872   u32 w[16];
873
874   w[ 0] = pws[gid].i[ 0];
875   w[ 1] = pws[gid].i[ 1];
876   w[ 2] = pws[gid].i[ 2];
877   w[ 3] = pws[gid].i[ 3];
878   w[ 4] = pws[gid].i[ 4];
879   w[ 5] = pws[gid].i[ 5];
880   w[ 6] = pws[gid].i[ 6];
881   w[ 7] = pws[gid].i[ 7];
882   w[ 8] = pws[gid].i[ 8];
883   w[ 9] = pws[gid].i[ 9];
884   w[10] = pws[gid].i[10];
885   w[11] = pws[gid].i[11];
886   w[12] = pws[gid].i[12];
887   w[13] = pws[gid].i[13];
888   w[14] = pws[gid].i[14];
889   w[15] = pws[gid].i[15];
890
891   const u32 pw_len = pws[gid].pw_len;
892
893   /**
894    * bin2asc table
895    */
896
897   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
898                  | c_bin2asc[(lid >> 4) & 15] << 0;
899
900   __syncthreads ();
901
902   /**
903    * sbox
904    */
905
906   __shared__ u32 s_lotus_magic_table[256];
907
908   s_lotus_magic_table[lid] = lotus_magic_table[lid];
909
910   __syncthreads ();
911
912   if (gid >= gid_max) return;
913
914   /**
915    * main
916    */
917
918   m08700s (s_lotus_magic_table, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
919 }