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