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