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