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