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