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