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