37a617b333046e162cae4274194f9143a378e7ce
[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 #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 m02710_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[0];
92   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1];
93   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2];
94   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[3];
95   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[4];
96   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[5];
97   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[6];
98   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[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] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
266           | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
267     w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
268           | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
269     w0[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
270           | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
271     w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
272           | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
273     w1[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
274           | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
275     w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
276           | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
277     w1[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
278           | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
279     w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
280           | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
281
282     w2[0] = salt_buf0[0];
283     w2[1] = salt_buf0[1];
284     w2[2] = salt_buf0[2];
285     w2[3] = salt_buf0[3];
286     w3[0] = salt_buf1[0];
287     w3[1] = salt_buf1[1];
288     w3[2] = salt_buf1[2];
289     w3[3] = salt_buf1[3];
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_14 = (32 + salt_len) * 8;
370
371     a = r_a;
372     b = r_b;
373     c = r_c;
374     d = r_d;
375
376     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C00, MD5S00);
377     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C01, MD5S01);
378     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C02, MD5S02);
379     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C03, MD5S03);
380     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C04, MD5S00);
381     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C05, MD5S01);
382     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C06, MD5S02);
383     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C07, MD5S03);
384     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C08, MD5S00);
385     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C09, MD5S01);
386     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C0a, MD5S02);
387     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0b, MD5S03);
388     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C0c, MD5S00);
389     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C0d, MD5S01);
390     MD5_STEP (MD5_Fo, c, d, a, b, r_14, MD5C0e, MD5S02);
391     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0f, MD5S03);
392
393     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C10, MD5S10);
394     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C11, MD5S11);
395     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C12, MD5S12);
396     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C13, MD5S13);
397     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C14, MD5S10);
398     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C15, MD5S11);
399     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C16, MD5S12);
400     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C17, MD5S13);
401     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C18, MD5S10);
402     MD5_STEP (MD5_Go, d, a, b, c, r_14, MD5C19, MD5S11);
403     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1a, MD5S12);
404     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1b, MD5S13);
405     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C1c, MD5S10);
406     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C1d, MD5S11);
407     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1e, MD5S12);
408     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1f, MD5S13);
409
410     MD5_STEP0(MD5_H , a, b, c, d,       MD5C20, MD5S20);
411     MD5_STEP0(MD5_H , d, a, b, c,       MD5C21, MD5S21);
412     MD5_STEP0(MD5_H , c, d, a, b,       MD5C22, MD5S22);
413     MD5_STEP (MD5_H , b, c, d, a, r_14, MD5C23, MD5S23);
414     MD5_STEP0(MD5_H , a, b, c, d,       MD5C24, MD5S20);
415     MD5_STEP0(MD5_H , d, a, b, c,       MD5C25, MD5S21);
416     MD5_STEP0(MD5_H , c, d, a, b,       MD5C26, MD5S22);
417     MD5_STEP0(MD5_H , b, c, d, a,       MD5C27, MD5S23);
418     MD5_STEP0(MD5_H , a, b, c, d,       MD5C28, MD5S20);
419     MD5_STEP0(MD5_H , d, a, b, c,       MD5C29, MD5S21);
420     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2a, MD5S22);
421     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2b, MD5S23);
422     MD5_STEP0(MD5_H , a, b, c, d,       MD5C2c, MD5S20);
423     MD5_STEP0(MD5_H , d, a, b, c,       MD5C2d, MD5S21);
424     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2e, MD5S22);
425     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2f, MD5S23);
426
427     MD5_STEP0(MD5_I , a, b, c, d,       MD5C30, MD5S30);
428     MD5_STEP0(MD5_I , d, a, b, c,       MD5C31, MD5S31);
429     MD5_STEP (MD5_I , c, d, a, b, r_14, MD5C32, MD5S32);
430     MD5_STEP0(MD5_I , b, c, d, a,       MD5C33, MD5S33);
431     MD5_STEP0(MD5_I , a, b, c, d,       MD5C34, MD5S30);
432     MD5_STEP0(MD5_I , d, a, b, c,       MD5C35, MD5S31);
433     MD5_STEP0(MD5_I , c, d, a, b,       MD5C36, MD5S32);
434     MD5_STEP0(MD5_I , b, c, d, a,       MD5C37, MD5S33);
435     MD5_STEP0(MD5_I , a, b, c, d,       MD5C38, MD5S30);
436     MD5_STEP0(MD5_I , d, a, b, c,       MD5C39, MD5S31);
437     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3a, MD5S32);
438     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3b, MD5S33);
439     MD5_STEP0(MD5_I , a, b, c, d,       MD5C3c, MD5S30);
440     MD5_STEP0(MD5_I , d, a, b, c,       MD5C3d, MD5S31);
441     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3e, MD5S32);
442     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3f, MD5S33);
443
444     a += r_a;
445     b += r_b;
446     c += r_c;
447     d += r_d;
448
449     COMPARE_M_SIMD (a, d, c, b);
450   }
451 }
452
453 __kernel void m02710_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)
454 {
455 }
456
457 __kernel void m02710_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)
458 {
459 }
460
461 __kernel void m02710_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)
462 {
463   /**
464    * modifier
465    */
466
467   const u32 gid = get_global_id (0);
468   const u32 lid = get_local_id (0);
469   const u32 lsz = get_local_size (0);
470
471   /**
472    * bin2asc table
473    */
474
475   __local u32 l_bin2asc[256];
476
477   for (u32 i = lid; i < 256; i += lsz)
478   {
479     const u32 i0 = (i >> 0) & 15;
480     const u32 i1 = (i >> 4) & 15;
481
482     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
483                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
484   }
485
486   barrier (CLK_LOCAL_MEM_FENCE);
487
488   if (gid >= gid_max) return;
489
490   /**
491    * base
492    */
493
494   u32 pw_buf0[4];
495   u32 pw_buf1[4];
496
497   pw_buf0[0] = pws[gid].i[0];
498   pw_buf0[1] = pws[gid].i[1];
499   pw_buf0[2] = pws[gid].i[2];
500   pw_buf0[3] = pws[gid].i[3];
501   pw_buf1[0] = pws[gid].i[4];
502   pw_buf1[1] = pws[gid].i[5];
503   pw_buf1[2] = pws[gid].i[6];
504   pw_buf1[3] = pws[gid].i[7];
505
506   const u32 pw_l_len = pws[gid].pw_len;
507
508   /**
509    * salt
510    */
511
512   u32 salt_buf0[4];
513   u32 salt_buf1[4];
514   u32 salt_buf2[4];
515   u32 salt_buf3[4];
516
517   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0];
518   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1];
519   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2];
520   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[3];
521   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[4];
522   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[5];
523   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[6];
524   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[7];
525   salt_buf2[0] = 0;
526   salt_buf2[1] = 0;
527   salt_buf2[2] = 0;
528   salt_buf2[3] = 0;
529   salt_buf3[0] = 0;
530   salt_buf3[1] = 0;
531   salt_buf3[2] = 0;
532   salt_buf3[3] = 0;
533
534   const u32 salt_len = salt_bufs[salt_pos].salt_len;
535
536   /**
537    * digest
538    */
539
540   const u32 search[4] =
541   {
542     digests_buf[digests_offset].digest_buf[DGST_R0],
543     digests_buf[digests_offset].digest_buf[DGST_R1],
544     digests_buf[digests_offset].digest_buf[DGST_R2],
545     digests_buf[digests_offset].digest_buf[DGST_R3]
546   };
547
548   /**
549    * loop
550    */
551
552   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
553   {
554     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
555
556     const u32x pw_len = pw_l_len + pw_r_len;
557
558     /**
559      * concat password candidate
560      */
561
562     u32x wordl0[4] = { 0 };
563     u32x wordl1[4] = { 0 };
564     u32x wordl2[4] = { 0 };
565     u32x wordl3[4] = { 0 };
566
567     wordl0[0] = pw_buf0[0];
568     wordl0[1] = pw_buf0[1];
569     wordl0[2] = pw_buf0[2];
570     wordl0[3] = pw_buf0[3];
571     wordl1[0] = pw_buf1[0];
572     wordl1[1] = pw_buf1[1];
573     wordl1[2] = pw_buf1[2];
574     wordl1[3] = pw_buf1[3];
575
576     u32x wordr0[4] = { 0 };
577     u32x wordr1[4] = { 0 };
578     u32x wordr2[4] = { 0 };
579     u32x wordr3[4] = { 0 };
580
581     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
582     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
583     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
584     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
585     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
586     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
587     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
588     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
589
590     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
591     {
592       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
593     }
594     else
595     {
596       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
597     }
598
599     u32x w0[4];
600     u32x w1[4];
601     u32x w2[4];
602     u32x w3[4];
603
604     w0[0] = wordl0[0] | wordr0[0];
605     w0[1] = wordl0[1] | wordr0[1];
606     w0[2] = wordl0[2] | wordr0[2];
607     w0[3] = wordl0[3] | wordr0[3];
608     w1[0] = wordl1[0] | wordr1[0];
609     w1[1] = wordl1[1] | wordr1[1];
610     w1[2] = wordl1[2] | wordr1[2];
611     w1[3] = wordl1[3] | wordr1[3];
612     w2[0] = wordl2[0] | wordr2[0];
613     w2[1] = wordl2[1] | wordr2[1];
614     w2[2] = wordl2[2] | wordr2[2];
615     w2[3] = wordl2[3] | wordr2[3];
616     w3[0] = wordl3[0] | wordr3[0];
617     w3[1] = wordl3[1] | wordr3[1];
618     w3[2] = pw_len * 8;
619     w3[3] = 0;
620
621     /**
622      * md5
623      */
624
625     u32x a = MD5M_A;
626     u32x b = MD5M_B;
627     u32x c = MD5M_C;
628     u32x d = MD5M_D;
629
630     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
631     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
632     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
633     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
634     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
635     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
636     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
637     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
638     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
639     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
640     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
641     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
642     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
643     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
644     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
645     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
646
647     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
648     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
649     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
650     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
651     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
652     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
653     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
654     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
655     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
656     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
657     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
658     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
659     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
660     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
661     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
662     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
663
664     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
665     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
666     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
667     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
668     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
669     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
670     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
671     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
672     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
673     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
674     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
675     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
676     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
677     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
678     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
679     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
680
681     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
682     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
683     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
684     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
685     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
686     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
687     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
688     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
689     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
690     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
691     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
692     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
693     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
694     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
695     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
696     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
697
698     a += MD5M_A;
699     b += MD5M_B;
700     c += MD5M_C;
701     d += MD5M_D;
702
703     w0[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
704           | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
705     w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
706           | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
707     w0[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
708           | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
709     w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
710           | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
711     w1[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
712           | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
713     w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
714           | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
715     w1[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
716           | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
717     w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
718           | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
719
720     w2[0] = salt_buf0[0];
721     w2[1] = salt_buf0[1];
722     w2[2] = salt_buf0[2];
723     w2[3] = salt_buf0[3];
724     w3[0] = salt_buf1[0];
725     w3[1] = salt_buf1[1];
726     w3[2] = salt_buf1[2];
727     w3[3] = salt_buf1[3];
728
729     a = MD5M_A;
730     b = MD5M_B;
731     c = MD5M_C;
732     d = MD5M_D;
733
734     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
735     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
736     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
737     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
738     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
739     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
740     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
741     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
742     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
743     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
744     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
745     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
746     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
747     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
748     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
749     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
750
751     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
752     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
753     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
754     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
755     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
756     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
757     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
758     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
759     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
760     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
761     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
762     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
763     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
764     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
765     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
766     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
767
768     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
769     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
770     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
771     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
772     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
773     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
774     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
775     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
776     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
777     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
778     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
779     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
780     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
781     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
782     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
783     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
784
785     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
786     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
787     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
788     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
789     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
790     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
791     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
792     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
793     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
794     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
795     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
796     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
797     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
798     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
799     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
800     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
801
802     const u32x r_a = a + MD5M_A;
803     const u32x r_b = b + MD5M_B;
804     const u32x r_c = c + MD5M_C;
805     const u32x r_d = d + MD5M_D;
806
807     const u32x r_14 = (32 + salt_len) * 8;
808
809     a = r_a;
810     b = r_b;
811     c = r_c;
812     d = r_d;
813
814     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C00, MD5S00);
815     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C01, MD5S01);
816     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C02, MD5S02);
817     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C03, MD5S03);
818     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C04, MD5S00);
819     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C05, MD5S01);
820     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C06, MD5S02);
821     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C07, MD5S03);
822     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C08, MD5S00);
823     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C09, MD5S01);
824     MD5_STEP0(MD5_Fo, c, d, a, b,       MD5C0a, MD5S02);
825     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0b, MD5S03);
826     MD5_STEP0(MD5_Fo, a, b, c, d,       MD5C0c, MD5S00);
827     MD5_STEP0(MD5_Fo, d, a, b, c,       MD5C0d, MD5S01);
828     MD5_STEP (MD5_Fo, c, d, a, b, r_14, MD5C0e, MD5S02);
829     MD5_STEP0(MD5_Fo, b, c, d, a,       MD5C0f, MD5S03);
830
831     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C10, MD5S10);
832     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C11, MD5S11);
833     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C12, MD5S12);
834     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C13, MD5S13);
835     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C14, MD5S10);
836     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C15, MD5S11);
837     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C16, MD5S12);
838     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C17, MD5S13);
839     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C18, MD5S10);
840     MD5_STEP (MD5_Go, d, a, b, c, r_14, MD5C19, MD5S11);
841     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1a, MD5S12);
842     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1b, MD5S13);
843     MD5_STEP0(MD5_Go, a, b, c, d,       MD5C1c, MD5S10);
844     MD5_STEP0(MD5_Go, d, a, b, c,       MD5C1d, MD5S11);
845     MD5_STEP0(MD5_Go, c, d, a, b,       MD5C1e, MD5S12);
846     MD5_STEP0(MD5_Go, b, c, d, a,       MD5C1f, MD5S13);
847
848     MD5_STEP0(MD5_H , a, b, c, d,       MD5C20, MD5S20);
849     MD5_STEP0(MD5_H , d, a, b, c,       MD5C21, MD5S21);
850     MD5_STEP0(MD5_H , c, d, a, b,       MD5C22, MD5S22);
851     MD5_STEP (MD5_H , b, c, d, a, r_14, MD5C23, MD5S23);
852     MD5_STEP0(MD5_H , a, b, c, d,       MD5C24, MD5S20);
853     MD5_STEP0(MD5_H , d, a, b, c,       MD5C25, MD5S21);
854     MD5_STEP0(MD5_H , c, d, a, b,       MD5C26, MD5S22);
855     MD5_STEP0(MD5_H , b, c, d, a,       MD5C27, MD5S23);
856     MD5_STEP0(MD5_H , a, b, c, d,       MD5C28, MD5S20);
857     MD5_STEP0(MD5_H , d, a, b, c,       MD5C29, MD5S21);
858     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2a, MD5S22);
859     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2b, MD5S23);
860     MD5_STEP0(MD5_H , a, b, c, d,       MD5C2c, MD5S20);
861     MD5_STEP0(MD5_H , d, a, b, c,       MD5C2d, MD5S21);
862     MD5_STEP0(MD5_H , c, d, a, b,       MD5C2e, MD5S22);
863     MD5_STEP0(MD5_H , b, c, d, a,       MD5C2f, MD5S23);
864
865     MD5_STEP0(MD5_I , a, b, c, d,       MD5C30, MD5S30);
866     MD5_STEP0(MD5_I , d, a, b, c,       MD5C31, MD5S31);
867     MD5_STEP (MD5_I , c, d, a, b, r_14, MD5C32, MD5S32);
868     MD5_STEP0(MD5_I , b, c, d, a,       MD5C33, MD5S33);
869     MD5_STEP0(MD5_I , a, b, c, d,       MD5C34, MD5S30);
870     MD5_STEP0(MD5_I , d, a, b, c,       MD5C35, MD5S31);
871     MD5_STEP0(MD5_I , c, d, a, b,       MD5C36, MD5S32);
872     MD5_STEP0(MD5_I , b, c, d, a,       MD5C37, MD5S33);
873     MD5_STEP0(MD5_I , a, b, c, d,       MD5C38, MD5S30);
874     MD5_STEP0(MD5_I , d, a, b, c,       MD5C39, MD5S31);
875     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3a, MD5S32);
876     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3b, MD5S33);
877     MD5_STEP0(MD5_I , a, b, c, d,       MD5C3c, MD5S30);
878
879     if (MATCHES_NONE_VS ((a + r_a), search[0])) continue;
880
881     MD5_STEP0(MD5_I , d, a, b, c,       MD5C3d, MD5S31);
882     MD5_STEP0(MD5_I , c, d, a, b,       MD5C3e, MD5S32);
883     MD5_STEP0(MD5_I , b, c, d, a,       MD5C3f, MD5S33);
884
885     a += r_a;
886     b += r_b;
887     c += r_c;
888     d += r_d;
889
890     COMPARE_S_SIMD (a, d, c, b);
891   }
892 }
893
894 __kernel void m02710_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)
895 {
896 }
897
898 __kernel void m02710_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)
899 {
900 }