Revert some RC4 based kernels back to scalar processing
[hashcat.git] / OpenCL / m10400_a3.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_
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 #include "OpenCL/simd.c"
20
21 __constant u32 padding[8] =
22 {
23   0x5e4ebf28,
24   0x418a754e,
25   0x564e0064,
26   0x0801faff,
27   0xb6002e2e,
28   0x803e68d0,
29   0xfea90c2f,
30   0x7a695364
31 };
32
33 typedef struct
34 {
35   u8 S[256];
36
37   u32 wtf_its_faster;
38
39 } RC4_KEY;
40
41 static void swap (__local RC4_KEY *rc4_key, const u8 i, const u8 j)
42 {
43   u8 tmp;
44
45   tmp           = rc4_key->S[i];
46   rc4_key->S[i] = rc4_key->S[j];
47   rc4_key->S[j] = tmp;
48 }
49
50 static void rc4_init_16 (__local RC4_KEY *rc4_key, const u32 data[4])
51 {
52   u32 v = 0x03020100;
53   u32 a = 0x04040404;
54
55   __local u32 *ptr = (__local u32 *) rc4_key->S;
56
57   #pragma unroll
58   for (u32 i = 0; i < 64; i++)
59   {
60     ptr[i] = v; v += a;
61   }
62
63   const u32 d0 = data[0] >>  0;
64   const u32 d1 = data[0] >>  8;
65   const u32 d2 = data[0] >> 16;
66   const u32 d3 = data[0] >> 24;
67   const u32 d4 = data[1] >>  0;
68
69   u32 j = 0;
70
71   #pragma unroll
72   for (u32 i = 0; i < 255; i += 5)
73   {
74     j += rc4_key->S[i + 0] + d0; swap (rc4_key, i + 0, j);
75     j += rc4_key->S[i + 1] + d1; swap (rc4_key, i + 1, j);
76     j += rc4_key->S[i + 2] + d2; swap (rc4_key, i + 2, j);
77     j += rc4_key->S[i + 3] + d3; swap (rc4_key, i + 3, j);
78     j += rc4_key->S[i + 4] + d4; swap (rc4_key, i + 4, j);
79   }
80
81   j += rc4_key->S[255] + d0; swap (rc4_key, 255, j);
82 }
83
84 static u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, __constant u32 in[4], u32 out[4])
85 {
86   #pragma unroll 4
87   for (u32 k = 0; k < 4; k++)
88   {
89     u32 xor4 = 0;
90
91     u8 idx;
92
93     i += 1;
94     j += rc4_key->S[i];
95
96     swap (rc4_key, i, j);
97
98     idx = rc4_key->S[i] + rc4_key->S[j];
99
100     xor4 |= rc4_key->S[idx] <<  0;
101
102     i += 1;
103     j += rc4_key->S[i];
104
105     swap (rc4_key, i, j);
106
107     idx = rc4_key->S[i] + rc4_key->S[j];
108
109     xor4 |= rc4_key->S[idx] <<  8;
110
111     i += 1;
112     j += rc4_key->S[i];
113
114     swap (rc4_key, i, j);
115
116     idx = rc4_key->S[i] + rc4_key->S[j];
117
118     xor4 |= rc4_key->S[idx] << 16;
119
120     i += 1;
121     j += rc4_key->S[i];
122
123     swap (rc4_key, i, j);
124
125     idx = rc4_key->S[i] + rc4_key->S[j];
126
127     xor4 |= rc4_key->S[idx] << 24;
128
129     out[k] = in[k] ^ xor4;
130   }
131
132   return j;
133 }
134
135 static void md5_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[4])
136 {
137   u32 a = digest[0];
138   u32 b = digest[1];
139   u32 c = digest[2];
140   u32 d = digest[3];
141
142   u32 w0_t = w0[0];
143   u32 w1_t = w0[1];
144   u32 w2_t = w0[2];
145   u32 w3_t = w0[3];
146   u32 w4_t = w1[0];
147   u32 w5_t = w1[1];
148   u32 w6_t = w1[2];
149   u32 w7_t = w1[3];
150   u32 w8_t = w2[0];
151   u32 w9_t = w2[1];
152   u32 wa_t = w2[2];
153   u32 wb_t = w2[3];
154   u32 wc_t = w3[0];
155   u32 wd_t = w3[1];
156   u32 we_t = w3[2];
157   u32 wf_t = w3[3];
158
159   MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
160   MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
161   MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
162   MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
163   MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
164   MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
165   MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
166   MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
167   MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
168   MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
169   MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
170   MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
171   MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
172   MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
173   MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
174   MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
175
176   MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
177   MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
178   MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
179   MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
180   MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
181   MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
182   MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
183   MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
184   MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
185   MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
186   MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
187   MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
188   MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
189   MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
190   MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
191   MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
192
193   MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
194   MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
195   MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
196   MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
197   MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
198   MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
199   MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
200   MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
201   MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
202   MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
203   MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
204   MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
205   MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
206   MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
207   MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
208   MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
209
210   MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
211   MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
212   MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
213   MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
214   MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
215   MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
216   MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
217   MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
218   MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
219   MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
220   MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
221   MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
222   MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
223   MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
224   MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
225   MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
226
227   digest[0] += a;
228   digest[1] += b;
229   digest[2] += c;
230   digest[3] += d;
231 }
232
233 static void m10400m (__local RC4_KEY rc4_keys[64], u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_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)
234 {
235   /**
236    * modifier
237    */
238
239   const u32 gid = get_global_id (0);
240   const u32 lid = get_local_id (0);
241
242   __local RC4_KEY *rc4_key = &rc4_keys[lid];
243
244   /**
245    * U_buf
246    */
247
248   u32 o_buf[8];
249
250   o_buf[0] = pdf_bufs[salt_pos].o_buf[0];
251   o_buf[1] = pdf_bufs[salt_pos].o_buf[1];
252   o_buf[2] = pdf_bufs[salt_pos].o_buf[2];
253   o_buf[3] = pdf_bufs[salt_pos].o_buf[3];
254   o_buf[4] = pdf_bufs[salt_pos].o_buf[4];
255   o_buf[5] = pdf_bufs[salt_pos].o_buf[5];
256   o_buf[6] = pdf_bufs[salt_pos].o_buf[6];
257   o_buf[7] = pdf_bufs[salt_pos].o_buf[7];
258
259   u32 P = pdf_bufs[salt_pos].P;
260
261   u32 id_buf[4];
262
263   id_buf[0] = pdf_bufs[salt_pos].id_buf[0];
264   id_buf[1] = pdf_bufs[salt_pos].id_buf[1];
265   id_buf[2] = pdf_bufs[salt_pos].id_buf[2];
266   id_buf[3] = pdf_bufs[salt_pos].id_buf[3];
267
268   /**
269    * loop
270    */
271
272   u32 w0l = w0[0];
273
274   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
275   {
276     const u32 w0r = w0r_create_bft (bfs_buf, il_pos);
277
278     w0[0] = w0l | w0r;
279
280     u32 w0_t[4];
281     u32 w1_t[4];
282     u32 w2_t[4];
283     u32 w3_t[4];
284
285     // max length supported by pdf11 is 32
286
287     w0_t[0] = padding[0];
288     w0_t[1] = padding[1];
289     w0_t[2] = padding[2];
290     w0_t[3] = padding[3];
291     w1_t[0] = padding[4];
292     w1_t[1] = padding[5];
293     w1_t[2] = padding[6];
294     w1_t[3] = padding[7];
295     w2_t[0] = 0;
296     w2_t[1] = 0;
297     w2_t[2] = 0;
298     w2_t[3] = 0;
299     w3_t[0] = 0;
300     w3_t[1] = 0;
301     w3_t[2] = 0;
302     w3_t[3] = 0;
303
304     switch_buffer_by_offset_le_S (w0_t, w1_t, w2_t, w3_t, pw_len);
305
306     // add password
307     // truncate at 32 is wanted, not a bug!
308     // add o_buf
309
310     w0_t[0] |= w0[0];
311     w0_t[1] |= w0[1];
312     w0_t[2] |= w0[2];
313     w0_t[3] |= w0[3];
314     w1_t[0] |= w1[0];
315     w1_t[1] |= w1[1];
316     w1_t[2] |= w1[2];
317     w1_t[3] |= w1[3];
318     w2_t[0]  = o_buf[0];
319     w2_t[1]  = o_buf[1];
320     w2_t[2]  = o_buf[2];
321     w2_t[3]  = o_buf[3];
322     w3_t[0]  = o_buf[4];
323     w3_t[1]  = o_buf[5];
324     w3_t[2]  = o_buf[6];
325     w3_t[3]  = o_buf[7];
326
327     u32 digest[4];
328
329     digest[0] = MD5M_A;
330     digest[1] = MD5M_B;
331     digest[2] = MD5M_C;
332     digest[3] = MD5M_D;
333
334     md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
335
336     w0_t[0] = P;
337     w0_t[1] = id_buf[0];
338     w0_t[2] = id_buf[1];
339     w0_t[3] = id_buf[2];
340     w1_t[0] = id_buf[3];
341     w1_t[1] = 0x80;
342     w1_t[2] = 0;
343     w1_t[3] = 0;
344     w2_t[0] = 0;
345     w2_t[1] = 0;
346     w2_t[2] = 0;
347     w2_t[3] = 0;
348     w3_t[0] = 0;
349     w3_t[1] = 0;
350     w3_t[2] = 84 * 8;
351     w3_t[3] = 0;
352
353     md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
354
355     // now the RC4 part
356
357     u32 key[4];
358
359     key[0] = digest[0];
360     key[1] = digest[1] & 0xff;
361     key[2] = 0;
362     key[3] = 0;
363
364     rc4_init_16 (rc4_key, key);
365
366     u32 out[4];
367
368     rc4_next_16 (rc4_key, 0, 0, padding, out);
369
370     COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
371   }
372 }
373
374 static void m10400s (__local RC4_KEY rc4_keys[64], u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_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)
375 {
376   /**
377    * modifier
378    */
379
380   const u32 gid = get_global_id (0);
381   const u32 lid = get_local_id (0);
382
383   __local RC4_KEY *rc4_key = &rc4_keys[lid];
384
385   /**
386    * digest
387    */
388
389   const u32 search[4] =
390   {
391     digests_buf[digests_offset].digest_buf[DGST_R0],
392     digests_buf[digests_offset].digest_buf[DGST_R1],
393     digests_buf[digests_offset].digest_buf[DGST_R2],
394     digests_buf[digests_offset].digest_buf[DGST_R3]
395   };
396
397   /**
398    * U_buf
399    */
400
401   u32 o_buf[8];
402
403   o_buf[0] = pdf_bufs[salt_pos].o_buf[0];
404   o_buf[1] = pdf_bufs[salt_pos].o_buf[1];
405   o_buf[2] = pdf_bufs[salt_pos].o_buf[2];
406   o_buf[3] = pdf_bufs[salt_pos].o_buf[3];
407   o_buf[4] = pdf_bufs[salt_pos].o_buf[4];
408   o_buf[5] = pdf_bufs[salt_pos].o_buf[5];
409   o_buf[6] = pdf_bufs[salt_pos].o_buf[6];
410   o_buf[7] = pdf_bufs[salt_pos].o_buf[7];
411
412   u32 P = pdf_bufs[salt_pos].P;
413
414   u32 id_buf[4];
415
416   id_buf[0] = pdf_bufs[salt_pos].id_buf[0];
417   id_buf[1] = pdf_bufs[salt_pos].id_buf[1];
418   id_buf[2] = pdf_bufs[salt_pos].id_buf[2];
419   id_buf[3] = pdf_bufs[salt_pos].id_buf[3];
420
421   /**
422    * loop
423    */
424
425   u32 w0l = w0[0];
426
427   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
428   {
429     const u32 w0r = w0r_create_bft (bfs_buf, il_pos);
430
431     w0[0] = w0l | w0r;
432
433     u32 w0_t[4];
434     u32 w1_t[4];
435     u32 w2_t[4];
436     u32 w3_t[4];
437
438     // max length supported by pdf11 is 32
439
440     w0_t[0] = padding[0];
441     w0_t[1] = padding[1];
442     w0_t[2] = padding[2];
443     w0_t[3] = padding[3];
444     w1_t[0] = padding[4];
445     w1_t[1] = padding[5];
446     w1_t[2] = padding[6];
447     w1_t[3] = padding[7];
448     w2_t[0] = 0;
449     w2_t[1] = 0;
450     w2_t[2] = 0;
451     w2_t[3] = 0;
452     w3_t[0] = 0;
453     w3_t[1] = 0;
454     w3_t[2] = 0;
455     w3_t[3] = 0;
456
457     switch_buffer_by_offset_le_S (w0_t, w1_t, w2_t, w3_t, pw_len);
458
459     // add password
460     // truncate at 32 is wanted, not a bug!
461     // add o_buf
462
463     w0_t[0] |= w0[0];
464     w0_t[1] |= w0[1];
465     w0_t[2] |= w0[2];
466     w0_t[3] |= w0[3];
467     w1_t[0] |= w1[0];
468     w1_t[1] |= w1[1];
469     w1_t[2] |= w1[2];
470     w1_t[3] |= w1[3];
471     w2_t[0]  = o_buf[0];
472     w2_t[1]  = o_buf[1];
473     w2_t[2]  = o_buf[2];
474     w2_t[3]  = o_buf[3];
475     w3_t[0]  = o_buf[4];
476     w3_t[1]  = o_buf[5];
477     w3_t[2]  = o_buf[6];
478     w3_t[3]  = o_buf[7];
479
480     u32 digest[4];
481
482     digest[0] = MD5M_A;
483     digest[1] = MD5M_B;
484     digest[2] = MD5M_C;
485     digest[3] = MD5M_D;
486
487     md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
488
489     w0_t[0] = P;
490     w0_t[1] = id_buf[0];
491     w0_t[2] = id_buf[1];
492     w0_t[3] = id_buf[2];
493     w1_t[0] = id_buf[3];
494     w1_t[1] = 0x80;
495     w1_t[2] = 0;
496     w1_t[3] = 0;
497     w2_t[0] = 0;
498     w2_t[1] = 0;
499     w2_t[2] = 0;
500     w2_t[3] = 0;
501     w3_t[0] = 0;
502     w3_t[1] = 0;
503     w3_t[2] = 84 * 8;
504     w3_t[3] = 0;
505
506     md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
507
508     // now the RC4 part
509
510     u32 key[4];
511
512     key[0] = digest[0];
513     key[1] = digest[1] & 0xff;
514     key[2] = 0;
515     key[3] = 0;
516
517     rc4_init_16 (rc4_key, key);
518
519     u32 out[4];
520
521     rc4_next_16 (rc4_key, 0, 0, padding, out);
522
523     COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
524   }
525 }
526
527 __kernel void m10400_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_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)
528 {
529   /**
530    * base
531    */
532
533   const u32 gid = get_global_id (0);
534
535   if (gid >= gid_max) return;
536
537   u32 w0[4];
538
539   w0[0] = pws[gid].i[ 0];
540   w0[1] = pws[gid].i[ 1];
541   w0[2] = pws[gid].i[ 2];
542   w0[3] = pws[gid].i[ 3];
543
544   u32 w1[4];
545
546   w1[0] = 0;
547   w1[1] = 0;
548   w1[2] = 0;
549   w1[3] = 0;
550
551   u32 w2[4];
552
553   w2[0] = 0;
554   w2[1] = 0;
555   w2[2] = 0;
556   w2[3] = 0;
557
558   u32 w3[4];
559
560   w3[0] = 0;
561   w3[1] = 0;
562   w3[2] = 0;
563   w3[3] = 0;
564
565   const u32 pw_len = pws[gid].pw_len;
566
567   /**
568    * main
569    */
570
571   __local RC4_KEY rc4_keys[64];
572
573   m10400m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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, pdf_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);
574 }
575
576 __kernel void m10400_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_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)
577 {
578   /**
579    * base
580    */
581
582   const u32 gid = get_global_id (0);
583
584   if (gid >= gid_max) return;
585
586   u32 w0[4];
587
588   w0[0] = pws[gid].i[ 0];
589   w0[1] = pws[gid].i[ 1];
590   w0[2] = pws[gid].i[ 2];
591   w0[3] = pws[gid].i[ 3];
592
593   u32 w1[4];
594
595   w1[0] = pws[gid].i[ 4];
596   w1[1] = pws[gid].i[ 5];
597   w1[2] = pws[gid].i[ 6];
598   w1[3] = pws[gid].i[ 7];
599
600   u32 w2[4];
601
602   w2[0] = 0;
603   w2[1] = 0;
604   w2[2] = 0;
605   w2[3] = 0;
606
607   u32 w3[4];
608
609   w3[0] = 0;
610   w3[1] = 0;
611   w3[2] = 0;
612   w3[3] = 0;
613
614   const u32 pw_len = pws[gid].pw_len;
615
616   /**
617    * main
618    */
619
620   __local RC4_KEY rc4_keys[64];
621
622   m10400m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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, pdf_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);
623 }
624
625 __kernel void m10400_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_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)
626 {
627   /**
628    * base
629    */
630
631   const u32 gid = get_global_id (0);
632
633   if (gid >= gid_max) return;
634
635   u32 w0[4];
636
637   w0[0] = pws[gid].i[ 0];
638   w0[1] = pws[gid].i[ 1];
639   w0[2] = pws[gid].i[ 2];
640   w0[3] = pws[gid].i[ 3];
641
642   u32 w1[4];
643
644   w1[0] = pws[gid].i[ 4];
645   w1[1] = pws[gid].i[ 5];
646   w1[2] = pws[gid].i[ 6];
647   w1[3] = pws[gid].i[ 7];
648
649   u32 w2[4];
650
651   w2[0] = pws[gid].i[ 8];
652   w2[1] = pws[gid].i[ 9];
653   w2[2] = pws[gid].i[10];
654   w2[3] = pws[gid].i[11];
655
656   u32 w3[4];
657
658   w3[0] = pws[gid].i[12];
659   w3[1] = pws[gid].i[13];
660   w3[2] = 0;
661   w3[3] = 0;
662
663   const u32 pw_len = pws[gid].pw_len;
664
665   /**
666    * main
667    */
668
669   __local RC4_KEY rc4_keys[64];
670
671   m10400m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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, pdf_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);
672 }
673
674 __kernel void m10400_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_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)
675 {
676   /**
677    * base
678    */
679
680   const u32 gid = get_global_id (0);
681
682   if (gid >= gid_max) return;
683
684   u32 w0[4];
685
686   w0[0] = pws[gid].i[ 0];
687   w0[1] = pws[gid].i[ 1];
688   w0[2] = pws[gid].i[ 2];
689   w0[3] = pws[gid].i[ 3];
690
691   u32 w1[4];
692
693   w1[0] = 0;
694   w1[1] = 0;
695   w1[2] = 0;
696   w1[3] = 0;
697
698   u32 w2[4];
699
700   w2[0] = 0;
701   w2[1] = 0;
702   w2[2] = 0;
703   w2[3] = 0;
704
705   u32 w3[4];
706
707   w3[0] = 0;
708   w3[1] = 0;
709   w3[2] = 0;
710   w3[3] = 0;
711
712   const u32 pw_len = pws[gid].pw_len;
713
714   /**
715    * main
716    */
717
718   __local RC4_KEY rc4_keys[64];
719
720   m10400s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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, pdf_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
721 }
722
723 __kernel void m10400_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
724 {
725   /**
726    * base
727    */
728
729   const u32 gid = get_global_id (0);
730
731   if (gid >= gid_max) return;
732
733   u32 w0[4];
734
735   w0[0] = pws[gid].i[ 0];
736   w0[1] = pws[gid].i[ 1];
737   w0[2] = pws[gid].i[ 2];
738   w0[3] = pws[gid].i[ 3];
739
740   u32 w1[4];
741
742   w1[0] = pws[gid].i[ 4];
743   w1[1] = pws[gid].i[ 5];
744   w1[2] = pws[gid].i[ 6];
745   w1[3] = pws[gid].i[ 7];
746
747   u32 w2[4];
748
749   w2[0] = 0;
750   w2[1] = 0;
751   w2[2] = 0;
752   w2[3] = 0;
753
754   u32 w3[4];
755
756   w3[0] = 0;
757   w3[1] = 0;
758   w3[2] = 0;
759   w3[3] = 0;
760
761   const u32 pw_len = pws[gid].pw_len;
762
763   /**
764    * main
765    */
766
767   __local RC4_KEY rc4_keys[64];
768
769   m10400s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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, pdf_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);
770 }
771
772 __kernel void m10400_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __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 pdf_t *pdf_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)
773 {
774   /**
775    * base
776    */
777
778   const u32 gid = get_global_id (0);
779
780   if (gid >= gid_max) return;
781
782   u32 w0[4];
783
784   w0[0] = pws[gid].i[ 0];
785   w0[1] = pws[gid].i[ 1];
786   w0[2] = pws[gid].i[ 2];
787   w0[3] = pws[gid].i[ 3];
788
789   u32 w1[4];
790
791   w1[0] = pws[gid].i[ 4];
792   w1[1] = pws[gid].i[ 5];
793   w1[2] = pws[gid].i[ 6];
794   w1[3] = pws[gid].i[ 7];
795
796   u32 w2[4];
797
798   w2[0] = pws[gid].i[ 8];
799   w2[1] = pws[gid].i[ 9];
800   w2[2] = pws[gid].i[10];
801   w2[3] = pws[gid].i[11];
802
803   u32 w3[4];
804
805   w3[0] = pws[gid].i[12];
806   w3[1] = pws[gid].i[13];
807   w3[2] = 0;
808   w3[3] = 0;
809
810   const u32 pw_len = pws[gid].pw_len;
811
812   /**
813    * main
814    */
815
816   __local RC4_KEY rc4_keys[64];
817
818   m10400s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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, pdf_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);
819 }