Fix path to includes
[hashcat.git] / OpenCL / m02810_a1.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
20 #define COMPARE_S "OpenCL/check_single_comp4.c"
21 #define COMPARE_M "OpenCL/check_multi_comp4.c"
22
23 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
24
25 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m02810_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 combs_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 wordl0[4];
40
41   wordl0[0] = pws[gid].i[ 0];
42   wordl0[1] = pws[gid].i[ 1];
43   wordl0[2] = pws[gid].i[ 2];
44   wordl0[3] = pws[gid].i[ 3];
45
46   u32 wordl1[4];
47
48   wordl1[0] = pws[gid].i[ 4];
49   wordl1[1] = pws[gid].i[ 5];
50   wordl1[2] = pws[gid].i[ 6];
51   wordl1[3] = pws[gid].i[ 7];
52
53   u32 wordl2[4];
54
55   wordl2[0] = 0;
56   wordl2[1] = 0;
57   wordl2[2] = 0;
58   wordl2[3] = 0;
59
60   u32 wordl3[4];
61
62   wordl3[0] = 0;
63   wordl3[1] = 0;
64   wordl3[2] = 0;
65   wordl3[3] = 0;
66
67   const u32 pw_l_len = pws[gid].pw_len;
68
69   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
70   {
71     append_0x80_2x4 (wordl0, wordl1, pw_l_len);
72
73     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
74   }
75
76   /**
77    * salt
78    */
79
80   u32 s[8];
81
82   s[0] = salt_bufs[salt_pos].salt_buf_pc[0];
83   s[1] = salt_bufs[salt_pos].salt_buf_pc[1];
84   s[2] = salt_bufs[salt_pos].salt_buf_pc[2];
85   s[3] = salt_bufs[salt_pos].salt_buf_pc[3];
86   s[4] = salt_bufs[salt_pos].salt_buf_pc[4];
87   s[5] = salt_bufs[salt_pos].salt_buf_pc[5];
88   s[6] = salt_bufs[salt_pos].salt_buf_pc[6];
89   s[7] = salt_bufs[salt_pos].salt_buf_pc[7];
90
91   const u32 r_00 = 0x80;
92   const u32 r_14 = 64 * 8;
93
94   /**
95    * bin2asc table
96    */
97
98   __local u32 l_bin2asc[256];
99
100   const u32 lid4 = lid * 4;
101
102   const u32 lid40 = lid4 + 0;
103   const u32 lid41 = lid4 + 1;
104   const u32 lid42 = lid4 + 2;
105   const u32 lid43 = lid4 + 3;
106
107   const u32 v400 = (lid40 >> 0) & 15;
108   const u32 v401 = (lid40 >> 4) & 15;
109   const u32 v410 = (lid41 >> 0) & 15;
110   const u32 v411 = (lid41 >> 4) & 15;
111   const u32 v420 = (lid42 >> 0) & 15;
112   const u32 v421 = (lid42 >> 4) & 15;
113   const u32 v430 = (lid43 >> 0) & 15;
114   const u32 v431 = (lid43 >> 4) & 15;
115
116   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
117                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
118   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
119                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
120   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
121                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
122   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
123                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
124
125   barrier (CLK_LOCAL_MEM_FENCE);
126
127   if (gid >= gid_max) return;
128
129   /**
130    * loop
131    */
132
133   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
134   {
135     const u32 pw_r_len = combs_buf[il_pos].pw_len;
136
137     const u32 pw_len = pw_l_len + pw_r_len;
138
139     u32 wordr0[4];
140
141     wordr0[0] = combs_buf[il_pos].i[0];
142     wordr0[1] = combs_buf[il_pos].i[1];
143     wordr0[2] = combs_buf[il_pos].i[2];
144     wordr0[3] = combs_buf[il_pos].i[3];
145
146     u32 wordr1[4];
147
148     wordr1[0] = combs_buf[il_pos].i[4];
149     wordr1[1] = combs_buf[il_pos].i[5];
150     wordr1[2] = combs_buf[il_pos].i[6];
151     wordr1[3] = combs_buf[il_pos].i[7];
152
153     u32 wordr2[4];
154
155     wordr2[0] = 0;
156     wordr2[1] = 0;
157     wordr2[2] = 0;
158     wordr2[3] = 0;
159
160     u32 wordr3[4];
161
162     wordr3[0] = 0;
163     wordr3[1] = 0;
164     wordr3[2] = 0;
165     wordr3[3] = 0;
166
167     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
168     {
169       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
170     }
171
172     u32 w0[4];
173
174     w0[0] = wordl0[0] | wordr0[0];
175     w0[1] = wordl0[1] | wordr0[1];
176     w0[2] = wordl0[2] | wordr0[2];
177     w0[3] = wordl0[3] | wordr0[3];
178
179     u32 w1[4];
180
181     w1[0] = wordl1[0] | wordr1[0];
182     w1[1] = wordl1[1] | wordr1[1];
183     w1[2] = wordl1[2] | wordr1[2];
184     w1[3] = wordl1[3] | wordr1[3];
185
186     u32 w2[4];
187
188     w2[0] = wordl2[0] | wordr2[0];
189     w2[1] = wordl2[1] | wordr2[1];
190     w2[2] = wordl2[2] | wordr2[2];
191     w2[3] = wordl2[3] | wordr2[3];
192
193     u32 w3[4];
194
195     w3[0] = wordl3[0] | wordr3[0];
196     w3[1] = wordl3[1] | wordr3[1];
197     w3[2] = pw_len * 8;
198     w3[3] = 0;
199
200     u32 a = MD5M_A;
201     u32 b = MD5M_B;
202     u32 c = MD5M_C;
203     u32 d = MD5M_D;
204
205     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
206     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
207     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
208     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
209     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
210     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
211     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
212     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
213     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
214     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
215     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
216     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
217     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
218     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
219     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
220     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
221
222     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
223     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
224     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
225     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
226     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
227     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
228     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
229     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
230     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
231     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
232     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
233     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
234     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
235     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
236     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
237     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
238
239     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
240     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
241     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
242     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
243     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
244     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
245     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
246     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
247     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
248     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
249     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
250     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
251     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
252     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
253     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
254     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
255
256     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
257     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
258     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
259     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
260     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
261     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
262     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
263     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
264     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
265     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
266     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
267     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
268     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
269     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
270     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
271     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
272
273     a += MD5M_A;
274     b += MD5M_B;
275     c += MD5M_C;
276     d += MD5M_D;
277
278     const u32  w0_t = s[0];
279     const u32  w1_t = s[1];
280     const u32  w2_t = s[2];
281     const u32  w3_t = s[3];
282     const u32  w4_t = s[4];
283     const u32  w5_t = s[5];
284     const u32  w6_t = s[6];
285     const u32  w7_t = s[7];
286
287     const u32 w8_t = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
288                      | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
289     const u32 w9_t = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
290                      | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
291     const u32 wa_t = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
292                      | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
293     const u32 wb_t = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
294                      | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
295     const u32 wc_t = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
296                      | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
297     const u32 wd_t = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
298                      | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
299     const u32 we_t = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
300                      | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
301     const u32 wf_t = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
302                      | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
303
304     a = MD5M_A;
305     b = MD5M_B;
306     c = MD5M_C;
307     d = MD5M_D;
308
309     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
310     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
311     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
312     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
313     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
314     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
315     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
316     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
317     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
318     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
319     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
320     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
321     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
322     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
323     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
324     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
325
326     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
327     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
328     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
329     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
330     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
331     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
332     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
333     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
334     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
335     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
336     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
337     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
338     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
339     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
340     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
341     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
342
343     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
344     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
345     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
346     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
347     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
348     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
349     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
350     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
351     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
352     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
353     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
354     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
355     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
356     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
357     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
358     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
359
360     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
361     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
362     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
363     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
364     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
365     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
366     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
367     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
368     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
369     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
370     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
371     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
372     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
373     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
374     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
375     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
376
377     const u32 r_a = a + MD5M_A;
378     const u32 r_b = b + MD5M_B;
379     const u32 r_c = c + MD5M_C;
380     const u32 r_d = d + MD5M_D;
381
382     a = r_a;
383     b = r_b;
384     c = r_c;
385     d = r_d;
386
387     MD5_STEP (MD5_Fo, a, b, c, d, r_00, MD5C00, MD5S00);
388     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C01, MD5S01);
389     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C02, MD5S02);
390     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C03, MD5S03);
391     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C04, MD5S00);
392     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C05, MD5S01);
393     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C06, MD5S02);
394     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C07, MD5S03);
395     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C08, MD5S00);
396     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C09, MD5S01);
397     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C0a, MD5S02);
398     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0b, MD5S03);
399     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C0c, MD5S00);
400     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C0d, MD5S01);
401     MD5_STEP (MD5_Fo, c, d, a, b, r_14, MD5C0e, MD5S02);
402     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0f, MD5S03);
403
404     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C10, MD5S10);
405     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C11, MD5S11);
406     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C12, MD5S12);
407     MD5_STEP (MD5_Go, b, c, d, a, r_00, MD5C13, MD5S13);
408     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C14, MD5S10);
409     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C15, MD5S11);
410     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C16, MD5S12);
411     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C17, MD5S13);
412     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C18, MD5S10);
413     MD5_STEP (MD5_Go, d, a, b, c, r_14, MD5C19, MD5S11);
414     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1a, MD5S12);
415     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1b, MD5S13);
416     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C1c, MD5S10);
417     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C1d, MD5S11);
418     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1e, MD5S12);
419     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1f, MD5S13);
420
421     MD5_STEP0(MD5_H , a, b, c, d,       MD5C20, MD5S20);
422     MD5_STEP0(MD5_H , d, a, b, c,       MD5C21, MD5S21);
423     MD5_STEP0(MD5_H , c, d, a, b,       MD5C22, MD5S22);
424     MD5_STEP (MD5_H , b, c, d, a, r_14, MD5C23, MD5S23);
425     MD5_STEP0(MD5_H , a, b, c, d,       MD5C24, MD5S20);
426     MD5_STEP0(MD5_H , d, a, b, c,       MD5C25, MD5S21);
427     MD5_STEP0(MD5_H , c, d, a, b,       MD5C26, MD5S22);
428     MD5_STEP0(MD5_H , b, c, d, a,       MD5C27, MD5S23);
429     MD5_STEP0(MD5_H , a, b, c, d,       MD5C28, MD5S20);
430     MD5_STEP (MD5_H , d, a, b, c, r_00, MD5C29, MD5S21);
431     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2a, MD5S22);
432     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2b, MD5S23);
433     MD5_STEP0(MD5_H , a, b, c, d,       MD5C2c, MD5S20);
434     MD5_STEP0(MD5_H , d, a, b, c,       MD5C2d, MD5S21);
435     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2e, MD5S22);
436     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2f, MD5S23);
437
438     MD5_STEP (MD5_I , a, b, c, d, r_00, MD5C30, MD5S30);
439     MD5_STEP0(MD5_I , d, a, b, c,       MD5C31, MD5S31);
440     MD5_STEP (MD5_I , c, d, a, b, r_14, MD5C32, MD5S32);
441     MD5_STEP0(MD5_I , b, c, d, a,       MD5C33, MD5S33);
442     MD5_STEP0(MD5_I , a, b, c, d,       MD5C34, MD5S30);
443     MD5_STEP0(MD5_I , d, a, b, c,       MD5C35, MD5S31);
444     MD5_STEP0(MD5_I , c, d, a, b,       MD5C36, MD5S32);
445     MD5_STEP0(MD5_I , b, c, d, a,       MD5C37, MD5S33);
446     MD5_STEP0(MD5_I , a, b, c, d,       MD5C38, MD5S30);
447     MD5_STEP0(MD5_I , d, a, b, c,       MD5C39, MD5S31);
448     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3a, MD5S32);
449     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3b, MD5S33);
450     MD5_STEP0(MD5_I , a, b, c, d,       MD5C3c, MD5S30);
451     MD5_STEP0(MD5_I , d, a, b, c,       MD5C3d, MD5S31);
452     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3e, MD5S32);
453     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3f, MD5S33);
454
455     a += r_a;
456     b += r_b;
457     c += r_c;
458     d += r_d;
459
460     const u32 r0 = a;
461     const u32 r1 = d;
462     const u32 r2 = c;
463     const u32 r3 = b;
464
465     #include COMPARE_M
466   }
467 }
468
469 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m02810_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)
470 {
471 }
472
473 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m02810_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)
474 {
475 }
476
477 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m02810_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
478 {
479   /**
480    * modifier
481    */
482
483   const u32 lid = get_local_id (0);
484
485   /**
486    * base
487    */
488
489   const u32 gid = get_global_id (0);
490
491   u32 wordl0[4];
492
493   wordl0[0] = pws[gid].i[ 0];
494   wordl0[1] = pws[gid].i[ 1];
495   wordl0[2] = pws[gid].i[ 2];
496   wordl0[3] = pws[gid].i[ 3];
497
498   u32 wordl1[4];
499
500   wordl1[0] = pws[gid].i[ 4];
501   wordl1[1] = pws[gid].i[ 5];
502   wordl1[2] = pws[gid].i[ 6];
503   wordl1[3] = pws[gid].i[ 7];
504
505   u32 wordl2[4];
506
507   wordl2[0] = 0;
508   wordl2[1] = 0;
509   wordl2[2] = 0;
510   wordl2[3] = 0;
511
512   u32 wordl3[4];
513
514   wordl3[0] = 0;
515   wordl3[1] = 0;
516   wordl3[2] = 0;
517   wordl3[3] = 0;
518
519   const u32 pw_l_len = pws[gid].pw_len;
520
521   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
522   {
523     append_0x80_2x4 (wordl0, wordl1, pw_l_len);
524
525     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
526   }
527
528   /**
529    * salt
530    */
531
532   u32 s[8];
533
534   s[0] = salt_bufs[salt_pos].salt_buf_pc[0];
535   s[1] = salt_bufs[salt_pos].salt_buf_pc[1];
536   s[2] = salt_bufs[salt_pos].salt_buf_pc[2];
537   s[3] = salt_bufs[salt_pos].salt_buf_pc[3];
538   s[4] = salt_bufs[salt_pos].salt_buf_pc[4];
539   s[5] = salt_bufs[salt_pos].salt_buf_pc[5];
540   s[6] = salt_bufs[salt_pos].salt_buf_pc[6];
541   s[7] = salt_bufs[salt_pos].salt_buf_pc[7];
542
543   const u32 r_00 = 0x80;
544   const u32 r_14 = 64 * 8;
545
546   /**
547    * digest
548    */
549
550   const u32 search[4] =
551   {
552     digests_buf[digests_offset].digest_buf[DGST_R0],
553     digests_buf[digests_offset].digest_buf[DGST_R1],
554     digests_buf[digests_offset].digest_buf[DGST_R2],
555     digests_buf[digests_offset].digest_buf[DGST_R3]
556   };
557
558   /**
559    * bin2asc table
560    */
561
562   __local u32 l_bin2asc[256];
563
564   const u32 lid4 = lid * 4;
565
566   const u32 lid40 = lid4 + 0;
567   const u32 lid41 = lid4 + 1;
568   const u32 lid42 = lid4 + 2;
569   const u32 lid43 = lid4 + 3;
570
571   const u32 v400 = (lid40 >> 0) & 15;
572   const u32 v401 = (lid40 >> 4) & 15;
573   const u32 v410 = (lid41 >> 0) & 15;
574   const u32 v411 = (lid41 >> 4) & 15;
575   const u32 v420 = (lid42 >> 0) & 15;
576   const u32 v421 = (lid42 >> 4) & 15;
577   const u32 v430 = (lid43 >> 0) & 15;
578   const u32 v431 = (lid43 >> 4) & 15;
579
580   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
581                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
582   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
583                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
584   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
585                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
586   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
587                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
588
589   barrier (CLK_LOCAL_MEM_FENCE);
590
591   if (gid >= gid_max) return;
592
593   /**
594    * loop
595    */
596
597   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
598   {
599     const u32 pw_r_len = combs_buf[il_pos].pw_len;
600
601     const u32 pw_len = pw_l_len + pw_r_len;
602
603     u32 wordr0[4];
604
605     wordr0[0] = combs_buf[il_pos].i[0];
606     wordr0[1] = combs_buf[il_pos].i[1];
607     wordr0[2] = combs_buf[il_pos].i[2];
608     wordr0[3] = combs_buf[il_pos].i[3];
609
610     u32 wordr1[4];
611
612     wordr1[0] = combs_buf[il_pos].i[4];
613     wordr1[1] = combs_buf[il_pos].i[5];
614     wordr1[2] = combs_buf[il_pos].i[6];
615     wordr1[3] = combs_buf[il_pos].i[7];
616
617     u32 wordr2[4];
618
619     wordr2[0] = 0;
620     wordr2[1] = 0;
621     wordr2[2] = 0;
622     wordr2[3] = 0;
623
624     u32 wordr3[4];
625
626     wordr3[0] = 0;
627     wordr3[1] = 0;
628     wordr3[2] = 0;
629     wordr3[3] = 0;
630
631     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
632     {
633       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
634     }
635
636     u32 w0[4];
637
638     w0[0] = wordl0[0] | wordr0[0];
639     w0[1] = wordl0[1] | wordr0[1];
640     w0[2] = wordl0[2] | wordr0[2];
641     w0[3] = wordl0[3] | wordr0[3];
642
643     u32 w1[4];
644
645     w1[0] = wordl1[0] | wordr1[0];
646     w1[1] = wordl1[1] | wordr1[1];
647     w1[2] = wordl1[2] | wordr1[2];
648     w1[3] = wordl1[3] | wordr1[3];
649
650     u32 w2[4];
651
652     w2[0] = wordl2[0] | wordr2[0];
653     w2[1] = wordl2[1] | wordr2[1];
654     w2[2] = wordl2[2] | wordr2[2];
655     w2[3] = wordl2[3] | wordr2[3];
656
657     u32 w3[4];
658
659     w3[0] = wordl3[0] | wordr3[0];
660     w3[1] = wordl3[1] | wordr3[1];
661     w3[2] = pw_len * 8;
662     w3[3] = 0;
663
664     u32 a = MD5M_A;
665     u32 b = MD5M_B;
666     u32 c = MD5M_C;
667     u32 d = MD5M_D;
668
669     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
670     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
671     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
672     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
673     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
674     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
675     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
676     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
677     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
678     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
679     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
680     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
681     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
682     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
683     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
684     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
685
686     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
687     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
688     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
689     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
690     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
691     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
692     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
693     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
694     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
695     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
696     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
697     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
698     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
699     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
700     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
701     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
702
703     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
704     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
705     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
706     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
707     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
708     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
709     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
710     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
711     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
712     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
713     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
714     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
715     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
716     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
717     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
718     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
719
720     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
721     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
722     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
723     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
724     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
725     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
726     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
727     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
728     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
729     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
730     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
731     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
732     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
733     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
734     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
735     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
736
737     a += MD5M_A;
738     b += MD5M_B;
739     c += MD5M_C;
740     d += MD5M_D;
741
742     const u32  w0_t = s[0];
743     const u32  w1_t = s[1];
744     const u32  w2_t = s[2];
745     const u32  w3_t = s[3];
746     const u32  w4_t = s[4];
747     const u32  w5_t = s[5];
748     const u32  w6_t = s[6];
749     const u32  w7_t = s[7];
750
751     const u32 w8_t = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
752                      | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
753     const u32 w9_t = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
754                      | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
755     const u32 wa_t = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
756                      | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
757     const u32 wb_t = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
758                      | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
759     const u32 wc_t = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
760                      | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
761     const u32 wd_t = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
762                      | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
763     const u32 we_t = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
764                      | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
765     const u32 wf_t = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
766                      | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
767
768     a = MD5M_A;
769     b = MD5M_B;
770     c = MD5M_C;
771     d = MD5M_D;
772
773     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
774     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
775     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
776     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
777     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
778     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
779     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
780     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
781     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
782     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
783     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
784     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
785     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
786     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
787     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
788     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
789
790     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
791     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
792     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
793     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
794     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
795     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
796     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
797     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
798     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
799     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
800     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
801     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
802     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
803     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
804     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
805     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
806
807     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
808     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
809     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
810     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
811     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
812     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
813     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
814     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
815     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
816     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
817     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
818     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
819     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
820     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
821     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
822     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
823
824     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
825     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
826     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
827     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
828     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
829     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
830     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
831     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
832     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
833     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
834     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
835     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
836     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
837     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
838     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
839     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
840
841     const u32 r_a = a + MD5M_A;
842     const u32 r_b = b + MD5M_B;
843     const u32 r_c = c + MD5M_C;
844     const u32 r_d = d + MD5M_D;
845
846     a = r_a;
847     b = r_b;
848     c = r_c;
849     d = r_d;
850
851     MD5_STEP (MD5_Fo, a, b, c, d, r_00, MD5C00, MD5S00);
852     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C01, MD5S01);
853     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C02, MD5S02);
854     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C03, MD5S03);
855     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C04, MD5S00);
856     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C05, MD5S01);
857     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C06, MD5S02);
858     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C07, MD5S03);
859     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C08, MD5S00);
860     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C09, MD5S01);
861     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C0a, MD5S02);
862     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0b, MD5S03);
863     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C0c, MD5S00);
864     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C0d, MD5S01);
865     MD5_STEP (MD5_Fo, c, d, a, b, r_14, MD5C0e, MD5S02);
866     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0f, MD5S03);
867
868     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C10, MD5S10);
869     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C11, MD5S11);
870     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C12, MD5S12);
871     MD5_STEP (MD5_Go, b, c, d, a, r_00, MD5C13, MD5S13);
872     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C14, MD5S10);
873     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C15, MD5S11);
874     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C16, MD5S12);
875     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C17, MD5S13);
876     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C18, MD5S10);
877     MD5_STEP (MD5_Go, d, a, b, c, r_14, MD5C19, MD5S11);
878     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1a, MD5S12);
879     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1b, MD5S13);
880     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C1c, MD5S10);
881     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C1d, MD5S11);
882     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1e, MD5S12);
883     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1f, MD5S13);
884
885     MD5_STEP0(MD5_H , a, b, c, d,       MD5C20, MD5S20);
886     MD5_STEP0(MD5_H , d, a, b, c,       MD5C21, MD5S21);
887     MD5_STEP0(MD5_H , c, d, a, b,       MD5C22, MD5S22);
888     MD5_STEP (MD5_H , b, c, d, a, r_14, MD5C23, MD5S23);
889     MD5_STEP0(MD5_H , a, b, c, d,       MD5C24, MD5S20);
890     MD5_STEP0(MD5_H , d, a, b, c,       MD5C25, MD5S21);
891     MD5_STEP0(MD5_H , c, d, a, b,       MD5C26, MD5S22);
892     MD5_STEP0(MD5_H , b, c, d, a,       MD5C27, MD5S23);
893     MD5_STEP0(MD5_H , a, b, c, d,       MD5C28, MD5S20);
894     MD5_STEP (MD5_H , d, a, b, c, r_00, MD5C29, MD5S21);
895     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2a, MD5S22);
896     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2b, MD5S23);
897     MD5_STEP0(MD5_H , a, b, c, d,       MD5C2c, MD5S20);
898     MD5_STEP0(MD5_H , d, a, b, c,       MD5C2d, MD5S21);
899     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2e, MD5S22);
900     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2f, MD5S23);
901
902     MD5_STEP (MD5_I , a, b, c, d, r_00, MD5C30, MD5S30);
903     MD5_STEP0(MD5_I , d, a, b, c,       MD5C31, MD5S31);
904     MD5_STEP (MD5_I , c, d, a, b, r_14, MD5C32, MD5S32);
905     MD5_STEP0(MD5_I , b, c, d, a,       MD5C33, MD5S33);
906     MD5_STEP0(MD5_I , a, b, c, d,       MD5C34, MD5S30);
907     MD5_STEP0(MD5_I , d, a, b, c,       MD5C35, MD5S31);
908     MD5_STEP0(MD5_I , c, d, a, b,       MD5C36, MD5S32);
909     MD5_STEP0(MD5_I , b, c, d, a,       MD5C37, MD5S33);
910     MD5_STEP0(MD5_I , a, b, c, d,       MD5C38, MD5S30);
911     MD5_STEP0(MD5_I , d, a, b, c,       MD5C39, MD5S31);
912     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3a, MD5S32);
913     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3b, MD5S33);
914     MD5_STEP0(MD5_I , a, b, c, d,       MD5C3c, MD5S30);
915
916     if (allx ((a + r_a) != search[0])) continue;
917
918     MD5_STEP0(MD5_I , d, a, b, c,       MD5C3d, MD5S31);
919     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3e, MD5S32);
920     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3f, MD5S33);
921
922     a += r_a;
923     b += r_b;
924     c += r_c;
925     d += r_d;
926
927     const u32 r0 = a;
928     const u32 r1 = d;
929     const u32 r2 = c;
930     const u32 r3 = b;
931
932     #include COMPARE_S
933   }
934 }
935
936 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m02810_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)
937 {
938 }
939
940 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m02810_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)
941 {
942 }