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