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