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