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