Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m03800_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 __kernel void m03800_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)
18 {
19   /**
20    * modifier
21    */
22
23   const u32 lid = get_local_id (0);
24
25   /**
26    * base
27    */
28
29   const u32 gid = get_global_id (0);
30
31   if (gid >= gid_max) return;
32
33   u32 pw_buf0[4];
34   u32 pw_buf1[4];
35
36   pw_buf0[0] = pws[gid].i[0];
37   pw_buf0[1] = pws[gid].i[1];
38   pw_buf0[2] = pws[gid].i[2];
39   pw_buf0[3] = pws[gid].i[3];
40   pw_buf1[0] = pws[gid].i[4];
41   pw_buf1[1] = pws[gid].i[5];
42   pw_buf1[2] = pws[gid].i[6];
43   pw_buf1[3] = pws[gid].i[7];
44
45   const u32 pw_l_len = pws[gid].pw_len;
46
47   /**
48    * salt
49    */
50
51   u32 salt_buf0[4];
52   u32 salt_buf1[4];
53   u32 salt_buf2[4];
54   u32 salt_buf3[4];
55
56   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
57   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
58   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
59   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
60   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
61   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
62   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
63   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
64   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
65   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
66   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
67   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
68   salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
69   salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
70   salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
71   salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
72
73   const u32 salt_len = salt_bufs[salt_pos].salt_len;
74
75   /**
76    * loop
77    */
78
79   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
80   {
81     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
82
83     const u32x pw_len = pw_l_len + pw_r_len;
84
85     /**
86      * concat password candidate
87      */
88
89     u32x wordl0[4] = { 0 };
90     u32x wordl1[4] = { 0 };
91     u32x wordl2[4] = { 0 };
92     u32x wordl3[4] = { 0 };
93
94     wordl0[0] = pw_buf0[0];
95     wordl0[1] = pw_buf0[1];
96     wordl0[2] = pw_buf0[2];
97     wordl0[3] = pw_buf0[3];
98     wordl1[0] = pw_buf1[0];
99     wordl1[1] = pw_buf1[1];
100     wordl1[2] = pw_buf1[2];
101     wordl1[3] = pw_buf1[3];
102
103     u32x wordr0[4] = { 0 };
104     u32x wordr1[4] = { 0 };
105     u32x wordr2[4] = { 0 };
106     u32x wordr3[4] = { 0 };
107
108     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
109     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
110     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
111     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
112     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
113     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
114     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
115     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
116
117     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
118     {
119       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
120     }
121     else
122     {
123       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
124     }
125
126     u32x w0[4];
127     u32x w1[4];
128     u32x w2[4];
129     u32x w3[4];
130
131     w0[0] = wordl0[0] | wordr0[0];
132     w0[1] = wordl0[1] | wordr0[1];
133     w0[2] = wordl0[2] | wordr0[2];
134     w0[3] = wordl0[3] | wordr0[3];
135     w1[0] = wordl1[0] | wordr1[0];
136     w1[1] = wordl1[1] | wordr1[1];
137     w1[2] = wordl1[2] | wordr1[2];
138     w1[3] = wordl1[3] | wordr1[3];
139     w2[0] = wordl2[0] | wordr2[0];
140     w2[1] = wordl2[1] | wordr2[1];
141     w2[2] = wordl2[2] | wordr2[2];
142     w2[3] = wordl2[3] | wordr2[3];
143     w3[0] = wordl3[0] | wordr3[0];
144     w3[1] = wordl3[1] | wordr3[1];
145     w3[2] = wordl3[2] | wordr3[2];
146     w3[3] = wordl3[3] | wordr3[3];
147
148     /**
149      * prepend salt
150      */
151
152     switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len);
153
154     const u32x pw_salt_len = pw_len + salt_len;
155
156     w0[0] |= salt_buf0[0];
157     w0[1] |= salt_buf0[1];
158     w0[2] |= salt_buf0[2];
159     w0[3] |= salt_buf0[3];
160     w1[0] |= salt_buf1[0];
161     w1[1] |= salt_buf1[1];
162     w1[2] |= salt_buf1[2];
163     w1[3] |= salt_buf1[3];
164     w2[0] |= salt_buf2[0];
165     w2[1] |= salt_buf2[1];
166     w2[2] |= salt_buf2[2];
167     w2[3] |= salt_buf2[3];
168     w3[0] |= salt_buf3[0];
169     w3[1] |= salt_buf3[1];
170     w3[2] |= salt_buf3[2];
171     w3[3] |= salt_buf3[3];
172
173     /**
174      * append salt
175      */
176
177     u32x s0[4];
178     u32x s1[4];
179     u32x s2[4];
180     u32x s3[4];
181
182     s0[0] = salt_buf0[0];
183     s0[1] = salt_buf0[1];
184     s0[2] = salt_buf0[2];
185     s0[3] = salt_buf0[3];
186     s1[0] = salt_buf1[0];
187     s1[1] = salt_buf1[1];
188     s1[2] = salt_buf1[2];
189     s1[3] = salt_buf1[3];
190     s2[0] = salt_buf2[0];
191     s2[1] = salt_buf2[1];
192     s2[2] = salt_buf2[2];
193     s2[3] = salt_buf2[3];
194     s3[0] = salt_buf3[0];
195     s3[1] = salt_buf3[1];
196     s3[2] = salt_buf3[2];
197     s3[3] = salt_buf3[3];
198
199     switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_salt_len);
200
201     w0[0] |= s0[0];
202     w0[1] |= s0[1];
203     w0[2] |= s0[2];
204     w0[3] |= s0[3];
205     w1[0] |= s1[0];
206     w1[1] |= s1[1];
207     w1[2] |= s1[2];
208     w1[3] |= s1[3];
209     w2[0] |= s2[0];
210     w2[1] |= s2[1];
211     w2[2] |= s2[2];
212     w2[3] |= s2[3];
213     w3[0] |= s3[0];
214     w3[1] |= s3[1];
215     w3[2] |= s3[2];
216     w3[3] |= s3[3];
217
218     const u32x salt_pw_salt_len = salt_len + pw_len + salt_len;
219
220     append_0x80_4x4_VV (w0, w1, w2, w3, salt_pw_salt_len);
221
222     w3[2] = salt_pw_salt_len * 8;
223     w3[3] = 0;
224
225     /**
226      * md5
227      */
228
229     u32x a = MD5M_A;
230     u32x b = MD5M_B;
231     u32x c = MD5M_C;
232     u32x d = MD5M_D;
233
234     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
235     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
236     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
237     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
238     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
239     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
240     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
241     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
242     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
243     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
244     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
245     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
246     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
247     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
248     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
249     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
250
251     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
252     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
253     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
254     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
255     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
256     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
257     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
258     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
259     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
260     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
261     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
262     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
263     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
264     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
265     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
266     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
267
268     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
269     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
270     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
271     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
272     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
273     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
274     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
275     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
276     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
277     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
278     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
279     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
280     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
281     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
282     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
283     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
284
285     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
286     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
287     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
288     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
289     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
290     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
291     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
292     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
293     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
294     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
295     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
296     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
297     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
298     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
299     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
300     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
301
302     COMPARE_M_SIMD (a, d, c, b);
303   }
304 }
305
306 __kernel void m03800_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)
307 {
308 }
309
310 __kernel void m03800_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)
311 {
312 }
313
314 __kernel void m03800_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)
315 {
316   /**
317    * modifier
318    */
319
320   const u32 lid = get_local_id (0);
321
322   /**
323    * base
324    */
325
326   const u32 gid = get_global_id (0);
327
328   if (gid >= gid_max) return;
329
330   u32 pw_buf0[4];
331   u32 pw_buf1[4];
332
333   pw_buf0[0] = pws[gid].i[0];
334   pw_buf0[1] = pws[gid].i[1];
335   pw_buf0[2] = pws[gid].i[2];
336   pw_buf0[3] = pws[gid].i[3];
337   pw_buf1[0] = pws[gid].i[4];
338   pw_buf1[1] = pws[gid].i[5];
339   pw_buf1[2] = pws[gid].i[6];
340   pw_buf1[3] = pws[gid].i[7];
341
342   const u32 pw_l_len = pws[gid].pw_len;
343
344   /**
345    * salt
346    */
347
348   u32 salt_buf0[4];
349   u32 salt_buf1[4];
350   u32 salt_buf2[4];
351   u32 salt_buf3[4];
352
353   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
354   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
355   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
356   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
357   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
358   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
359   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
360   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
361   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
362   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
363   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
364   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
365   salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
366   salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
367   salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
368   salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
369
370   const u32 salt_len = salt_bufs[salt_pos].salt_len;
371
372   /**
373    * digest
374    */
375
376   const u32 search[4] =
377   {
378     digests_buf[digests_offset].digest_buf[DGST_R0],
379     digests_buf[digests_offset].digest_buf[DGST_R1],
380     digests_buf[digests_offset].digest_buf[DGST_R2],
381     digests_buf[digests_offset].digest_buf[DGST_R3]
382   };
383
384   /**
385    * loop
386    */
387
388   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
389   {
390     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
391
392     const u32x pw_len = pw_l_len + pw_r_len;
393
394     /**
395      * concat password candidate
396      */
397
398     u32x wordl0[4] = { 0 };
399     u32x wordl1[4] = { 0 };
400     u32x wordl2[4] = { 0 };
401     u32x wordl3[4] = { 0 };
402
403     wordl0[0] = pw_buf0[0];
404     wordl0[1] = pw_buf0[1];
405     wordl0[2] = pw_buf0[2];
406     wordl0[3] = pw_buf0[3];
407     wordl1[0] = pw_buf1[0];
408     wordl1[1] = pw_buf1[1];
409     wordl1[2] = pw_buf1[2];
410     wordl1[3] = pw_buf1[3];
411
412     u32x wordr0[4] = { 0 };
413     u32x wordr1[4] = { 0 };
414     u32x wordr2[4] = { 0 };
415     u32x wordr3[4] = { 0 };
416
417     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
418     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
419     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
420     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
421     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
422     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
423     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
424     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
425
426     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
427     {
428       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
429     }
430     else
431     {
432       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
433     }
434
435     u32x w0[4];
436     u32x w1[4];
437     u32x w2[4];
438     u32x w3[4];
439
440     w0[0] = wordl0[0] | wordr0[0];
441     w0[1] = wordl0[1] | wordr0[1];
442     w0[2] = wordl0[2] | wordr0[2];
443     w0[3] = wordl0[3] | wordr0[3];
444     w1[0] = wordl1[0] | wordr1[0];
445     w1[1] = wordl1[1] | wordr1[1];
446     w1[2] = wordl1[2] | wordr1[2];
447     w1[3] = wordl1[3] | wordr1[3];
448     w2[0] = wordl2[0] | wordr2[0];
449     w2[1] = wordl2[1] | wordr2[1];
450     w2[2] = wordl2[2] | wordr2[2];
451     w2[3] = wordl2[3] | wordr2[3];
452     w3[0] = wordl3[0] | wordr3[0];
453     w3[1] = wordl3[1] | wordr3[1];
454     w3[2] = wordl3[2] | wordr3[2];
455     w3[3] = wordl3[3] | wordr3[3];
456
457     /**
458      * prepend salt
459      */
460
461     switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len);
462
463     const u32x pw_salt_len = pw_len + salt_len;
464
465     w0[0] |= salt_buf0[0];
466     w0[1] |= salt_buf0[1];
467     w0[2] |= salt_buf0[2];
468     w0[3] |= salt_buf0[3];
469     w1[0] |= salt_buf1[0];
470     w1[1] |= salt_buf1[1];
471     w1[2] |= salt_buf1[2];
472     w1[3] |= salt_buf1[3];
473     w2[0] |= salt_buf2[0];
474     w2[1] |= salt_buf2[1];
475     w2[2] |= salt_buf2[2];
476     w2[3] |= salt_buf2[3];
477     w3[0] |= salt_buf3[0];
478     w3[1] |= salt_buf3[1];
479     w3[2] |= salt_buf3[2];
480     w3[3] |= salt_buf3[3];
481
482     /**
483      * append salt
484      */
485
486     u32x s0[4];
487     u32x s1[4];
488     u32x s2[4];
489     u32x s3[4];
490
491     s0[0] = salt_buf0[0];
492     s0[1] = salt_buf0[1];
493     s0[2] = salt_buf0[2];
494     s0[3] = salt_buf0[3];
495     s1[0] = salt_buf1[0];
496     s1[1] = salt_buf1[1];
497     s1[2] = salt_buf1[2];
498     s1[3] = salt_buf1[3];
499     s2[0] = salt_buf2[0];
500     s2[1] = salt_buf2[1];
501     s2[2] = salt_buf2[2];
502     s2[3] = salt_buf2[3];
503     s3[0] = salt_buf3[0];
504     s3[1] = salt_buf3[1];
505     s3[2] = salt_buf3[2];
506     s3[3] = salt_buf3[3];
507
508     switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_salt_len);
509
510     w0[0] |= s0[0];
511     w0[1] |= s0[1];
512     w0[2] |= s0[2];
513     w0[3] |= s0[3];
514     w1[0] |= s1[0];
515     w1[1] |= s1[1];
516     w1[2] |= s1[2];
517     w1[3] |= s1[3];
518     w2[0] |= s2[0];
519     w2[1] |= s2[1];
520     w2[2] |= s2[2];
521     w2[3] |= s2[3];
522     w3[0] |= s3[0];
523     w3[1] |= s3[1];
524     w3[2] |= s3[2];
525     w3[3] |= s3[3];
526
527     const u32x salt_pw_salt_len = salt_len + pw_len + salt_len;
528
529     append_0x80_4x4_VV (w0, w1, w2, w3, salt_pw_salt_len);
530
531     w3[2] = salt_pw_salt_len * 8;
532     w3[3] = 0;
533
534     /**
535      * md5
536      */
537
538     u32x a = MD5M_A;
539     u32x b = MD5M_B;
540     u32x c = MD5M_C;
541     u32x d = MD5M_D;
542
543     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
544     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
545     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
546     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
547     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
548     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
549     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
550     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
551     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
552     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
553     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
554     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
555     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
556     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
557     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
558     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
559
560     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
561     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
562     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
563     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
564     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
565     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
566     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
567     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
568     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
569     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
570     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
571     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
572     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
573     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
574     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
575     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
576
577     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
578     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
579     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
580     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
581     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
582     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
583     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
584     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
585     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
586     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
587     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
588     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
589     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
590     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
591     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
592     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
593
594     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
595     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
596     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
597     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
598     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
599     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
600     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
601     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
602     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
603     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
604     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
605     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
606     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
607
608     if (MATCHES_NONE_VS (a, search[0])) continue;
609
610     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
611     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
612     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
613
614     COMPARE_S_SIMD (a, d, c, b);
615   }
616 }
617
618 __kernel void m03800_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)
619 {
620 }
621
622 __kernel void m03800_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)
623 {
624 }