Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m00010_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 m00010_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      * append salt
150      */
151
152     u32x s0[4];
153     u32x s1[4];
154     u32x s2[4];
155     u32x s3[4];
156
157     s0[0] = salt_buf0[0];
158     s0[1] = salt_buf0[1];
159     s0[2] = salt_buf0[2];
160     s0[3] = salt_buf0[3];
161     s1[0] = salt_buf1[0];
162     s1[1] = salt_buf1[1];
163     s1[2] = salt_buf1[2];
164     s1[3] = salt_buf1[3];
165     s2[0] = salt_buf2[0];
166     s2[1] = salt_buf2[1];
167     s2[2] = salt_buf2[2];
168     s2[3] = salt_buf2[3];
169     s3[0] = salt_buf3[0];
170     s3[1] = salt_buf3[1];
171     s3[2] = salt_buf3[2];
172     s3[3] = salt_buf3[3];
173
174     switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len);
175
176     const u32x pw_salt_len = pw_len + salt_len;
177
178     w0[0] |= s0[0];
179     w0[1] |= s0[1];
180     w0[2] |= s0[2];
181     w0[3] |= s0[3];
182     w1[0] |= s1[0];
183     w1[1] |= s1[1];
184     w1[2] |= s1[2];
185     w1[3] |= s1[3];
186     w2[0] |= s2[0];
187     w2[1] |= s2[1];
188     w2[2] |= s2[2];
189     w2[3] |= s2[3];
190     w3[0] |= s3[0];
191     w3[1] |= s3[1];
192     w3[2]  = pw_salt_len * 8;
193     w3[3]  = 0;
194
195     /**
196      * md5
197      */
198
199     u32x a = MD5M_A;
200     u32x b = MD5M_B;
201     u32x c = MD5M_C;
202     u32x d = MD5M_D;
203
204     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
205     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
206     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
207     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
208     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
209     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
210     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
211     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
212     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
213     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
214     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
215     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
216     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
217     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
218     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
219     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
220
221     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
222     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
223     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
224     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
225     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
226     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
227     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
228     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
229     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
230     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
231     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
232     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
233     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
234     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
235     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
236     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
237
238     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
239     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
240     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
241     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
242     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
243     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
244     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
245     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
246     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
247     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
248     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
249     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
250     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
251     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
252     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
253     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
254
255     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
256     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
257     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
258     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
259     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
260     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
261     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
262     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
263     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
264     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
265     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
266     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
267     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
268     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
269     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
270     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
271
272     COMPARE_M_SIMD (a, d, c, b);
273   }
274 }
275
276 __kernel void m00010_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)
277 {
278 }
279
280 __kernel void m00010_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)
281 {
282 }
283
284 __kernel void m00010_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)
285 {
286   /**
287    * modifier
288    */
289
290   const u32 lid = get_local_id (0);
291
292   /**
293    * base
294    */
295
296   const u32 gid = get_global_id (0);
297
298   if (gid >= gid_max) return;
299
300   u32 pw_buf0[4];
301   u32 pw_buf1[4];
302
303   pw_buf0[0] = pws[gid].i[0];
304   pw_buf0[1] = pws[gid].i[1];
305   pw_buf0[2] = pws[gid].i[2];
306   pw_buf0[3] = pws[gid].i[3];
307   pw_buf1[0] = pws[gid].i[4];
308   pw_buf1[1] = pws[gid].i[5];
309   pw_buf1[2] = pws[gid].i[6];
310   pw_buf1[3] = pws[gid].i[7];
311
312   const u32 pw_l_len = pws[gid].pw_len;
313
314   /**
315    * salt
316    */
317
318   u32 salt_buf0[4];
319   u32 salt_buf1[4];
320   u32 salt_buf2[4];
321   u32 salt_buf3[4];
322
323   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
324   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
325   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
326   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
327   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
328   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
329   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
330   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
331   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
332   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
333   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
334   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
335   salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
336   salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
337   salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
338   salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
339
340   const u32 salt_len = salt_bufs[salt_pos].salt_len;
341
342   /**
343    * digest
344    */
345
346   const u32 search[4] =
347   {
348     digests_buf[digests_offset].digest_buf[DGST_R0],
349     digests_buf[digests_offset].digest_buf[DGST_R1],
350     digests_buf[digests_offset].digest_buf[DGST_R2],
351     digests_buf[digests_offset].digest_buf[DGST_R3]
352   };
353
354   /**
355    * loop
356    */
357
358   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
359   {
360     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
361
362     const u32x pw_len = pw_l_len + pw_r_len;
363
364     /**
365      * concat password candidate
366      */
367
368     u32x wordl0[4] = { 0 };
369     u32x wordl1[4] = { 0 };
370     u32x wordl2[4] = { 0 };
371     u32x wordl3[4] = { 0 };
372
373     wordl0[0] = pw_buf0[0];
374     wordl0[1] = pw_buf0[1];
375     wordl0[2] = pw_buf0[2];
376     wordl0[3] = pw_buf0[3];
377     wordl1[0] = pw_buf1[0];
378     wordl1[1] = pw_buf1[1];
379     wordl1[2] = pw_buf1[2];
380     wordl1[3] = pw_buf1[3];
381
382     u32x wordr0[4] = { 0 };
383     u32x wordr1[4] = { 0 };
384     u32x wordr2[4] = { 0 };
385     u32x wordr3[4] = { 0 };
386
387     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
388     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
389     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
390     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
391     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
392     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
393     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
394     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
395
396     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
397     {
398       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
399     }
400     else
401     {
402       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
403     }
404
405     u32x w0[4];
406     u32x w1[4];
407     u32x w2[4];
408     u32x w3[4];
409
410     w0[0] = wordl0[0] | wordr0[0];
411     w0[1] = wordl0[1] | wordr0[1];
412     w0[2] = wordl0[2] | wordr0[2];
413     w0[3] = wordl0[3] | wordr0[3];
414     w1[0] = wordl1[0] | wordr1[0];
415     w1[1] = wordl1[1] | wordr1[1];
416     w1[2] = wordl1[2] | wordr1[2];
417     w1[3] = wordl1[3] | wordr1[3];
418     w2[0] = wordl2[0] | wordr2[0];
419     w2[1] = wordl2[1] | wordr2[1];
420     w2[2] = wordl2[2] | wordr2[2];
421     w2[3] = wordl2[3] | wordr2[3];
422     w3[0] = wordl3[0] | wordr3[0];
423     w3[1] = wordl3[1] | wordr3[1];
424     w3[2] = wordl3[2] | wordr3[2];
425     w3[3] = wordl3[3] | wordr3[3];
426
427     /**
428      * append salt
429      */
430
431     u32x s0[4];
432     u32x s1[4];
433     u32x s2[4];
434     u32x s3[4];
435
436     s0[0] = salt_buf0[0];
437     s0[1] = salt_buf0[1];
438     s0[2] = salt_buf0[2];
439     s0[3] = salt_buf0[3];
440     s1[0] = salt_buf1[0];
441     s1[1] = salt_buf1[1];
442     s1[2] = salt_buf1[2];
443     s1[3] = salt_buf1[3];
444     s2[0] = salt_buf2[0];
445     s2[1] = salt_buf2[1];
446     s2[2] = salt_buf2[2];
447     s2[3] = salt_buf2[3];
448     s3[0] = salt_buf3[0];
449     s3[1] = salt_buf3[1];
450     s3[2] = salt_buf3[2];
451     s3[3] = salt_buf3[3];
452
453     switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len);
454
455     const u32x pw_salt_len = pw_len + salt_len;
456
457     w0[0] |= s0[0];
458     w0[1] |= s0[1];
459     w0[2] |= s0[2];
460     w0[3] |= s0[3];
461     w1[0] |= s1[0];
462     w1[1] |= s1[1];
463     w1[2] |= s1[2];
464     w1[3] |= s1[3];
465     w2[0] |= s2[0];
466     w2[1] |= s2[1];
467     w2[2] |= s2[2];
468     w2[3] |= s2[3];
469     w3[0] |= s3[0];
470     w3[1] |= s3[1];
471     w3[2]  = pw_salt_len * 8;
472     w3[3]  = 0;
473
474     /**
475      * md5
476      */
477
478     u32x a = MD5M_A;
479     u32x b = MD5M_B;
480     u32x c = MD5M_C;
481     u32x d = MD5M_D;
482
483     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
484     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
485     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
486     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
487     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
488     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
489     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
490     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
491     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
492     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
493     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
494     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
495     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
496     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
497     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
498     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
499
500     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
501     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
502     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
503     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
504     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
505     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
506     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
507     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
508     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
509     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
510     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
511     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
512     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
513     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
514     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
515     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
516
517     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
518     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
519     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
520     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
521     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
522     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
523     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
524     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
525     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
526     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
527     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
528     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
529     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
530     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
531     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
532     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
533
534     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
535     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
536     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
537     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
538     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
539     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
540     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
541     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
542     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
543     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
544     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
545     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
546     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
547
548     if (MATCHES_NONE_VS (a, search[0])) continue;
549
550     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
551     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
552     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
553
554     COMPARE_S_SIMD (a, d, c, b);
555   }
556 }
557
558 __kernel void m00010_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)
559 {
560 }
561
562 __kernel void m00010_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)
563 {
564 }