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