Converted _a3 kernels, use SIMD for CPU and GPU
[hashcat.git] / OpenCL / m03800_a0.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 3
13 #define DGST_R2 2
14 #define DGST_R3 1
15
16 #include "include/kernel_functions.c"
17 #include "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19 #include "include/rp_kernel.h"
20 #include "OpenCL/rp.c"
21
22 #define COMPARE_S "OpenCL/check_single_comp4.c"
23 #define COMPARE_M "OpenCL/check_multi_comp4.c"
24
25 __kernel void m03800_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 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
26 {
27   /**
28    * modifier
29    */
30
31   const u32 gid = get_global_id (0);
32   const u32 lid = get_local_id (0);
33   const u32 lsz = get_local_size (0);
34
35   /**
36    * base
37    */
38
39   u32 pw_buf0[4];
40
41   pw_buf0[0] = pws[gid].i[ 0];
42   pw_buf0[1] = pws[gid].i[ 1];
43   pw_buf0[2] = pws[gid].i[ 2];
44   pw_buf0[3] = pws[gid].i[ 3];
45
46   u32 pw_buf1[4];
47
48   pw_buf1[0] = pws[gid].i[ 4];
49   pw_buf1[1] = pws[gid].i[ 5];
50   pw_buf1[2] = pws[gid].i[ 6];
51   pw_buf1[3] = pws[gid].i[ 7];
52
53   const u32 pw_len = pws[gid].pw_len;
54
55   /**
56    * salt
57    */
58
59   u32 salt_buf0[4];
60
61   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
62   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
63   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
64   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
65
66   u32 salt_buf1[4];
67
68   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
69   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
70   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
71   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
72
73   u32 salt_buf2[4];
74
75   salt_buf2[0] = 0;
76   salt_buf2[1] = 0;
77   salt_buf2[2] = 0;
78   salt_buf2[3] = 0;
79
80   u32 salt_buf3[4];
81
82   salt_buf3[0] = 0;
83   salt_buf3[1] = 0;
84   salt_buf3[2] = 0;
85   salt_buf3[3] = 0;
86
87   const u32 salt_len = salt_bufs[salt_pos].salt_len;
88
89   /**
90    * loop
91    */
92
93   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
94   {
95     u32 w0[4];
96
97     w0[0] = pw_buf0[0];
98     w0[1] = pw_buf0[1];
99     w0[2] = pw_buf0[2];
100     w0[3] = pw_buf0[3];
101
102     u32 w1[4];
103
104     w1[0] = pw_buf1[0];
105     w1[1] = pw_buf1[1];
106     w1[2] = pw_buf1[2];
107     w1[3] = pw_buf1[3];
108
109     u32 w2[4];
110
111     w2[0] = 0;
112     w2[1] = 0;
113     w2[2] = 0;
114     w2[3] = 0;
115
116     u32 w3[4];
117
118     w3[0] = 0;
119     w3[1] = 0;
120     w3[2] = 0;
121     w3[3] = 0;
122
123     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
124
125     u32 w0_t[4];
126
127     w0_t[0] = w0[0];
128     w0_t[1] = w0[1];
129     w0_t[2] = w0[2];
130     w0_t[3] = w0[3];
131
132     u32 w1_t[4];
133
134     w1_t[0] = w1[0];
135     w1_t[1] = w1[1];
136     w1_t[2] = w1[2];
137     w1_t[3] = w1[3];
138
139     u32 w2_t[4];
140
141     w2_t[0] = w2[0];
142     w2_t[1] = w2[1];
143     w2_t[2] = w2[2];
144     w2_t[3] = w2[3];
145
146     u32 w3_t[4];
147
148     w3_t[0] = w3[0];
149     w3_t[1] = w3[1];
150     w3_t[2] = w3[2];
151     w3_t[3] = w3[3];
152
153
154     /**
155      * prepend salt
156      */
157
158     switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, salt_len);
159
160     w0_t[0] |= salt_buf0[0];
161     w0_t[1] |= salt_buf0[1];
162     w0_t[2] |= salt_buf0[2];
163     w0_t[3] |= salt_buf0[3];
164     w1_t[0] |= salt_buf1[0];
165     w1_t[1] |= salt_buf1[1];
166     w1_t[2] |= salt_buf1[2];
167     w1_t[3] |= salt_buf1[3];
168     w2_t[0] |= salt_buf2[0];
169     w2_t[1] |= salt_buf2[1];
170     w2_t[2] |= salt_buf2[2];
171     w2_t[3] |= salt_buf2[3];
172     w3_t[0] |= salt_buf3[0];
173     w3_t[1] |= salt_buf3[1];
174     w3_t[2] |= salt_buf3[2];
175     w3_t[3] |= salt_buf3[3];
176
177     /**
178      * append salt
179      */
180
181     u32 s0[4];
182
183     s0[0] = salt_buf0[0];
184     s0[1] = salt_buf0[1];
185     s0[2] = salt_buf0[2];
186     s0[3] = salt_buf0[3];
187
188     u32 s1[4];
189
190     s1[0] = salt_buf1[0];
191     s1[1] = salt_buf1[1];
192     s1[2] = salt_buf1[2];
193     s1[3] = salt_buf1[3];
194
195     u32 s2[4];
196
197     s2[0] = 0;
198     s2[1] = 0;
199     s2[2] = 0;
200     s2[3] = 0;
201
202     u32 s3[4];
203
204     s3[0] = 0;
205     s3[1] = 0;
206     s3[2] = 0;
207     s3[3] = 0;
208
209     switch_buffer_by_offset_le (s0, s1, s2, s3, salt_len + out_len);
210
211     w0_t[0] |= s0[0];
212     w0_t[1] |= s0[1];
213     w0_t[2] |= s0[2];
214     w0_t[3] |= s0[3];
215     w1_t[0] |= s1[0];
216     w1_t[1] |= s1[1];
217     w1_t[2] |= s1[2];
218     w1_t[3] |= s1[3];
219     w2_t[0] |= s2[0];
220     w2_t[1] |= s2[1];
221     w2_t[2] |= s2[2];
222     w2_t[3] |= s2[3];
223     w3_t[0] |= s3[0];
224     w3_t[1] |= s3[1];
225     w3_t[2] |= s3[2];
226     w3_t[3] |= s3[3];
227
228     const u32 pw_salt_len = salt_len + out_len + salt_len;
229
230     append_0x80_4x4 (w0_t, w1_t, w2_t, w3_t, pw_salt_len);
231
232     w3_t[2] = pw_salt_len * 8;
233
234     /**
235      * md5
236      */
237
238     u32 a = MD5M_A;
239     u32 b = MD5M_B;
240     u32 c = MD5M_C;
241     u32 d = MD5M_D;
242
243     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
244     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
245     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
246     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
247     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
248     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
249     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
250     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
251     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
252     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
253     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
254     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
255     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
256     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
257     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
258     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
259
260     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
261     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
262     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
263     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
264     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
265     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
266     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
267     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
268     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
269     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
270     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
271     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
272     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
273     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
274     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
275     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
276
277     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
278     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
279     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
280     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
281     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
282     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
283     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
284     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
285     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
286     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
287     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
288     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
289     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
290     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
291     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
292     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
293
294     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
295     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
296     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
297     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
298     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
299     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
300     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
301     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
302     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
303     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
304     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
305     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
306     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
307
308     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
309     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
310     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
311
312     const u32 r0 = a;
313     const u32 r1 = d;
314     const u32 r2 = c;
315     const u32 r3 = b;
316
317     #include COMPARE_M
318   }
319 }
320
321 __kernel void m03800_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 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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
322 {
323 }
324
325 __kernel void m03800_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 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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
326 {
327 }
328
329 __kernel void m03800_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 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
330 {
331   /**
332    * modifier
333    */
334
335   const u32 gid = get_global_id (0);
336   const u32 lid = get_local_id (0);
337   const u32 lsz = get_local_size (0);
338
339   /**
340    * base
341    */
342
343   u32 pw_buf0[4];
344
345   pw_buf0[0] = pws[gid].i[ 0];
346   pw_buf0[1] = pws[gid].i[ 1];
347   pw_buf0[2] = pws[gid].i[ 2];
348   pw_buf0[3] = pws[gid].i[ 3];
349
350   u32 pw_buf1[4];
351
352   pw_buf1[0] = pws[gid].i[ 4];
353   pw_buf1[1] = pws[gid].i[ 5];
354   pw_buf1[2] = pws[gid].i[ 6];
355   pw_buf1[3] = pws[gid].i[ 7];
356
357   const u32 pw_len = pws[gid].pw_len;
358
359   /**
360    * salt
361    */
362
363   u32 salt_buf0[4];
364
365   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
366   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
367   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
368   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
369
370   u32 salt_buf1[4];
371
372   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
373   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
374   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
375   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
376
377   u32 salt_buf2[4];
378
379   salt_buf2[0] = 0;
380   salt_buf2[1] = 0;
381   salt_buf2[2] = 0;
382   salt_buf2[3] = 0;
383
384   u32 salt_buf3[4];
385
386   salt_buf3[0] = 0;
387   salt_buf3[1] = 0;
388   salt_buf3[2] = 0;
389   salt_buf3[3] = 0;
390
391   const u32 salt_len = salt_bufs[salt_pos].salt_len;
392
393   /**
394    * digest
395    */
396
397   const u32 search[4] =
398   {
399     digests_buf[digests_offset].digest_buf[DGST_R0],
400     digests_buf[digests_offset].digest_buf[DGST_R1],
401     digests_buf[digests_offset].digest_buf[DGST_R2],
402     digests_buf[digests_offset].digest_buf[DGST_R3]
403   };
404
405   /**
406    * loop
407    */
408
409   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
410   {
411     u32 w0[4];
412
413     w0[0] = pw_buf0[0];
414     w0[1] = pw_buf0[1];
415     w0[2] = pw_buf0[2];
416     w0[3] = pw_buf0[3];
417
418     u32 w1[4];
419
420     w1[0] = pw_buf1[0];
421     w1[1] = pw_buf1[1];
422     w1[2] = pw_buf1[2];
423     w1[3] = pw_buf1[3];
424
425     u32 w2[4];
426
427     w2[0] = 0;
428     w2[1] = 0;
429     w2[2] = 0;
430     w2[3] = 0;
431
432     u32 w3[4];
433
434     w3[0] = 0;
435     w3[1] = 0;
436     w3[2] = 0;
437     w3[3] = 0;
438
439     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
440
441     u32 w0_t[4];
442
443     w0_t[0] = w0[0];
444     w0_t[1] = w0[1];
445     w0_t[2] = w0[2];
446     w0_t[3] = w0[3];
447
448     u32 w1_t[4];
449
450     w1_t[0] = w1[0];
451     w1_t[1] = w1[1];
452     w1_t[2] = w1[2];
453     w1_t[3] = w1[3];
454
455     u32 w2_t[4];
456
457     w2_t[0] = w2[0];
458     w2_t[1] = w2[1];
459     w2_t[2] = w2[2];
460     w2_t[3] = w2[3];
461
462     u32 w3_t[4];
463
464     w3_t[0] = w3[0];
465     w3_t[1] = w3[1];
466     w3_t[2] = w3[2];
467     w3_t[3] = w3[3];
468
469
470     /**
471      * prepend salt
472      */
473
474     switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, salt_len);
475
476     w0_t[0] |= salt_buf0[0];
477     w0_t[1] |= salt_buf0[1];
478     w0_t[2] |= salt_buf0[2];
479     w0_t[3] |= salt_buf0[3];
480     w1_t[0] |= salt_buf1[0];
481     w1_t[1] |= salt_buf1[1];
482     w1_t[2] |= salt_buf1[2];
483     w1_t[3] |= salt_buf1[3];
484     w2_t[0] |= salt_buf2[0];
485     w2_t[1] |= salt_buf2[1];
486     w2_t[2] |= salt_buf2[2];
487     w2_t[3] |= salt_buf2[3];
488     w3_t[0] |= salt_buf3[0];
489     w3_t[1] |= salt_buf3[1];
490     w3_t[2] |= salt_buf3[2];
491     w3_t[3] |= salt_buf3[3];
492
493     /**
494      * append salt
495      */
496
497     u32 s0[4];
498
499     s0[0] = salt_buf0[0];
500     s0[1] = salt_buf0[1];
501     s0[2] = salt_buf0[2];
502     s0[3] = salt_buf0[3];
503
504     u32 s1[4];
505
506     s1[0] = salt_buf1[0];
507     s1[1] = salt_buf1[1];
508     s1[2] = salt_buf1[2];
509     s1[3] = salt_buf1[3];
510
511     u32 s2[4];
512
513     s2[0] = 0;
514     s2[1] = 0;
515     s2[2] = 0;
516     s2[3] = 0;
517
518     u32 s3[4];
519
520     s3[0] = 0;
521     s3[1] = 0;
522     s3[2] = 0;
523     s3[3] = 0;
524
525     switch_buffer_by_offset_le (s0, s1, s2, s3, salt_len + out_len);
526
527     w0_t[0] |= s0[0];
528     w0_t[1] |= s0[1];
529     w0_t[2] |= s0[2];
530     w0_t[3] |= s0[3];
531     w1_t[0] |= s1[0];
532     w1_t[1] |= s1[1];
533     w1_t[2] |= s1[2];
534     w1_t[3] |= s1[3];
535     w2_t[0] |= s2[0];
536     w2_t[1] |= s2[1];
537     w2_t[2] |= s2[2];
538     w2_t[3] |= s2[3];
539     w3_t[0] |= s3[0];
540     w3_t[1] |= s3[1];
541     w3_t[2] |= s3[2];
542     w3_t[3] |= s3[3];
543
544     const u32 pw_salt_len = salt_len + out_len + salt_len;
545
546     append_0x80_4x4 (w0_t, w1_t, w2_t, w3_t, pw_salt_len);
547
548     w3_t[2] = pw_salt_len * 8;
549
550     /**
551      * md5
552      */
553
554     u32 a = MD5M_A;
555     u32 b = MD5M_B;
556     u32 c = MD5M_C;
557     u32 d = MD5M_D;
558
559     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
560     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
561     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
562     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
563     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
564     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
565     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
566     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
567     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
568     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
569     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
570     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
571     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
572     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
573     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
574     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
575
576     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
577     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
578     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
579     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
580     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
581     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
582     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
583     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
584     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
585     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
586     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
587     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
588     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
589     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
590     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
591     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
592
593     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
594     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
595     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
596     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
597     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
598     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
599     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
600     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
601     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
602     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
603     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
604     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
605     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
606     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
607     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
608     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
609
610     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
611     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
612     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
613     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
614     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
615     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
616     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
617     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
618     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
619     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
620     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
621     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
622     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
623     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
624     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
625     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
626
627     const u32 r0 = a;
628     const u32 r1 = d;
629     const u32 r2 = c;
630     const u32 r3 = b;
631
632     #include COMPARE_S
633   }
634 }
635
636 __kernel void m03800_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 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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
637 {
638 }
639
640 __kernel void m03800_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 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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
641 {
642 }