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