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