Initial commit
[hashcat.git] / nv / m08700_a0.cu
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _LOTUS6_
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 #include "types_nv.c"
26 #include "common_nv.c"
27 #include "include/rp_gpu.h"
28 #include "rp_nv.c"
29
30 #ifdef  VECT_SIZE1
31 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
32 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
33 #endif
34
35 #ifdef  VECT_SIZE2
36 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
37 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
38 #endif
39
40 __device__ __constant__ u32 lotus_magic_table[256] =
41 {
42   0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a,
43   0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0,
44   0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b,
45   0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a,
46   0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda,
47   0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36,
48   0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8,
49   0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c,
50   0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17,
51   0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60,
52   0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72,
53   0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa,
54   0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd,
55   0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e,
56   0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b,
57   0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf,
58   0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77,
59   0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6,
60   0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3,
61   0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3,
62   0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e,
63   0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c,
64   0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d,
65   0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2,
66   0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46,
67   0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5,
68   0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97,
69   0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5,
70   0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef,
71   0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f,
72   0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf,
73   0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab,
74 };
75
76 #ifdef VECT_SIZE1
77 #define BOX(S,i) u32x ((S)[(i)])
78 #endif
79
80 #ifdef VECT_SIZE2
81 #define BOX(S,i) u32x ((S)[(i).x], (S)[(i).y])
82 #endif
83
84 #ifdef VECT_SIZE1
85 #define uint_to_hex_upper8(i) l_bin2asc[(i)]
86 #endif
87
88 #ifdef VECT_SIZE2
89 #define uint_to_hex_upper8(i) u32x (l_bin2asc[(i).x], l_bin2asc[(i).y])
90 #endif
91
92 __device__ __constant__ char c_bin2asc[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
93
94 __device__ __shared__ short l_bin2asc[256];
95
96 __device__ static void lotus_mix (u32x *in, u32 s_lotus_magic_table[256])
97 {
98   u32x p = 0;
99
100   for (int i = 0; i < 18; i++)
101   {
102     u32 s = 48;
103
104     #pragma unroll 12
105     for (int j = 0; j < 12; j++)
106     {
107       u32x tmp_in = in[j];
108       u32x tmp_out = 0;
109
110       p = (p + s--) & 0xff; p = ((tmp_in >>  0) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  0;
111       p = (p + s--) & 0xff; p = ((tmp_in >>  8) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  8;
112       p = (p + s--) & 0xff; p = ((tmp_in >> 16) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 16;
113       p = (p + s--) & 0xff; p = ((tmp_in >> 24) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 24;
114
115       in[j] = tmp_out;
116     }
117   }
118 }
119
120 __device__ static void lotus_transform_password (u32x *in, u32x *out, u32 s_lotus_magic_table[256])
121 {
122   u32x t = out[3] >> 24;
123
124   u32x c;
125
126   for (int i = 0; i < 4; i++)
127   {
128     t ^= (in[i] >>  0) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  0; t = ((out[i] >>  0) & 0xff);
129     t ^= (in[i] >>  8) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  8; t = ((out[i] >>  8) & 0xff);
130     t ^= (in[i] >> 16) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 16; t = ((out[i] >> 16) & 0xff);
131     t ^= (in[i] >> 24) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 24; t = ((out[i] >> 24) & 0xff);
132   }
133 }
134
135 __device__ static void pad (u32x w[4], const u32 len)
136 {
137   const u32 val = 16 - len;
138
139   const u32 mask1 = val << 24;
140
141   const u32 mask2 = val << 16
142                    | val << 24;
143
144   const u32 mask3 = val <<  8
145                    | val << 16
146                    | val << 24;
147
148   const u32 mask4 = val <<  0
149                    | val <<  8
150                    | val << 16
151                    | val << 24;
152
153   switch (len)
154   {
155     case  0:  w[0]  = mask4;
156               w[1]  = mask4;
157               w[2]  = mask4;
158               w[3]  = mask4;
159               break;
160     case  1:  w[0] |= mask3;
161               w[1]  = mask4;
162               w[2]  = mask4;
163               w[3]  = mask4;
164               break;
165     case  2:  w[0] |= mask2;
166               w[1]  = mask4;
167               w[2]  = mask4;
168               w[3]  = mask4;
169               break;
170     case  3:  w[0] |= mask1;
171               w[1]  = mask4;
172               w[2]  = mask4;
173               w[3]  = mask4;
174               break;
175     case  4:  w[1]  = mask4;
176               w[2]  = mask4;
177               w[3]  = mask4;
178               break;
179     case  5:  w[1] |= mask3;
180               w[2]  = mask4;
181               w[3]  = mask4;
182               break;
183     case  6:  w[1] |= mask2;
184               w[2]  = mask4;
185               w[3]  = mask4;
186               break;
187     case  7:  w[1] |= mask1;
188               w[2]  = mask4;
189               w[3]  = mask4;
190               break;
191     case  8:  w[2]  = mask4;
192               w[3]  = mask4;
193               break;
194     case  9:  w[2] |= mask3;
195               w[3]  = mask4;
196               break;
197     case 10:  w[2] |= mask2;
198               w[3]  = mask4;
199               break;
200     case 11:  w[2] |= mask1;
201               w[3]  = mask4;
202               break;
203     case 12:  w[3]  = mask4;
204               break;
205     case 13:  w[3] |= mask3;
206               break;
207     case 14:  w[3] |= mask2;
208               break;
209     case 15:  w[3] |= mask1;
210               break;
211   }
212 }
213
214 __device__ static void mdtransform_norecalc (u32x state[4], u32x block[4], u32 s_lotus_magic_table[256])
215 {
216         u32x x[12];
217
218   x[ 0] = state[0];
219   x[ 1] = state[1];
220   x[ 2] = state[2];
221   x[ 3] = state[3];
222   x[ 4] = block[0];
223   x[ 5] = block[1];
224   x[ 6] = block[2];
225   x[ 7] = block[3];
226   x[ 8] = state[0] ^ block[0];
227   x[ 9] = state[1] ^ block[1];
228   x[10] = state[2] ^ block[2];
229   x[11] = state[3] ^ block[3];
230
231   lotus_mix (x, s_lotus_magic_table);
232
233   state[0] = x[0];
234   state[1] = x[1];
235   state[2] = x[2];
236   state[3] = x[3];
237 }
238
239 __device__ static void mdtransform (u32x state[4], u32x checksum[4], u32x block[4], u32 s_lotus_magic_table[256])
240 {
241   mdtransform_norecalc (state, block, s_lotus_magic_table);
242
243   lotus_transform_password (block, checksum, s_lotus_magic_table);
244 }
245
246 __device__ static void domino_big_md (const u32x saved_key[16], const u32 size, u32x state[4], u32 s_lotus_magic_table[256])
247 {
248         u32x checksum[4];
249
250   checksum[0] = 0;
251   checksum[1] = 0;
252   checksum[2] = 0;
253   checksum[3] = 0;
254
255         u32x block[4];
256
257   block[0] = 0;
258   block[1] = 0;
259   block[2] = 0;
260   block[3] = 0;
261
262   u32 curpos;
263   u32 idx;
264
265   for (curpos = 0, idx = 0; curpos + 16 < size; curpos += 16, idx += 4)
266   {
267     block[0] = saved_key[idx + 0];
268     block[1] = saved_key[idx + 1];
269     block[2] = saved_key[idx + 2];
270     block[3] = saved_key[idx + 3];
271
272     mdtransform (state, checksum, block, s_lotus_magic_table);
273   }
274
275         u32 left = size - curpos;
276
277   block[0] = saved_key[idx + 0];
278   block[1] = saved_key[idx + 1];
279   block[2] = saved_key[idx + 2];
280   block[3] = saved_key[idx + 3];
281
282   mdtransform (state, checksum, block, s_lotus_magic_table);
283
284         mdtransform_norecalc (state, checksum, s_lotus_magic_table);
285 }
286
287 __device__ __constant__ gpu_rule_t c_rules[1024];
288
289 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 bf_t *bfs_buf, const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
290 {
291   /**
292    * modifier
293    */
294
295   const u32 lid = threadIdx.x;
296
297   /**
298    * base
299    */
300
301   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
302
303   /**
304    * bin2asc table
305    */
306
307   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
308                  | c_bin2asc[(lid >> 4) & 15] << 0;
309
310   __syncthreads ();
311
312   /**
313    * sbox
314    */
315
316   __shared__ u32 s_lotus_magic_table[256];
317
318   s_lotus_magic_table[lid] = lotus_magic_table[lid];
319
320   __syncthreads ();
321
322   if (gid >= gid_max) return;
323
324   /**
325    * base
326    */
327
328   u32x pw_buf0[4];
329
330   pw_buf0[0] = pws[gid].i[ 0];
331   pw_buf0[1] = pws[gid].i[ 1];
332   pw_buf0[2] = pws[gid].i[ 2];
333   pw_buf0[3] = pws[gid].i[ 3];
334
335   u32x pw_buf1[4];
336
337   pw_buf1[0] = pws[gid].i[ 4];
338   pw_buf1[1] = pws[gid].i[ 5];
339   pw_buf1[2] = pws[gid].i[ 6];
340   pw_buf1[3] = pws[gid].i[ 7];
341
342   const u32 pw_len = pws[gid].pw_len;
343
344   /**
345    * salt
346    */
347
348   const u32 salt0 = salt_bufs[salt_pos].salt_buf[0];
349   const u32 salt1 = salt_bufs[salt_pos].salt_buf[1] & 0xff | '(' << 8;
350
351   /**
352    * loop
353    */
354
355   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
356   {
357     u32x w0[4];
358
359     w0[0] = pw_buf0[0];
360     w0[1] = pw_buf0[1];
361     w0[2] = pw_buf0[2];
362     w0[3] = pw_buf0[3];
363
364     u32x w1[4];
365
366     w1[0] = pw_buf1[0];
367     w1[1] = pw_buf1[1];
368     w1[2] = pw_buf1[2];
369     w1[3] = pw_buf1[3];
370
371     u32x w2[4];
372
373     w2[0] = 0;
374     w2[1] = 0;
375     w2[2] = 0;
376     w2[3] = 0;
377
378     u32x w3[4];
379
380     w3[0] = 0;
381     w3[1] = 0;
382     w3[2] = 0;
383     w3[3] = 0;
384
385     const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
386
387     u32x w[16];
388
389     w[ 0] = w0[0];
390     w[ 1] = w0[1];
391     w[ 2] = w0[2];
392     w[ 3] = w0[3];
393     w[ 4] = w1[0];
394     w[ 5] = w1[1];
395     w[ 6] = w1[2];
396     w[ 7] = w1[3];
397     w[ 8] = w2[0];
398     w[ 9] = w2[1];
399     w[10] = w2[2];
400     w[11] = w2[3];
401     w[12] = w3[0];
402     w[13] = w3[1];
403     w[14] = w3[2];
404     w[15] = w3[3];
405
406     u32x state[4];
407
408     state[0] = 0;
409     state[1] = 0;
410     state[2] = 0;
411     state[3] = 0;
412
413     /**
414      * padding
415      */
416
417     if (pw_len < 16)
418     {
419       pad (&w[ 0], pw_len & 0xf);
420     }
421     else if (pw_len < 32)
422     {
423       pad (&w[ 4], pw_len & 0xf);
424     }
425     else if (pw_len < 48)
426     {
427       pad (&w[ 8], pw_len & 0xf);
428     }
429     else if (pw_len < 64)
430     {
431       pad (&w[12], pw_len & 0xf);
432     }
433
434     domino_big_md (w, pw_len, state, s_lotus_magic_table);
435
436     const u32x w0_t = uint_to_hex_upper8 ((state[0] >>  0) & 255) <<  0
437                      | uint_to_hex_upper8 ((state[0] >>  8) & 255) << 16;
438     const u32x w1_t = uint_to_hex_upper8 ((state[0] >> 16) & 255) <<  0
439                      | uint_to_hex_upper8 ((state[0] >> 24) & 255) << 16;
440     const u32x w2_t = uint_to_hex_upper8 ((state[1] >>  0) & 255) <<  0
441                      | uint_to_hex_upper8 ((state[1] >>  8) & 255) << 16;
442     const u32x w3_t = uint_to_hex_upper8 ((state[1] >> 16) & 255) <<  0
443                      | uint_to_hex_upper8 ((state[1] >> 24) & 255) << 16;
444     const u32x w4_t = uint_to_hex_upper8 ((state[2] >>  0) & 255) <<  0
445                      | uint_to_hex_upper8 ((state[2] >>  8) & 255) << 16;
446     const u32x w5_t = uint_to_hex_upper8 ((state[2] >> 16) & 255) <<  0
447                      | uint_to_hex_upper8 ((state[2] >> 24) & 255) << 16;
448     const u32x w6_t = uint_to_hex_upper8 ((state[3] >>  0) & 255) <<  0
449                      | uint_to_hex_upper8 ((state[3] >>  8) & 255) << 16;
450     //const u32x w7_t = uint_to_hex_upper8 ((state[3] >> 16) & 255) <<  0
451     //                 | uint_to_hex_upper8 ((state[3] >> 24) & 255) << 16;
452
453     const u32 pade = 0x0e0e0e0e;
454
455     w[ 0] = salt0;
456     w[ 1] = salt1      | w0_t << 16;
457     w[ 2] = w0_t >> 16 | w1_t << 16;
458     w[ 3] = w1_t >> 16 | w2_t << 16;
459     w[ 4] = w2_t >> 16 | w3_t << 16;
460     w[ 5] = w3_t >> 16 | w4_t << 16;
461     w[ 6] = w4_t >> 16 | w5_t << 16;
462     w[ 7] = w5_t >> 16 | w6_t << 16;
463     w[ 8] = w6_t >> 16 | pade << 16; // | w7_t <<  8;
464     w[ 9] = pade;
465     w[10] = pade;
466     w[11] = pade;
467     w[12] = 0;
468     w[13] = 0;
469     w[14] = 0;
470     w[15] = 0;
471
472     state[0] = 0;
473     state[1] = 0;
474     state[2] = 0;
475     state[3] = 0;
476
477     domino_big_md (w, 34, state, s_lotus_magic_table);
478
479     u32x a = state[0] & 0xffffffff;
480     u32x b = state[1] & 0xffffffff;
481     u32x c = state[2] & 0x000000ff;
482     u32x d = state[3] & 0x00000000;
483
484     const u32x r0 = a;
485     const u32x r1 = b;
486     const u32x r2 = c;
487     const u32x r3 = d;
488
489     #include VECT_COMPARE_M
490   }
491 }
492
493 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 bf_t *bfs_buf, const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
494 {
495 }
496
497 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 bf_t *bfs_buf, const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
498 {
499 }
500
501 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 bf_t *bfs_buf, const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
502 {
503   /**
504    * modifier
505    */
506
507   const u32 lid = threadIdx.x;
508
509   /**
510    * base
511    */
512
513   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
514
515   /**
516    * bin2asc table
517    */
518
519   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
520                  | c_bin2asc[(lid >> 4) & 15] << 0;
521
522   __syncthreads ();
523
524   /**
525    * sbox
526    */
527
528   __shared__ u32 s_lotus_magic_table[256];
529
530   s_lotus_magic_table[lid] = lotus_magic_table[lid];
531
532   __syncthreads ();
533
534   if (gid >= gid_max) return;
535
536   /**
537    * base
538    */
539
540   u32x pw_buf0[4];
541
542   pw_buf0[0] = pws[gid].i[ 0];
543   pw_buf0[1] = pws[gid].i[ 1];
544   pw_buf0[2] = pws[gid].i[ 2];
545   pw_buf0[3] = pws[gid].i[ 3];
546
547   u32x pw_buf1[4];
548
549   pw_buf1[0] = pws[gid].i[ 4];
550   pw_buf1[1] = pws[gid].i[ 5];
551   pw_buf1[2] = pws[gid].i[ 6];
552   pw_buf1[3] = pws[gid].i[ 7];
553
554   const u32 pw_len = pws[gid].pw_len;
555
556   /**
557    * salt
558    */
559
560   const u32 salt0 = salt_bufs[salt_pos].salt_buf[0];
561   const u32 salt1 = salt_bufs[salt_pos].salt_buf[1] & 0xff | '(' << 8;
562
563   /**
564    * digest
565    */
566
567   const u32 search[4] =
568   {
569     digests_buf[digests_offset].digest_buf[DGST_R0],
570     digests_buf[digests_offset].digest_buf[DGST_R1],
571     digests_buf[digests_offset].digest_buf[DGST_R2],
572     digests_buf[digests_offset].digest_buf[DGST_R3]
573   };
574
575   /**
576    * loop
577    */
578
579   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
580   {
581     u32x w0[4];
582
583     w0[0] = pw_buf0[0];
584     w0[1] = pw_buf0[1];
585     w0[2] = pw_buf0[2];
586     w0[3] = pw_buf0[3];
587
588     u32x w1[4];
589
590     w1[0] = pw_buf1[0];
591     w1[1] = pw_buf1[1];
592     w1[2] = pw_buf1[2];
593     w1[3] = pw_buf1[3];
594
595     u32x w2[4];
596
597     w2[0] = 0;
598     w2[1] = 0;
599     w2[2] = 0;
600     w2[3] = 0;
601
602     u32x w3[4];
603
604     w3[0] = 0;
605     w3[1] = 0;
606     w3[2] = 0;
607     w3[3] = 0;
608
609     const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
610
611     u32x w[16];
612
613     w[ 0] = w0[0];
614     w[ 1] = w0[1];
615     w[ 2] = w0[2];
616     w[ 3] = w0[3];
617     w[ 4] = w1[0];
618     w[ 5] = w1[1];
619     w[ 6] = w1[2];
620     w[ 7] = w1[3];
621     w[ 8] = w2[0];
622     w[ 9] = w2[1];
623     w[10] = w2[2];
624     w[11] = w2[3];
625     w[12] = w3[0];
626     w[13] = w3[1];
627     w[14] = w3[2];
628     w[15] = w3[3];
629
630     u32x state[4];
631
632     state[0] = 0;
633     state[1] = 0;
634     state[2] = 0;
635     state[3] = 0;
636
637     /**
638      * padding
639      */
640
641     if (pw_len < 16)
642     {
643       pad (&w[ 0], pw_len & 0xf);
644     }
645     else if (pw_len < 32)
646     {
647       pad (&w[ 4], pw_len & 0xf);
648     }
649     else if (pw_len < 48)
650     {
651       pad (&w[ 8], pw_len & 0xf);
652     }
653     else if (pw_len < 64)
654     {
655       pad (&w[12], pw_len & 0xf);
656     }
657
658     domino_big_md (w, pw_len, state, s_lotus_magic_table);
659
660     const u32x w0_t = uint_to_hex_upper8 ((state[0] >>  0) & 255) <<  0
661                      | uint_to_hex_upper8 ((state[0] >>  8) & 255) << 16;
662     const u32x w1_t = uint_to_hex_upper8 ((state[0] >> 16) & 255) <<  0
663                      | uint_to_hex_upper8 ((state[0] >> 24) & 255) << 16;
664     const u32x w2_t = uint_to_hex_upper8 ((state[1] >>  0) & 255) <<  0
665                      | uint_to_hex_upper8 ((state[1] >>  8) & 255) << 16;
666     const u32x w3_t = uint_to_hex_upper8 ((state[1] >> 16) & 255) <<  0
667                      | uint_to_hex_upper8 ((state[1] >> 24) & 255) << 16;
668     const u32x w4_t = uint_to_hex_upper8 ((state[2] >>  0) & 255) <<  0
669                      | uint_to_hex_upper8 ((state[2] >>  8) & 255) << 16;
670     const u32x w5_t = uint_to_hex_upper8 ((state[2] >> 16) & 255) <<  0
671                      | uint_to_hex_upper8 ((state[2] >> 24) & 255) << 16;
672     const u32x w6_t = uint_to_hex_upper8 ((state[3] >>  0) & 255) <<  0
673                      | uint_to_hex_upper8 ((state[3] >>  8) & 255) << 16;
674     //const u32x w7_t = uint_to_hex_upper8 ((state[3] >> 16) & 255) <<  0
675     //                 | uint_to_hex_upper8 ((state[3] >> 24) & 255) << 16;
676
677     const u32 pade = 0x0e0e0e0e;
678
679     w[ 0] = salt0;
680     w[ 1] = salt1      | w0_t << 16;
681     w[ 2] = w0_t >> 16 | w1_t << 16;
682     w[ 3] = w1_t >> 16 | w2_t << 16;
683     w[ 4] = w2_t >> 16 | w3_t << 16;
684     w[ 5] = w3_t >> 16 | w4_t << 16;
685     w[ 6] = w4_t >> 16 | w5_t << 16;
686     w[ 7] = w5_t >> 16 | w6_t << 16;
687     w[ 8] = w6_t >> 16 | pade << 16; // | w7_t <<  8;
688     w[ 9] = pade;
689     w[10] = pade;
690     w[11] = pade;
691     w[12] = 0;
692     w[13] = 0;
693     w[14] = 0;
694     w[15] = 0;
695
696     state[0] = 0;
697     state[1] = 0;
698     state[2] = 0;
699     state[3] = 0;
700
701     domino_big_md (w, 34, state, s_lotus_magic_table);
702
703     u32x a = state[0] & 0xffffffff;
704     u32x b = state[1] & 0xffffffff;
705     u32x c = state[2] & 0x000000ff;
706     u32x d = state[3] & 0x00000000;
707
708     const u32x r0 = a;
709     const u32x r1 = b;
710     const u32x r2 = c;
711     const u32x r3 = d;
712
713     #include VECT_COMPARE_S
714   }
715 }
716
717 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 bf_t *bfs_buf, const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
718 {
719 }
720
721 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 bf_t *bfs_buf, const 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
722 {
723 }