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