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