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