Merge branch 'master' into GetRidOfCUDA
[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 "types_ocl.c"
18 #include "common.c"
19 #include "include/rp_gpu.h"
20 #include "rp.c"
21
22 #define COMPARE_S "check_single_comp4.c"
23 #define COMPARE_M "check_multi_comp4.c"
24
25 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03800_m04 (__global pw_t *pws, __global gpu_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 lid = get_local_id (0);
32
33   /**
34    * base
35    */
36
37   const u32 gid = get_global_id (0);
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    * bin2asc table
91    */
92
93   __local u32 l_bin2asc[256];
94
95   const u32 lid4 = lid * 4;
96
97   const u32 lid40 = lid4 + 0;
98   const u32 lid41 = lid4 + 1;
99   const u32 lid42 = lid4 + 2;
100   const u32 lid43 = lid4 + 3;
101
102   const u32 v400 = (lid40 >> 0) & 15;
103   const u32 v401 = (lid40 >> 4) & 15;
104   const u32 v410 = (lid41 >> 0) & 15;
105   const u32 v411 = (lid41 >> 4) & 15;
106   const u32 v420 = (lid42 >> 0) & 15;
107   const u32 v421 = (lid42 >> 4) & 15;
108   const u32 v430 = (lid43 >> 0) & 15;
109   const u32 v431 = (lid43 >> 4) & 15;
110
111   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
112                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
113   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
114                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
115   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
116                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
117   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
118                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
119
120   barrier (CLK_LOCAL_MEM_FENCE);
121
122   if (gid >= gid_max) return;
123
124   /**
125    * loop
126    */
127
128   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
129   {
130     u32 w0[4];
131
132     w0[0] = pw_buf0[0];
133     w0[1] = pw_buf0[1];
134     w0[2] = pw_buf0[2];
135     w0[3] = pw_buf0[3];
136
137     u32 w1[4];
138
139     w1[0] = pw_buf1[0];
140     w1[1] = pw_buf1[1];
141     w1[2] = pw_buf1[2];
142     w1[3] = pw_buf1[3];
143
144     u32 w2[4];
145
146     w2[0] = 0;
147     w2[1] = 0;
148     w2[2] = 0;
149     w2[3] = 0;
150
151     u32 w3[4];
152
153     w3[0] = 0;
154     w3[1] = 0;
155     w3[2] = 0;
156     w3[3] = 0;
157
158     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
159
160     u32 w0_t[4];
161
162     w0_t[0] = w0[0];
163     w0_t[1] = w0[1];
164     w0_t[2] = w0[2];
165     w0_t[3] = w0[3];
166
167     u32 w1_t[4];
168
169     w1_t[0] = w1[0];
170     w1_t[1] = w1[1];
171     w1_t[2] = w1[2];
172     w1_t[3] = w1[3];
173
174     u32 w2_t[4];
175
176     w2_t[0] = w2[0];
177     w2_t[1] = w2[1];
178     w2_t[2] = w2[2];
179     w2_t[3] = w2[3];
180
181     u32 w3_t[4];
182
183     w3_t[0] = w3[0];
184     w3_t[1] = w3[1];
185     w3_t[2] = w3[2];
186     w3_t[3] = w3[3];
187
188
189     /**
190      * prepend salt
191      */
192
193     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
194
195     w0_t[0] |= salt_buf0[0];
196     w0_t[1] |= salt_buf0[1];
197     w0_t[2] |= salt_buf0[2];
198     w0_t[3] |= salt_buf0[3];
199     w1_t[0] |= salt_buf1[0];
200     w1_t[1] |= salt_buf1[1];
201     w1_t[2] |= salt_buf1[2];
202     w1_t[3] |= salt_buf1[3];
203     w2_t[0] |= salt_buf2[0];
204     w2_t[1] |= salt_buf2[1];
205     w2_t[2] |= salt_buf2[2];
206     w2_t[3] |= salt_buf2[3];
207     w3_t[0] |= salt_buf3[0];
208     w3_t[1] |= salt_buf3[1];
209     w3_t[2] |= salt_buf3[2];
210     w3_t[3] |= salt_buf3[3];
211
212     /**
213      * append salt
214      */
215
216     u32 s0[4];
217
218     s0[0] = salt_buf0[0];
219     s0[1] = salt_buf0[1];
220     s0[2] = salt_buf0[2];
221     s0[3] = salt_buf0[3];
222
223     u32 s1[4];
224
225     s1[0] = salt_buf1[0];
226     s1[1] = salt_buf1[1];
227     s1[2] = salt_buf1[2];
228     s1[3] = salt_buf1[3];
229
230     u32 s2[4];
231
232     s2[0] = 0;
233     s2[1] = 0;
234     s2[2] = 0;
235     s2[3] = 0;
236
237     u32 s3[4];
238
239     s3[0] = 0;
240     s3[1] = 0;
241     s3[2] = 0;
242     s3[3] = 0;
243
244     switch_buffer_by_offset (s0, s1, s2, s3, salt_len + out_len);
245
246     w0_t[0] |= s0[0];
247     w0_t[1] |= s0[1];
248     w0_t[2] |= s0[2];
249     w0_t[3] |= s0[3];
250     w1_t[0] |= s1[0];
251     w1_t[1] |= s1[1];
252     w1_t[2] |= s1[2];
253     w1_t[3] |= s1[3];
254     w2_t[0] |= s2[0];
255     w2_t[1] |= s2[1];
256     w2_t[2] |= s2[2];
257     w2_t[3] |= s2[3];
258     w3_t[0] |= s3[0];
259     w3_t[1] |= s3[1];
260     w3_t[2] |= s3[2];
261     w3_t[3] |= s3[3];
262
263     const u32 pw_salt_len = salt_len + out_len + salt_len;
264
265     append_0x80_4x4 (w0_t, w1_t, w2_t, w3_t, pw_salt_len);
266
267     w3_t[2] = pw_salt_len * 8;
268
269     /**
270      * md5
271      */
272
273     u32 a = MD5M_A;
274     u32 b = MD5M_B;
275     u32 c = MD5M_C;
276     u32 d = MD5M_D;
277
278     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
279     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
280     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
281     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
282     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
283     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
284     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
285     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
286     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
287     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
288     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
289     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
290     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
291     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
292     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
293     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
294
295     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
296     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
297     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
298     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
299     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
300     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
301     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
302     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
303     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
304     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
305     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
306     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
307     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
308     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
309     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
310     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
311
312     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
313     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
314     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
315     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
316     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
317     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
318     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
319     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
320     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
321     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
322     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
323     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
324     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
325     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
326     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
327     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
328
329     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
330     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
331     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
332     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
333     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
334     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
335     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
336     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
337     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
338     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
339     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
340     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
341     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
342
343     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
344     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
345     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
346
347     const u32 r0 = a;
348     const u32 r1 = d;
349     const u32 r2 = c;
350     const u32 r3 = b;
351
352     #include COMPARE_M
353   }
354 }
355
356 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03800_m08 (__global pw_t *pws, __global gpu_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)
357 {
358 }
359
360 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03800_m16 (__global pw_t *pws, __global gpu_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)
361 {
362 }
363
364 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03800_s04 (__global pw_t *pws, __global gpu_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)
365 {
366   /**
367    * modifier
368    */
369
370   const u32 lid = get_local_id (0);
371
372   /**
373    * base
374    */
375
376   const u32 gid = get_global_id (0);
377
378   u32 pw_buf0[4];
379
380   pw_buf0[0] = pws[gid].i[ 0];
381   pw_buf0[1] = pws[gid].i[ 1];
382   pw_buf0[2] = pws[gid].i[ 2];
383   pw_buf0[3] = pws[gid].i[ 3];
384
385   u32 pw_buf1[4];
386
387   pw_buf1[0] = pws[gid].i[ 4];
388   pw_buf1[1] = pws[gid].i[ 5];
389   pw_buf1[2] = pws[gid].i[ 6];
390   pw_buf1[3] = pws[gid].i[ 7];
391
392   const u32 pw_len = pws[gid].pw_len;
393
394   /**
395    * salt
396    */
397
398   u32 salt_buf0[4];
399
400   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
401   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
402   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
403   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
404
405   u32 salt_buf1[4];
406
407   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
408   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
409   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
410   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
411
412   u32 salt_buf2[4];
413
414   salt_buf2[0] = 0;
415   salt_buf2[1] = 0;
416   salt_buf2[2] = 0;
417   salt_buf2[3] = 0;
418
419   u32 salt_buf3[4];
420
421   salt_buf3[0] = 0;
422   salt_buf3[1] = 0;
423   salt_buf3[2] = 0;
424   salt_buf3[3] = 0;
425
426   const u32 salt_len = salt_bufs[salt_pos].salt_len;
427
428   /**
429    * digest
430    */
431
432   const u32 search[4] =
433   {
434     digests_buf[digests_offset].digest_buf[DGST_R0],
435     digests_buf[digests_offset].digest_buf[DGST_R1],
436     digests_buf[digests_offset].digest_buf[DGST_R2],
437     digests_buf[digests_offset].digest_buf[DGST_R3]
438   };
439
440   /**
441    * bin2asc table
442    */
443
444   __local u32 l_bin2asc[256];
445
446   const u32 lid4 = lid * 4;
447
448   const u32 lid40 = lid4 + 0;
449   const u32 lid41 = lid4 + 1;
450   const u32 lid42 = lid4 + 2;
451   const u32 lid43 = lid4 + 3;
452
453   const u32 v400 = (lid40 >> 0) & 15;
454   const u32 v401 = (lid40 >> 4) & 15;
455   const u32 v410 = (lid41 >> 0) & 15;
456   const u32 v411 = (lid41 >> 4) & 15;
457   const u32 v420 = (lid42 >> 0) & 15;
458   const u32 v421 = (lid42 >> 4) & 15;
459   const u32 v430 = (lid43 >> 0) & 15;
460   const u32 v431 = (lid43 >> 4) & 15;
461
462   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
463                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
464   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
465                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
466   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
467                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
468   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
469                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
470
471   barrier (CLK_LOCAL_MEM_FENCE);
472
473   if (gid >= gid_max) return;
474
475   /**
476    * loop
477    */
478
479   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
480   {
481     u32 w0[4];
482
483     w0[0] = pw_buf0[0];
484     w0[1] = pw_buf0[1];
485     w0[2] = pw_buf0[2];
486     w0[3] = pw_buf0[3];
487
488     u32 w1[4];
489
490     w1[0] = pw_buf1[0];
491     w1[1] = pw_buf1[1];
492     w1[2] = pw_buf1[2];
493     w1[3] = pw_buf1[3];
494
495     u32 w2[4];
496
497     w2[0] = 0;
498     w2[1] = 0;
499     w2[2] = 0;
500     w2[3] = 0;
501
502     u32 w3[4];
503
504     w3[0] = 0;
505     w3[1] = 0;
506     w3[2] = 0;
507     w3[3] = 0;
508
509     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
510
511     u32 w0_t[4];
512
513     w0_t[0] = w0[0];
514     w0_t[1] = w0[1];
515     w0_t[2] = w0[2];
516     w0_t[3] = w0[3];
517
518     u32 w1_t[4];
519
520     w1_t[0] = w1[0];
521     w1_t[1] = w1[1];
522     w1_t[2] = w1[2];
523     w1_t[3] = w1[3];
524
525     u32 w2_t[4];
526
527     w2_t[0] = w2[0];
528     w2_t[1] = w2[1];
529     w2_t[2] = w2[2];
530     w2_t[3] = w2[3];
531
532     u32 w3_t[4];
533
534     w3_t[0] = w3[0];
535     w3_t[1] = w3[1];
536     w3_t[2] = w3[2];
537     w3_t[3] = w3[3];
538
539
540     /**
541      * prepend salt
542      */
543
544     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
545
546     w0_t[0] |= salt_buf0[0];
547     w0_t[1] |= salt_buf0[1];
548     w0_t[2] |= salt_buf0[2];
549     w0_t[3] |= salt_buf0[3];
550     w1_t[0] |= salt_buf1[0];
551     w1_t[1] |= salt_buf1[1];
552     w1_t[2] |= salt_buf1[2];
553     w1_t[3] |= salt_buf1[3];
554     w2_t[0] |= salt_buf2[0];
555     w2_t[1] |= salt_buf2[1];
556     w2_t[2] |= salt_buf2[2];
557     w2_t[3] |= salt_buf2[3];
558     w3_t[0] |= salt_buf3[0];
559     w3_t[1] |= salt_buf3[1];
560     w3_t[2] |= salt_buf3[2];
561     w3_t[3] |= salt_buf3[3];
562
563     /**
564      * append salt
565      */
566
567     u32 s0[4];
568
569     s0[0] = salt_buf0[0];
570     s0[1] = salt_buf0[1];
571     s0[2] = salt_buf0[2];
572     s0[3] = salt_buf0[3];
573
574     u32 s1[4];
575
576     s1[0] = salt_buf1[0];
577     s1[1] = salt_buf1[1];
578     s1[2] = salt_buf1[2];
579     s1[3] = salt_buf1[3];
580
581     u32 s2[4];
582
583     s2[0] = 0;
584     s2[1] = 0;
585     s2[2] = 0;
586     s2[3] = 0;
587
588     u32 s3[4];
589
590     s3[0] = 0;
591     s3[1] = 0;
592     s3[2] = 0;
593     s3[3] = 0;
594
595     switch_buffer_by_offset (s0, s1, s2, s3, salt_len + out_len);
596
597     w0_t[0] |= s0[0];
598     w0_t[1] |= s0[1];
599     w0_t[2] |= s0[2];
600     w0_t[3] |= s0[3];
601     w1_t[0] |= s1[0];
602     w1_t[1] |= s1[1];
603     w1_t[2] |= s1[2];
604     w1_t[3] |= s1[3];
605     w2_t[0] |= s2[0];
606     w2_t[1] |= s2[1];
607     w2_t[2] |= s2[2];
608     w2_t[3] |= s2[3];
609     w3_t[0] |= s3[0];
610     w3_t[1] |= s3[1];
611     w3_t[2] |= s3[2];
612     w3_t[3] |= s3[3];
613
614     const u32 pw_salt_len = salt_len + out_len + salt_len;
615
616     append_0x80_4x4 (w0_t, w1_t, w2_t, w3_t, pw_salt_len);
617
618     w3_t[2] = pw_salt_len * 8;
619
620     /**
621      * md5
622      */
623
624     u32 a = MD5M_A;
625     u32 b = MD5M_B;
626     u32 c = MD5M_C;
627     u32 d = MD5M_D;
628
629     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
630     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
631     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
632     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
633     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
634     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
635     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
636     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
637     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
638     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
639     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
640     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
641     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
642     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
643     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
644     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
645
646     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
647     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
648     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
649     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
650     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
651     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
652     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
653     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
654     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
655     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
656     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
657     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
658     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
659     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
660     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
661     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
662
663     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
664     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
665     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
666     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
667     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
668     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
669     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
670     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
671     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
672     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
673     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
674     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
675     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
676     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
677     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
678     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
679
680     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
681     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
682     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
683     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
684     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
685     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
686     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
687     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
688     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
689     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
690     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
691     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
692     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
693     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
694     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
695     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
696
697     const u32 r0 = a;
698     const u32 r1 = d;
699     const u32 r2 = c;
700     const u32 r3 = b;
701
702     #include COMPARE_S
703   }
704 }
705
706 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03800_s08 (__global pw_t *pws, __global gpu_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)
707 {
708 }
709
710 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03800_s16 (__global pw_t *pws, __global gpu_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)
711 {
712 }