More kernel fixes for function calls and vector datatypes
[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 #define BOX(S,i) (S)[(i)]
60
61 #define uint_to_hex_upper8(i) l_bin2asc[(i)]
62
63 static void lotus_mix (u32 *in, __local u32 s_lotus_magic_table[256])
64 {
65   u32 p = 0;
66
67   for (int i = 0; i < 18; i++)
68   {
69     u32 s = 48;
70
71     #pragma unroll
72     for (int j = 0; j < 12; j++)
73     {
74       u32 tmp_in = in[j];
75       u32 tmp_out = 0;
76
77       p = (p + s--) & 0xff; p = ((tmp_in >>  0) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  0;
78       p = (p + s--) & 0xff; p = ((tmp_in >>  8) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p <<  8;
79       p = (p + s--) & 0xff; p = ((tmp_in >> 16) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 16;
80       p = (p + s--) & 0xff; p = ((tmp_in >> 24) & 0xff) ^ BOX (s_lotus_magic_table, p); tmp_out |= p << 24;
81
82       in[j] = tmp_out;
83     }
84   }
85 }
86
87 static void lotus_transform_password (u32 *in, u32 *out, __local u32 s_lotus_magic_table[256])
88 {
89   u32 t = out[3] >> 24;
90
91   u32 c;
92
93   //#pragma unroll // kernel fails if used
94   for (int i = 0; i < 4; i++)
95   {
96     t ^= (in[i] >>  0) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  0; t = ((out[i] >>  0) & 0xff);
97     t ^= (in[i] >>  8) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c <<  8; t = ((out[i] >>  8) & 0xff);
98     t ^= (in[i] >> 16) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 16; t = ((out[i] >> 16) & 0xff);
99     t ^= (in[i] >> 24) & 0xff; c = BOX (s_lotus_magic_table, t); out[i] ^= c << 24; t = ((out[i] >> 24) & 0xff);
100   }
101 }
102
103 static void pad (u32 w[4], const u32 len)
104 {
105   const u32 val = 16 - len;
106
107   const u32 mask1 = val << 24;
108
109   const u32 mask2 = val << 16
110                    | val << 24;
111
112   const u32 mask3 = val <<  8
113                    | val << 16
114                    | val << 24;
115
116   const u32 mask4 = val <<  0
117                    | val <<  8
118                    | val << 16
119                    | val << 24;
120
121   switch (len)
122   {
123     case  0:  w[0]  = mask4;
124               w[1]  = mask4;
125               w[2]  = mask4;
126               w[3]  = mask4;
127               break;
128     case  1:  w[0] |= mask3;
129               w[1]  = mask4;
130               w[2]  = mask4;
131               w[3]  = mask4;
132               break;
133     case  2:  w[0] |= mask2;
134               w[1]  = mask4;
135               w[2]  = mask4;
136               w[3]  = mask4;
137               break;
138     case  3:  w[0] |= mask1;
139               w[1]  = mask4;
140               w[2]  = mask4;
141               w[3]  = mask4;
142               break;
143     case  4:  w[1]  = mask4;
144               w[2]  = mask4;
145               w[3]  = mask4;
146               break;
147     case  5:  w[1] |= mask3;
148               w[2]  = mask4;
149               w[3]  = mask4;
150               break;
151     case  6:  w[1] |= mask2;
152               w[2]  = mask4;
153               w[3]  = mask4;
154               break;
155     case  7:  w[1] |= mask1;
156               w[2]  = mask4;
157               w[3]  = mask4;
158               break;
159     case  8:  w[2]  = mask4;
160               w[3]  = mask4;
161               break;
162     case  9:  w[2] |= mask3;
163               w[3]  = mask4;
164               break;
165     case 10:  w[2] |= mask2;
166               w[3]  = mask4;
167               break;
168     case 11:  w[2] |= mask1;
169               w[3]  = mask4;
170               break;
171     case 12:  w[3]  = mask4;
172               break;
173     case 13:  w[3] |= mask3;
174               break;
175     case 14:  w[3] |= mask2;
176               break;
177     case 15:  w[3] |= mask1;
178               break;
179   }
180 }
181
182 static void mdtransform_norecalc (u32 state[4], u32 block[4], __local u32 s_lotus_magic_table[256])
183 {
184   u32 x[12];
185
186   x[ 0] = state[0];
187   x[ 1] = state[1];
188   x[ 2] = state[2];
189   x[ 3] = state[3];
190   x[ 4] = block[0];
191   x[ 5] = block[1];
192   x[ 6] = block[2];
193   x[ 7] = block[3];
194   x[ 8] = state[0] ^ block[0];
195   x[ 9] = state[1] ^ block[1];
196   x[10] = state[2] ^ block[2];
197   x[11] = state[3] ^ block[3];
198
199   lotus_mix (x, s_lotus_magic_table);
200
201   state[0] = x[0];
202   state[1] = x[1];
203   state[2] = x[2];
204   state[3] = x[3];
205 }
206
207 static void mdtransform (u32 state[4], u32 checksum[4], u32 block[4], __local u32 s_lotus_magic_table[256])
208 {
209   mdtransform_norecalc (state, block, s_lotus_magic_table);
210
211   lotus_transform_password (block, checksum, s_lotus_magic_table);
212 }
213
214 static void domino_big_md (const u32 saved_key[16], const u32 size, u32 state[4], __local u32 s_lotus_magic_table[256])
215 {
216   u32 checksum[4];
217
218   checksum[0] = 0;
219   checksum[1] = 0;
220   checksum[2] = 0;
221   checksum[3] = 0;
222
223   u32 block[4];
224
225   block[0] = 0;
226   block[1] = 0;
227   block[2] = 0;
228   block[3] = 0;
229
230   u32 curpos;
231   u32 idx;
232
233   for (curpos = 0, idx = 0; curpos + 16 < size; curpos += 16, idx += 4)
234   {
235     block[0] = saved_key[idx + 0];
236     block[1] = saved_key[idx + 1];
237     block[2] = saved_key[idx + 2];
238     block[3] = saved_key[idx + 3];
239
240     mdtransform (state, checksum, block, s_lotus_magic_table);
241   }
242
243   block[0] = saved_key[idx + 0];
244   block[1] = saved_key[idx + 1];
245   block[2] = saved_key[idx + 2];
246   block[3] = saved_key[idx + 3];
247
248   mdtransform (state, checksum, block, s_lotus_magic_table);
249
250   mdtransform_norecalc (state, checksum, s_lotus_magic_table);
251 }
252
253 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)
254 {
255   /**
256    * modifier
257    */
258
259   const u32 gid = get_global_id (0);
260   const u32 lid = get_local_id (0);
261
262   /**
263    * padding
264    */
265
266   if (pw_len < 16)
267   {
268     pad (&w[ 0], pw_len & 0xf);
269   }
270   else if (pw_len < 32)
271   {
272     pad (&w[ 4], pw_len & 0xf);
273   }
274   else if (pw_len < 48)
275   {
276     pad (&w[ 8], pw_len & 0xf);
277   }
278   else if (pw_len < 64)
279   {
280     pad (&w[12], pw_len & 0xf);
281   }
282
283   /**
284    * salt
285    */
286
287   const u32 salt0 = salt_bufs[salt_pos].salt_buf[0];
288   const u32 salt1 = salt_bufs[salt_pos].salt_buf[1] & 0xff | '(' << 8;
289
290   /**
291    * loop
292    */
293
294   u32 w0l = w[0];
295
296   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
297   {
298     const u32 w0r = words_buf_r[il_pos];
299
300     const u32 w0 = w0l | w0r;
301
302     u32 w_tmp[16];
303
304     w_tmp[ 0] = w0;
305     w_tmp[ 1] = w[ 1];
306     w_tmp[ 2] = w[ 2];
307     w_tmp[ 3] = w[ 3];
308     w_tmp[ 4] = w[ 4];
309     w_tmp[ 5] = w[ 5];
310     w_tmp[ 6] = w[ 6];
311     w_tmp[ 7] = w[ 7];
312     w_tmp[ 8] = w[ 8];
313     w_tmp[ 9] = w[ 9];
314     w_tmp[10] = w[10];
315     w_tmp[11] = w[11];
316     w_tmp[12] = w[12];
317     w_tmp[13] = w[13];
318     w_tmp[14] = w[14];
319     w_tmp[15] = w[15];
320
321     u32 state[4];
322
323     state[0] = 0;
324     state[1] = 0;
325     state[2] = 0;
326     state[3] = 0;
327
328     domino_big_md (w_tmp, pw_len, state, s_lotus_magic_table);
329
330     const u32 w0_t = uint_to_hex_upper8 ((state[0] >>  0) & 255) <<  0
331                      | uint_to_hex_upper8 ((state[0] >>  8) & 255) << 16;
332     const u32 w1_t = uint_to_hex_upper8 ((state[0] >> 16) & 255) <<  0
333                      | uint_to_hex_upper8 ((state[0] >> 24) & 255) << 16;
334     const u32 w2_t = uint_to_hex_upper8 ((state[1] >>  0) & 255) <<  0
335                      | uint_to_hex_upper8 ((state[1] >>  8) & 255) << 16;
336     const u32 w3_t = uint_to_hex_upper8 ((state[1] >> 16) & 255) <<  0
337                      | uint_to_hex_upper8 ((state[1] >> 24) & 255) << 16;
338     const u32 w4_t = uint_to_hex_upper8 ((state[2] >>  0) & 255) <<  0
339                      | uint_to_hex_upper8 ((state[2] >>  8) & 255) << 16;
340     const u32 w5_t = uint_to_hex_upper8 ((state[2] >> 16) & 255) <<  0
341                      | uint_to_hex_upper8 ((state[2] >> 24) & 255) << 16;
342     const u32 w6_t = uint_to_hex_upper8 ((state[3] >>  0) & 255) <<  0
343                      | uint_to_hex_upper8 ((state[3] >>  8) & 255) << 16;
344     //const u32 w7_t = uint_to_hex_upper8 ((state[3] >> 16) & 255) <<  0
345     //                 | uint_to_hex_upper8 ((state[3] >> 24) & 255) << 16;
346
347     const u32 pade = 0x0e0e0e0e;
348
349     w_tmp[ 0] = salt0;
350     w_tmp[ 1] = salt1      | w0_t << 16;
351     w_tmp[ 2] = w0_t >> 16 | w1_t << 16;
352     w_tmp[ 3] = w1_t >> 16 | w2_t << 16;
353     w_tmp[ 4] = w2_t >> 16 | w3_t << 16;
354     w_tmp[ 5] = w3_t >> 16 | w4_t << 16;
355     w_tmp[ 6] = w4_t >> 16 | w5_t << 16;
356     w_tmp[ 7] = w5_t >> 16 | w6_t << 16;
357     w_tmp[ 8] = w6_t >> 16 | pade << 16; // | w7_t <<  8;
358     w_tmp[ 9] = pade;
359     w_tmp[10] = pade;
360     w_tmp[11] = pade;
361     w_tmp[12] = 0;
362     w_tmp[13] = 0;
363     w_tmp[14] = 0;
364     w_tmp[15] = 0;
365
366     state[0] = 0;
367     state[1] = 0;
368     state[2] = 0;
369     state[3] = 0;
370
371     domino_big_md (w_tmp, 34, state, s_lotus_magic_table);
372
373     u32 a = state[0] & 0xffffffff;
374     u32 b = state[1] & 0xffffffff;
375     u32 c = state[2] & 0x000000ff;
376     u32 d = state[3] & 0x00000000;
377
378     const u32 r0 = a;
379     const u32 r1 = b;
380     const u32 r2 = c;
381     const u32 r3 = d;
382
383     #include COMPARE_M
384   }
385 }
386
387 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)
388 {
389   /**
390    * modifier
391    */
392
393   const u32 gid = get_global_id (0);
394   const u32 lid = get_local_id (0);
395
396   /**
397    * base
398    */
399
400   if (pw_len < 16)
401   {
402     pad (&w[ 0], pw_len & 0xf);
403   }
404   else if (pw_len < 32)
405   {
406     pad (&w[ 4], pw_len & 0xf);
407   }
408   else if (pw_len < 48)
409   {
410     pad (&w[ 8], pw_len & 0xf);
411   }
412   else if (pw_len < 64)
413   {
414     pad (&w[12], pw_len & 0xf);
415   }
416
417   /**
418    * salt
419    */
420
421   const u32 salt0 = salt_bufs[salt_pos].salt_buf[0];
422   const u32 salt1 = salt_bufs[salt_pos].salt_buf[1] & 0xff | '(' << 8;
423
424   /**
425    * digest
426    */
427
428   const u32 search[4] =
429   {
430     digests_buf[digests_offset].digest_buf[DGST_R0],
431     digests_buf[digests_offset].digest_buf[DGST_R1],
432     digests_buf[digests_offset].digest_buf[DGST_R2],
433     digests_buf[digests_offset].digest_buf[DGST_R3]
434   };
435
436   /**
437    * loop
438    */
439
440   u32 w0l = w[0];
441
442   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
443   {
444     const u32 w0r = words_buf_r[il_pos];
445
446     const u32 w0 = w0l | w0r;
447
448     u32 w_tmp[16];
449
450     w_tmp[ 0] = w0;
451     w_tmp[ 1] = w[ 1];
452     w_tmp[ 2] = w[ 2];
453     w_tmp[ 3] = w[ 3];
454     w_tmp[ 4] = w[ 4];
455     w_tmp[ 5] = w[ 5];
456     w_tmp[ 6] = w[ 6];
457     w_tmp[ 7] = w[ 7];
458     w_tmp[ 8] = w[ 8];
459     w_tmp[ 9] = w[ 9];
460     w_tmp[10] = w[10];
461     w_tmp[11] = w[11];
462     w_tmp[12] = w[12];
463     w_tmp[13] = w[13];
464     w_tmp[14] = w[14];
465     w_tmp[15] = w[15];
466
467     u32 state[4];
468
469     state[0] = 0;
470     state[1] = 0;
471     state[2] = 0;
472     state[3] = 0;
473
474     domino_big_md (w_tmp, pw_len, state, s_lotus_magic_table);
475
476     const u32 w0_t = uint_to_hex_upper8 ((state[0] >>  0) & 255) <<  0
477                      | uint_to_hex_upper8 ((state[0] >>  8) & 255) << 16;
478     const u32 w1_t = uint_to_hex_upper8 ((state[0] >> 16) & 255) <<  0
479                      | uint_to_hex_upper8 ((state[0] >> 24) & 255) << 16;
480     const u32 w2_t = uint_to_hex_upper8 ((state[1] >>  0) & 255) <<  0
481                      | uint_to_hex_upper8 ((state[1] >>  8) & 255) << 16;
482     const u32 w3_t = uint_to_hex_upper8 ((state[1] >> 16) & 255) <<  0
483                      | uint_to_hex_upper8 ((state[1] >> 24) & 255) << 16;
484     const u32 w4_t = uint_to_hex_upper8 ((state[2] >>  0) & 255) <<  0
485                      | uint_to_hex_upper8 ((state[2] >>  8) & 255) << 16;
486     const u32 w5_t = uint_to_hex_upper8 ((state[2] >> 16) & 255) <<  0
487                      | uint_to_hex_upper8 ((state[2] >> 24) & 255) << 16;
488     const u32 w6_t = uint_to_hex_upper8 ((state[3] >>  0) & 255) <<  0
489                      | uint_to_hex_upper8 ((state[3] >>  8) & 255) << 16;
490     //const u32 w7_t = uint_to_hex_upper8 ((state[3] >> 16) & 255) <<  0
491     //                 | uint_to_hex_upper8 ((state[3] >> 24) & 255) << 16;
492
493     const u32 pade = 0x0e0e0e0e;
494
495     w_tmp[ 0] = salt0;
496     w_tmp[ 1] = salt1      | w0_t << 16;
497     w_tmp[ 2] = w0_t >> 16 | w1_t << 16;
498     w_tmp[ 3] = w1_t >> 16 | w2_t << 16;
499     w_tmp[ 4] = w2_t >> 16 | w3_t << 16;
500     w_tmp[ 5] = w3_t >> 16 | w4_t << 16;
501     w_tmp[ 6] = w4_t >> 16 | w5_t << 16;
502     w_tmp[ 7] = w5_t >> 16 | w6_t << 16;
503     w_tmp[ 8] = w6_t >> 16 | pade << 16; // | w7_t <<  8;
504     w_tmp[ 9] = pade;
505     w_tmp[10] = pade;
506     w_tmp[11] = pade;
507     w_tmp[12] = 0;
508     w_tmp[13] = 0;
509     w_tmp[14] = 0;
510     w_tmp[15] = 0;
511
512     state[0] = 0;
513     state[1] = 0;
514     state[2] = 0;
515     state[3] = 0;
516
517     domino_big_md (w_tmp, 34, state, s_lotus_magic_table);
518
519     u32 a = state[0] & 0xffffffff;
520     u32 b = state[1] & 0xffffffff;
521     u32 c = state[2] & 0x000000ff;
522     u32 d = state[3] & 0x00000000;
523
524     const u32 r0 = a;
525     const u32 r1 = b;
526     const u32 r2 = c;
527     const u32 r3 = d;
528
529     #include COMPARE_S
530   }
531 }
532
533 __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)
534 {
535   /**
536    * base
537    */
538
539   const u32 gid = get_global_id (0);
540   const u32 lid = get_local_id (0);
541
542   u32 w[16];
543
544   w[ 0] = pws[gid].i[ 0];
545   w[ 1] = pws[gid].i[ 1];
546   w[ 2] = pws[gid].i[ 2];
547   w[ 3] = pws[gid].i[ 3];
548   w[ 4] = 0;
549   w[ 5] = 0;
550   w[ 6] = 0;
551   w[ 7] = 0;
552   w[ 8] = 0;
553   w[ 9] = 0;
554   w[10] = 0;
555   w[11] = 0;
556   w[12] = 0;
557   w[13] = 0;
558   w[14] = 0;
559   w[15] = 0;
560
561   const u32 pw_len = pws[gid].pw_len;
562
563   /**
564    * bin2asc table
565    */
566
567   __local u32 l_bin2asc[256];
568
569   const u32 lid4 = lid * 4;
570
571   const u32 lid40 = lid4 + 0;
572   const u32 lid41 = lid4 + 1;
573   const u32 lid42 = lid4 + 2;
574   const u32 lid43 = lid4 + 3;
575
576   const u32 v400 = (lid40 >> 0) & 15;
577   const u32 v401 = (lid40 >> 4) & 15;
578   const u32 v410 = (lid41 >> 0) & 15;
579   const u32 v411 = (lid41 >> 4) & 15;
580   const u32 v420 = (lid42 >> 0) & 15;
581   const u32 v421 = (lid42 >> 4) & 15;
582   const u32 v430 = (lid43 >> 0) & 15;
583   const u32 v431 = (lid43 >> 4) & 15;
584
585   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'A' - 10 + v400) << 8
586                    | ((v401 < 10) ? '0' + v401 : 'A' - 10 + v401) << 0;
587   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'A' - 10 + v410) << 8
588                    | ((v411 < 10) ? '0' + v411 : 'A' - 10 + v411) << 0;
589   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'A' - 10 + v420) << 8
590                    | ((v421 < 10) ? '0' + v421 : 'A' - 10 + v421) << 0;
591   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'A' - 10 + v430) << 8
592                    | ((v431 < 10) ? '0' + v431 : 'A' - 10 + v431) << 0;
593
594   barrier (CLK_LOCAL_MEM_FENCE);
595
596   /**
597    * sbox
598    */
599
600   __local u32 s_lotus_magic_table[256];
601
602   s_lotus_magic_table[lid4 + 0] = lotus_magic_table[lid4 + 0];
603   s_lotus_magic_table[lid4 + 1] = lotus_magic_table[lid4 + 1];
604   s_lotus_magic_table[lid4 + 2] = lotus_magic_table[lid4 + 2];
605   s_lotus_magic_table[lid4 + 3] = lotus_magic_table[lid4 + 3];
606
607   barrier (CLK_LOCAL_MEM_FENCE);
608
609   if (gid >= gid_max) return;
610
611   /**
612    * main
613    */
614
615   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);
616 }
617
618 __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)
619 {
620   /**
621    * base
622    */
623
624   const u32 gid = get_global_id (0);
625   const u32 lid = get_local_id (0);
626
627   u32 w[16];
628
629   w[ 0] = pws[gid].i[ 0];
630   w[ 1] = pws[gid].i[ 1];
631   w[ 2] = pws[gid].i[ 2];
632   w[ 3] = pws[gid].i[ 3];
633   w[ 4] = pws[gid].i[ 4];
634   w[ 5] = pws[gid].i[ 5];
635   w[ 6] = pws[gid].i[ 6];
636   w[ 7] = pws[gid].i[ 7];
637   w[ 8] = 0;
638   w[ 9] = 0;
639   w[10] = 0;
640   w[11] = 0;
641   w[12] = 0;
642   w[13] = 0;
643   w[14] = 0;
644   w[15] = 0;
645
646   const u32 pw_len = pws[gid].pw_len;
647
648   /**
649    * bin2asc table
650    */
651
652   __local u32 l_bin2asc[256];
653
654   const u32 lid4 = lid * 4;
655
656   const u32 lid40 = lid4 + 0;
657   const u32 lid41 = lid4 + 1;
658   const u32 lid42 = lid4 + 2;
659   const u32 lid43 = lid4 + 3;
660
661   const u32 v400 = (lid40 >> 0) & 15;
662   const u32 v401 = (lid40 >> 4) & 15;
663   const u32 v410 = (lid41 >> 0) & 15;
664   const u32 v411 = (lid41 >> 4) & 15;
665   const u32 v420 = (lid42 >> 0) & 15;
666   const u32 v421 = (lid42 >> 4) & 15;
667   const u32 v430 = (lid43 >> 0) & 15;
668   const u32 v431 = (lid43 >> 4) & 15;
669
670   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'A' - 10 + v400) << 8
671                    | ((v401 < 10) ? '0' + v401 : 'A' - 10 + v401) << 0;
672   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'A' - 10 + v410) << 8
673                    | ((v411 < 10) ? '0' + v411 : 'A' - 10 + v411) << 0;
674   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'A' - 10 + v420) << 8
675                    | ((v421 < 10) ? '0' + v421 : 'A' - 10 + v421) << 0;
676   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'A' - 10 + v430) << 8
677                    | ((v431 < 10) ? '0' + v431 : 'A' - 10 + v431) << 0;
678
679   barrier (CLK_LOCAL_MEM_FENCE);
680
681   /**
682    * sbox
683    */
684
685   __local u32 s_lotus_magic_table[256];
686
687   s_lotus_magic_table[lid4 + 0] = lotus_magic_table[lid4 + 0];
688   s_lotus_magic_table[lid4 + 1] = lotus_magic_table[lid4 + 1];
689   s_lotus_magic_table[lid4 + 2] = lotus_magic_table[lid4 + 2];
690   s_lotus_magic_table[lid4 + 3] = lotus_magic_table[lid4 + 3];
691
692   barrier (CLK_LOCAL_MEM_FENCE);
693
694   if (gid >= gid_max) return;
695
696   /**
697    * main
698    */
699
700   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);
701 }
702
703 __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)
704 {
705   /**
706    * base
707    */
708
709   const u32 gid = get_global_id (0);
710   const u32 lid = get_local_id (0);
711
712   u32 w[16];
713
714   w[ 0] = pws[gid].i[ 0];
715   w[ 1] = pws[gid].i[ 1];
716   w[ 2] = pws[gid].i[ 2];
717   w[ 3] = pws[gid].i[ 3];
718   w[ 4] = pws[gid].i[ 4];
719   w[ 5] = pws[gid].i[ 5];
720   w[ 6] = pws[gid].i[ 6];
721   w[ 7] = pws[gid].i[ 7];
722   w[ 8] = pws[gid].i[ 8];
723   w[ 9] = pws[gid].i[ 9];
724   w[10] = pws[gid].i[10];
725   w[11] = pws[gid].i[11];
726   w[12] = pws[gid].i[12];
727   w[13] = pws[gid].i[13];
728   w[14] = pws[gid].i[14];
729   w[15] = pws[gid].i[15];
730
731   const u32 pw_len = pws[gid].pw_len;
732
733   /**
734    * bin2asc table
735    */
736
737   __local u32 l_bin2asc[256];
738
739   const u32 lid4 = lid * 4;
740
741   const u32 lid40 = lid4 + 0;
742   const u32 lid41 = lid4 + 1;
743   const u32 lid42 = lid4 + 2;
744   const u32 lid43 = lid4 + 3;
745
746   const u32 v400 = (lid40 >> 0) & 15;
747   const u32 v401 = (lid40 >> 4) & 15;
748   const u32 v410 = (lid41 >> 0) & 15;
749   const u32 v411 = (lid41 >> 4) & 15;
750   const u32 v420 = (lid42 >> 0) & 15;
751   const u32 v421 = (lid42 >> 4) & 15;
752   const u32 v430 = (lid43 >> 0) & 15;
753   const u32 v431 = (lid43 >> 4) & 15;
754
755   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'A' - 10 + v400) << 8
756                    | ((v401 < 10) ? '0' + v401 : 'A' - 10 + v401) << 0;
757   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'A' - 10 + v410) << 8
758                    | ((v411 < 10) ? '0' + v411 : 'A' - 10 + v411) << 0;
759   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'A' - 10 + v420) << 8
760                    | ((v421 < 10) ? '0' + v421 : 'A' - 10 + v421) << 0;
761   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'A' - 10 + v430) << 8
762                    | ((v431 < 10) ? '0' + v431 : 'A' - 10 + v431) << 0;
763
764   barrier (CLK_LOCAL_MEM_FENCE);
765
766   /**
767    * sbox
768    */
769
770   __local u32 s_lotus_magic_table[256];
771
772   s_lotus_magic_table[lid4 + 0] = lotus_magic_table[lid4 + 0];
773   s_lotus_magic_table[lid4 + 1] = lotus_magic_table[lid4 + 1];
774   s_lotus_magic_table[lid4 + 2] = lotus_magic_table[lid4 + 2];
775   s_lotus_magic_table[lid4 + 3] = lotus_magic_table[lid4 + 3];
776
777   barrier (CLK_LOCAL_MEM_FENCE);
778
779   if (gid >= gid_max) return;
780
781   /**
782    * main
783    */
784
785   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);
786 }
787
788 __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)
789 {
790   /**
791    * base
792    */
793
794   const u32 gid = get_global_id (0);
795   const u32 lid = get_local_id (0);
796
797   u32 w[16];
798
799   w[ 0] = pws[gid].i[ 0];
800   w[ 1] = pws[gid].i[ 1];
801   w[ 2] = pws[gid].i[ 2];
802   w[ 3] = pws[gid].i[ 3];
803   w[ 4] = 0;
804   w[ 5] = 0;
805   w[ 6] = 0;
806   w[ 7] = 0;
807   w[ 8] = 0;
808   w[ 9] = 0;
809   w[10] = 0;
810   w[11] = 0;
811   w[12] = 0;
812   w[13] = 0;
813   w[14] = 0;
814   w[15] = 0;
815
816   const u32 pw_len = pws[gid].pw_len;
817
818   /**
819    * bin2asc table
820    */
821
822   __local u32 l_bin2asc[256];
823
824   const u32 lid4 = lid * 4;
825
826   const u32 lid40 = lid4 + 0;
827   const u32 lid41 = lid4 + 1;
828   const u32 lid42 = lid4 + 2;
829   const u32 lid43 = lid4 + 3;
830
831   const u32 v400 = (lid40 >> 0) & 15;
832   const u32 v401 = (lid40 >> 4) & 15;
833   const u32 v410 = (lid41 >> 0) & 15;
834   const u32 v411 = (lid41 >> 4) & 15;
835   const u32 v420 = (lid42 >> 0) & 15;
836   const u32 v421 = (lid42 >> 4) & 15;
837   const u32 v430 = (lid43 >> 0) & 15;
838   const u32 v431 = (lid43 >> 4) & 15;
839
840   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'A' - 10 + v400) << 8
841                    | ((v401 < 10) ? '0' + v401 : 'A' - 10 + v401) << 0;
842   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'A' - 10 + v410) << 8
843                    | ((v411 < 10) ? '0' + v411 : 'A' - 10 + v411) << 0;
844   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'A' - 10 + v420) << 8
845                    | ((v421 < 10) ? '0' + v421 : 'A' - 10 + v421) << 0;
846   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'A' - 10 + v430) << 8
847                    | ((v431 < 10) ? '0' + v431 : 'A' - 10 + v431) << 0;
848
849   barrier (CLK_LOCAL_MEM_FENCE);
850
851   /**
852    * sbox
853    */
854
855   __local u32 s_lotus_magic_table[256];
856
857   s_lotus_magic_table[lid4 + 0] = lotus_magic_table[lid4 + 0];
858   s_lotus_magic_table[lid4 + 1] = lotus_magic_table[lid4 + 1];
859   s_lotus_magic_table[lid4 + 2] = lotus_magic_table[lid4 + 2];
860   s_lotus_magic_table[lid4 + 3] = lotus_magic_table[lid4 + 3];
861
862   barrier (CLK_LOCAL_MEM_FENCE);
863
864   if (gid >= gid_max) return;
865
866   /**
867    * main
868    */
869
870   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);
871 }
872
873 __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)
874 {
875   /**
876    * base
877    */
878
879   const u32 gid = get_global_id (0);
880   const u32 lid = get_local_id (0);
881
882   u32 w[16];
883
884   w[ 0] = pws[gid].i[ 0];
885   w[ 1] = pws[gid].i[ 1];
886   w[ 2] = pws[gid].i[ 2];
887   w[ 3] = pws[gid].i[ 3];
888   w[ 4] = pws[gid].i[ 4];
889   w[ 5] = pws[gid].i[ 5];
890   w[ 6] = pws[gid].i[ 6];
891   w[ 7] = pws[gid].i[ 7];
892   w[ 8] = 0;
893   w[ 9] = 0;
894   w[10] = 0;
895   w[11] = 0;
896   w[12] = 0;
897   w[13] = 0;
898   w[14] = 0;
899   w[15] = 0;
900
901   const u32 pw_len = pws[gid].pw_len;
902
903   /**
904    * bin2asc table
905    */
906
907   __local u32 l_bin2asc[256];
908
909   const u32 lid4 = lid * 4;
910
911   const u32 lid40 = lid4 + 0;
912   const u32 lid41 = lid4 + 1;
913   const u32 lid42 = lid4 + 2;
914   const u32 lid43 = lid4 + 3;
915
916   const u32 v400 = (lid40 >> 0) & 15;
917   const u32 v401 = (lid40 >> 4) & 15;
918   const u32 v410 = (lid41 >> 0) & 15;
919   const u32 v411 = (lid41 >> 4) & 15;
920   const u32 v420 = (lid42 >> 0) & 15;
921   const u32 v421 = (lid42 >> 4) & 15;
922   const u32 v430 = (lid43 >> 0) & 15;
923   const u32 v431 = (lid43 >> 4) & 15;
924
925   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'A' - 10 + v400) << 8
926                    | ((v401 < 10) ? '0' + v401 : 'A' - 10 + v401) << 0;
927   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'A' - 10 + v410) << 8
928                    | ((v411 < 10) ? '0' + v411 : 'A' - 10 + v411) << 0;
929   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'A' - 10 + v420) << 8
930                    | ((v421 < 10) ? '0' + v421 : 'A' - 10 + v421) << 0;
931   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'A' - 10 + v430) << 8
932                    | ((v431 < 10) ? '0' + v431 : 'A' - 10 + v431) << 0;
933
934   barrier (CLK_LOCAL_MEM_FENCE);
935
936   /**
937    * sbox
938    */
939
940   __local u32 s_lotus_magic_table[256];
941
942   s_lotus_magic_table[lid4 + 0] = lotus_magic_table[lid4 + 0];
943   s_lotus_magic_table[lid4 + 1] = lotus_magic_table[lid4 + 1];
944   s_lotus_magic_table[lid4 + 2] = lotus_magic_table[lid4 + 2];
945   s_lotus_magic_table[lid4 + 3] = lotus_magic_table[lid4 + 3];
946
947   barrier (CLK_LOCAL_MEM_FENCE);
948
949   if (gid >= gid_max) return;
950
951   /**
952    * main
953    */
954
955   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);
956 }
957
958 __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)
959 {
960   /**
961    * base
962    */
963
964   const u32 gid = get_global_id (0);
965   const u32 lid = get_local_id (0);
966
967   u32 w[16];
968
969   w[ 0] = pws[gid].i[ 0];
970   w[ 1] = pws[gid].i[ 1];
971   w[ 2] = pws[gid].i[ 2];
972   w[ 3] = pws[gid].i[ 3];
973   w[ 4] = pws[gid].i[ 4];
974   w[ 5] = pws[gid].i[ 5];
975   w[ 6] = pws[gid].i[ 6];
976   w[ 7] = pws[gid].i[ 7];
977   w[ 8] = pws[gid].i[ 8];
978   w[ 9] = pws[gid].i[ 9];
979   w[10] = pws[gid].i[10];
980   w[11] = pws[gid].i[11];
981   w[12] = pws[gid].i[12];
982   w[13] = pws[gid].i[13];
983   w[14] = pws[gid].i[14];
984   w[15] = pws[gid].i[15];
985
986   const u32 pw_len = pws[gid].pw_len;
987
988   /**
989    * bin2asc table
990    */
991
992   __local u32 l_bin2asc[256];
993
994   const u32 lid4 = lid * 4;
995
996   const u32 lid40 = lid4 + 0;
997   const u32 lid41 = lid4 + 1;
998   const u32 lid42 = lid4 + 2;
999   const u32 lid43 = lid4 + 3;
1000
1001   const u32 v400 = (lid40 >> 0) & 15;
1002   const u32 v401 = (lid40 >> 4) & 15;
1003   const u32 v410 = (lid41 >> 0) & 15;
1004   const u32 v411 = (lid41 >> 4) & 15;
1005   const u32 v420 = (lid42 >> 0) & 15;
1006   const u32 v421 = (lid42 >> 4) & 15;
1007   const u32 v430 = (lid43 >> 0) & 15;
1008   const u32 v431 = (lid43 >> 4) & 15;
1009
1010   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'A' - 10 + v400) << 8
1011                    | ((v401 < 10) ? '0' + v401 : 'A' - 10 + v401) << 0;
1012   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'A' - 10 + v410) << 8
1013                    | ((v411 < 10) ? '0' + v411 : 'A' - 10 + v411) << 0;
1014   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'A' - 10 + v420) << 8
1015                    | ((v421 < 10) ? '0' + v421 : 'A' - 10 + v421) << 0;
1016   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'A' - 10 + v430) << 8
1017                    | ((v431 < 10) ? '0' + v431 : 'A' - 10 + v431) << 0;
1018
1019   barrier (CLK_LOCAL_MEM_FENCE);
1020
1021   /**
1022    * sbox
1023    */
1024
1025   __local u32 s_lotus_magic_table[256];
1026
1027   s_lotus_magic_table[lid4 + 0] = lotus_magic_table[lid4 + 0];
1028   s_lotus_magic_table[lid4 + 1] = lotus_magic_table[lid4 + 1];
1029   s_lotus_magic_table[lid4 + 2] = lotus_magic_table[lid4 + 2];
1030   s_lotus_magic_table[lid4 + 3] = lotus_magic_table[lid4 + 3];
1031
1032   barrier (CLK_LOCAL_MEM_FENCE);
1033
1034   if (gid >= gid_max) return;
1035
1036   /**
1037    * main
1038    */
1039
1040   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);
1041 }