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