Merge branch 'master' of https://github.com/hashcat/oclHashcat
[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 "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19
20 #define COMPARE_S "OpenCL/check_single_comp4.c"
21 #define COMPARE_M "OpenCL/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[4], u32 out[4], __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 kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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 kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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 m08700_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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   const u32 lsz = get_local_size (0);
542
543   /**
544    * sbox
545    */
546
547   __local u32 s_lotus_magic_table[256];
548
549   for (u32 i = lid; i < 256; i += lsz)
550   {
551     s_lotus_magic_table[i] = lotus_magic_table[i];
552   }
553
554   __local u32 l_bin2asc[256];
555
556   for (u32 i = lid; i < 256; i += lsz)
557   {
558     const u32 i0 = (i >> 0) & 15;
559     const u32 i1 = (i >> 4) & 15;
560
561     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
562                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
563   }
564
565   barrier (CLK_LOCAL_MEM_FENCE);
566
567   if (gid >= gid_max) return;
568
569   /**
570    * base
571    */
572
573   u32 w[16];
574
575   w[ 0] = pws[gid].i[ 0];
576   w[ 1] = pws[gid].i[ 1];
577   w[ 2] = pws[gid].i[ 2];
578   w[ 3] = pws[gid].i[ 3];
579   w[ 4] = 0;
580   w[ 5] = 0;
581   w[ 6] = 0;
582   w[ 7] = 0;
583   w[ 8] = 0;
584   w[ 9] = 0;
585   w[10] = 0;
586   w[11] = 0;
587   w[12] = 0;
588   w[13] = 0;
589   w[14] = 0;
590   w[15] = 0;
591
592   const u32 pw_len = pws[gid].pw_len;
593
594   /**
595    * main
596    */
597
598   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);
599 }
600
601 __kernel void m08700_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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)
602 {
603   /**
604    * base
605    */
606
607   const u32 gid = get_global_id (0);
608   const u32 lid = get_local_id (0);
609   const u32 lsz = get_local_size (0);
610
611   /**
612    * sbox
613    */
614
615   __local u32 s_lotus_magic_table[256];
616
617   for (u32 i = lid; i < 256; i += lsz)
618   {
619     s_lotus_magic_table[i] = lotus_magic_table[i];
620   }
621
622   __local u32 l_bin2asc[256];
623
624   for (u32 i = lid; i < 256; i += lsz)
625   {
626     const u32 i0 = (i >> 0) & 15;
627     const u32 i1 = (i >> 4) & 15;
628
629     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
630                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
631   }
632
633   barrier (CLK_LOCAL_MEM_FENCE);
634
635   if (gid >= gid_max) return;
636
637   /**
638    * base
639    */
640
641   u32 w[16];
642
643   w[ 0] = pws[gid].i[ 0];
644   w[ 1] = pws[gid].i[ 1];
645   w[ 2] = pws[gid].i[ 2];
646   w[ 3] = pws[gid].i[ 3];
647   w[ 4] = pws[gid].i[ 4];
648   w[ 5] = pws[gid].i[ 5];
649   w[ 6] = pws[gid].i[ 6];
650   w[ 7] = pws[gid].i[ 7];
651   w[ 8] = 0;
652   w[ 9] = 0;
653   w[10] = 0;
654   w[11] = 0;
655   w[12] = 0;
656   w[13] = 0;
657   w[14] = 0;
658   w[15] = 0;
659
660   const u32 pw_len = pws[gid].pw_len;
661
662   /**
663    * main
664    */
665
666   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);
667 }
668
669 __kernel void m08700_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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)
670 {
671   /**
672    * base
673    */
674
675   const u32 gid = get_global_id (0);
676   const u32 lid = get_local_id (0);
677   const u32 lsz = get_local_size (0);
678
679   /**
680    * sbox
681    */
682
683   __local u32 s_lotus_magic_table[256];
684
685   for (u32 i = lid; i < 256; i += lsz)
686   {
687     s_lotus_magic_table[i] = lotus_magic_table[i];
688   }
689
690   __local u32 l_bin2asc[256];
691
692   for (u32 i = lid; i < 256; i += lsz)
693   {
694     const u32 i0 = (i >> 0) & 15;
695     const u32 i1 = (i >> 4) & 15;
696
697     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
698                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
699   }
700
701   barrier (CLK_LOCAL_MEM_FENCE);
702
703   if (gid >= gid_max) return;
704
705   /**
706    * base
707    */
708
709   u32 w[16];
710
711   w[ 0] = pws[gid].i[ 0];
712   w[ 1] = pws[gid].i[ 1];
713   w[ 2] = pws[gid].i[ 2];
714   w[ 3] = pws[gid].i[ 3];
715   w[ 4] = pws[gid].i[ 4];
716   w[ 5] = pws[gid].i[ 5];
717   w[ 6] = pws[gid].i[ 6];
718   w[ 7] = pws[gid].i[ 7];
719   w[ 8] = pws[gid].i[ 8];
720   w[ 9] = pws[gid].i[ 9];
721   w[10] = pws[gid].i[10];
722   w[11] = pws[gid].i[11];
723   w[12] = pws[gid].i[12];
724   w[13] = pws[gid].i[13];
725   w[14] = pws[gid].i[14];
726   w[15] = pws[gid].i[15];
727
728   const u32 pw_len = pws[gid].pw_len;
729
730   /**
731    * main
732    */
733
734   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);
735 }
736
737 __kernel void m08700_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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)
738 {
739   /**
740    * base
741    */
742
743   const u32 gid = get_global_id (0);
744   const u32 lid = get_local_id (0);
745   const u32 lsz = get_local_size (0);
746
747   /**
748    * sbox
749    */
750
751   __local u32 s_lotus_magic_table[256];
752
753   for (u32 i = lid; i < 256; i += lsz)
754   {
755     s_lotus_magic_table[i] = lotus_magic_table[i];
756   }
757
758   __local u32 l_bin2asc[256];
759
760   for (u32 i = lid; i < 256; i += lsz)
761   {
762     const u32 i0 = (i >> 0) & 15;
763     const u32 i1 = (i >> 4) & 15;
764
765     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
766                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
767   }
768
769   barrier (CLK_LOCAL_MEM_FENCE);
770
771   if (gid >= gid_max) return;
772
773   /**
774    * base
775    */
776
777   u32 w[16];
778
779   w[ 0] = pws[gid].i[ 0];
780   w[ 1] = pws[gid].i[ 1];
781   w[ 2] = pws[gid].i[ 2];
782   w[ 3] = pws[gid].i[ 3];
783   w[ 4] = 0;
784   w[ 5] = 0;
785   w[ 6] = 0;
786   w[ 7] = 0;
787   w[ 8] = 0;
788   w[ 9] = 0;
789   w[10] = 0;
790   w[11] = 0;
791   w[12] = 0;
792   w[13] = 0;
793   w[14] = 0;
794   w[15] = 0;
795
796   const u32 pw_len = pws[gid].pw_len;
797
798   /**
799    * main
800    */
801
802   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);
803 }
804
805 __kernel void m08700_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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)
806 {
807   /**
808    * base
809    */
810
811   const u32 gid = get_global_id (0);
812   const u32 lid = get_local_id (0);
813   const u32 lsz = get_local_size (0);
814
815   /**
816    * sbox
817    */
818
819   __local u32 s_lotus_magic_table[256];
820
821   for (u32 i = lid; i < 256; i += lsz)
822   {
823     s_lotus_magic_table[i] = lotus_magic_table[i];
824   }
825
826   __local u32 l_bin2asc[256];
827
828   for (u32 i = lid; i < 256; i += lsz)
829   {
830     const u32 i0 = (i >> 0) & 15;
831     const u32 i1 = (i >> 4) & 15;
832
833     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
834                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
835   }
836
837   barrier (CLK_LOCAL_MEM_FENCE);
838
839   if (gid >= gid_max) return;
840
841   /**
842    * base
843    */
844
845   u32 w[16];
846
847   w[ 0] = pws[gid].i[ 0];
848   w[ 1] = pws[gid].i[ 1];
849   w[ 2] = pws[gid].i[ 2];
850   w[ 3] = pws[gid].i[ 3];
851   w[ 4] = pws[gid].i[ 4];
852   w[ 5] = pws[gid].i[ 5];
853   w[ 6] = pws[gid].i[ 6];
854   w[ 7] = pws[gid].i[ 7];
855   w[ 8] = 0;
856   w[ 9] = 0;
857   w[10] = 0;
858   w[11] = 0;
859   w[12] = 0;
860   w[13] = 0;
861   w[14] = 0;
862   w[15] = 0;
863
864   const u32 pw_len = pws[gid].pw_len;
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 m08700_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant 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   const u32 lsz = get_local_size (0);
882
883   /**
884    * sbox
885    */
886
887   __local u32 s_lotus_magic_table[256];
888
889   for (u32 i = lid; i < 256; i += lsz)
890   {
891     s_lotus_magic_table[i] = lotus_magic_table[i];
892   }
893
894   __local u32 l_bin2asc[256];
895
896   for (u32 i = lid; i < 256; i += lsz)
897   {
898     const u32 i0 = (i >> 0) & 15;
899     const u32 i1 = (i >> 4) & 15;
900
901     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
902                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
903   }
904
905   barrier (CLK_LOCAL_MEM_FENCE);
906
907   if (gid >= gid_max) return;
908
909   /**
910    * base
911    */
912
913   u32 w[16];
914
915   w[ 0] = pws[gid].i[ 0];
916   w[ 1] = pws[gid].i[ 1];
917   w[ 2] = pws[gid].i[ 2];
918   w[ 3] = pws[gid].i[ 3];
919   w[ 4] = pws[gid].i[ 4];
920   w[ 5] = pws[gid].i[ 5];
921   w[ 6] = pws[gid].i[ 6];
922   w[ 7] = pws[gid].i[ 7];
923   w[ 8] = pws[gid].i[ 8];
924   w[ 9] = pws[gid].i[ 9];
925   w[10] = pws[gid].i[10];
926   w[11] = pws[gid].i[11];
927   w[12] = pws[gid].i[12];
928   w[13] = pws[gid].i[13];
929   w[14] = pws[gid].i[14];
930   w[15] = pws[gid].i[15];
931
932   const u32 pw_len = pws[gid].pw_len;
933
934   /**
935    * main
936    */
937
938   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);
939 }