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