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