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