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