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