Fix path to includes
[hashcat.git] / OpenCL / m04900_a0.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _SHA1_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #define DGST_R0 3
12 #define DGST_R1 4
13 #define DGST_R2 2
14 #define DGST_R3 1
15
16 #include "include/kernel_functions.c"
17 #include "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19 #include "include/rp_gpu.h"
20 #include "OpenCL/rp.c"
21
22 #define COMPARE_S "OpenCL/check_single_comp4.c"
23 #define COMPARE_M "OpenCL/check_multi_comp4.c"
24
25 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m04900_m04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
26 {
27   /**
28    * modifier
29    */
30
31   const u32 lid = get_local_id (0);
32
33   /**
34    * base
35    */
36
37   const u32 gid = get_global_id (0);
38
39   if (gid >= gid_max) return;
40
41   u32 pw_buf0[4];
42
43   pw_buf0[0] = pws[gid].i[ 0];
44   pw_buf0[1] = pws[gid].i[ 1];
45   pw_buf0[2] = pws[gid].i[ 2];
46   pw_buf0[3] = pws[gid].i[ 3];
47
48   u32 pw_buf1[4];
49
50   pw_buf1[0] = pws[gid].i[ 4];
51   pw_buf1[1] = pws[gid].i[ 5];
52   pw_buf1[2] = pws[gid].i[ 6];
53   pw_buf1[3] = pws[gid].i[ 7];
54
55   const u32 pw_len = pws[gid].pw_len;
56
57   /**
58    * salt
59    */
60
61   u32 salt_buf0[4];
62
63   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
64   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
65   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
66   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
67
68   u32 salt_buf1[4];
69
70   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
71   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
72   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
73   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
74
75   u32 salt_buf2[4];
76
77   salt_buf2[0] = 0;
78   salt_buf2[1] = 0;
79   salt_buf2[2] = 0;
80   salt_buf2[3] = 0;
81
82   u32 salt_buf3[4];
83
84   salt_buf3[0] = 0;
85   salt_buf3[1] = 0;
86   salt_buf3[2] = 0;
87   salt_buf3[3] = 0;
88
89   const u32 salt_len = salt_bufs[salt_pos].salt_len;
90
91   /**
92    * loop
93    */
94
95   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
96   {
97     u32 w0_t[4];
98
99     w0_t[0] = pw_buf0[0];
100     w0_t[1] = pw_buf0[1];
101     w0_t[2] = pw_buf0[2];
102     w0_t[3] = pw_buf0[3];
103
104     u32 w1_t[4];
105
106     w1_t[0] = pw_buf1[0];
107     w1_t[1] = pw_buf1[1];
108     w1_t[2] = pw_buf1[2];
109     w1_t[3] = pw_buf1[3];
110
111     u32 w2_t[4];
112
113     w2_t[0] = 0;
114     w2_t[1] = 0;
115     w2_t[2] = 0;
116     w2_t[3] = 0;
117
118     u32 w3_t[4];
119
120     w3_t[0] = 0;
121     w3_t[1] = 0;
122     w3_t[2] = 0;
123     w3_t[3] = 0;
124
125     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0_t, w1_t, pw_len);
126
127     /**
128      * prepend salt
129      */
130
131     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
132
133     w0_t[0] |= salt_buf0[0];
134     w0_t[1] |= salt_buf0[1];
135     w0_t[2] |= salt_buf0[2];
136     w0_t[3] |= salt_buf0[3];
137     w1_t[0] |= salt_buf1[0];
138     w1_t[1] |= salt_buf1[1];
139     w1_t[2] |= salt_buf1[2];
140     w1_t[3] |= salt_buf1[3];
141     w2_t[0] |= salt_buf2[0];
142     w2_t[1] |= salt_buf2[1];
143     w2_t[2] |= salt_buf2[2];
144     w2_t[3] |= salt_buf2[3];
145     w3_t[0] |= salt_buf3[0];
146     w3_t[1] |= salt_buf3[1];
147     w3_t[2] |= salt_buf3[2];
148     w3_t[3] |= salt_buf3[3];
149
150     /**
151      * append salt
152      */
153
154     u32 s0[4];
155
156     s0[0] = salt_buf0[0];
157     s0[1] = salt_buf0[1];
158     s0[2] = salt_buf0[2];
159     s0[3] = salt_buf0[3];
160
161     u32 s1[4];
162
163     s1[0] = salt_buf1[0];
164     s1[1] = salt_buf1[1];
165     s1[2] = salt_buf1[2];
166     s1[3] = salt_buf1[3];
167
168     u32 s2[4];
169
170     s2[0] = 0;
171     s2[1] = 0;
172     s2[2] = 0;
173     s2[3] = 0;
174
175     u32 s3[4];
176
177     s3[0] = 0;
178     s3[1] = 0;
179     s3[2] = 0;
180     s3[3] = 0;
181
182     switch_buffer_by_offset (s0, s1, s2, s3, salt_len + out_len);
183
184     w0_t[0] |= s0[0];
185     w0_t[1] |= s0[1];
186     w0_t[2] |= s0[2];
187     w0_t[3] |= s0[3];
188     w1_t[0] |= s1[0];
189     w1_t[1] |= s1[1];
190     w1_t[2] |= s1[2];
191     w1_t[3] |= s1[3];
192     w2_t[0] |= s2[0];
193     w2_t[1] |= s2[1];
194     w2_t[2] |= s2[2];
195     w2_t[3] |= s2[3];
196     w3_t[0] |= s3[0];
197     w3_t[1] |= s3[1];
198     w3_t[2] |= s3[2];
199     w3_t[3] |= s3[3];
200
201     const u32 pw_salt_len = salt_len + out_len + salt_len;
202
203     append_0x80_4x4 (w0_t, w1_t, w2_t, w3_t, pw_salt_len);
204
205     u32 w0 = swap32 (w0_t[0]);
206     u32 w1 = swap32 (w0_t[1]);
207     u32 w2 = swap32 (w0_t[2]);
208     u32 w3 = swap32 (w0_t[3]);
209     u32 w4 = swap32 (w1_t[0]);
210     u32 w5 = swap32 (w1_t[1]);
211     u32 w6 = swap32 (w1_t[2]);
212     u32 w7 = swap32 (w1_t[3]);
213     u32 w8 = swap32 (w2_t[0]);
214     u32 w9 = swap32 (w2_t[1]);
215     u32 wa = swap32 (w2_t[2]);
216     u32 wb = swap32 (w2_t[3]);
217     u32 wc = swap32 (w3_t[0]);
218     u32 wd = swap32 (w3_t[1]);
219     u32 we = 0;
220     u32 wf = pw_salt_len * 8;
221
222     /**
223      * sha1
224      */
225
226     u32 a = SHA1M_A;
227     u32 b = SHA1M_B;
228     u32 c = SHA1M_C;
229     u32 d = SHA1M_D;
230     u32 e = SHA1M_E;
231
232     #undef K
233     #define K SHA1C00
234
235     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0);
236     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1);
237     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2);
238     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3);
239     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4);
240     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5);
241     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6);
242     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7);
243     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8);
244     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9);
245     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa);
246     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb);
247     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc);
248     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd);
249     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we);
250     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf);
251     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0);
252     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1);
253     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2);
254     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3);
255
256     #undef K
257     #define K SHA1C01
258
259     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4);
260     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5);
261     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6);
262     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7);
263     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8);
264     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9);
265     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa);
266     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb);
267     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc);
268     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd);
269     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we);
270     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf);
271     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0);
272     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1);
273     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2);
274     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3);
275     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4);
276     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5);
277     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6);
278     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7);
279
280     #undef K
281     #define K SHA1C02
282
283     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8);
284     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9);
285     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa);
286     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb);
287     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc);
288     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd);
289     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we);
290     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf);
291     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0);
292     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1);
293     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2);
294     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3);
295     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4);
296     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5);
297     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6);
298     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7);
299     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8);
300     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9);
301     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa);
302     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb);
303
304     #undef K
305     #define K SHA1C03
306
307     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc);
308     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd);
309     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we);
310     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf);
311     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0);
312     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1);
313     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2);
314     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3);
315     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4);
316     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5);
317     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6);
318     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7);
319     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8);
320     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9);
321     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa);
322     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb);
323     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc);
324     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd);
325     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we);
326     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf);
327
328     const u32 r0 = d;
329     const u32 r1 = e;
330     const u32 r2 = c;
331     const u32 r3 = b;
332
333     #include COMPARE_M
334   }
335 }
336
337 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m04900_m08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
338 {
339 }
340
341 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m04900_m16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
342 {
343 }
344
345 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m04900_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)
346 {
347   /**
348    * modifier
349    */
350
351   const u32 lid = get_local_id (0);
352
353   /**
354    * base
355    */
356
357   const u32 gid = get_global_id (0);
358
359   if (gid >= gid_max) return;
360
361   u32 pw_buf0[4];
362
363   pw_buf0[0] = pws[gid].i[ 0];
364   pw_buf0[1] = pws[gid].i[ 1];
365   pw_buf0[2] = pws[gid].i[ 2];
366   pw_buf0[3] = pws[gid].i[ 3];
367
368   u32 pw_buf1[4];
369
370   pw_buf1[0] = pws[gid].i[ 4];
371   pw_buf1[1] = pws[gid].i[ 5];
372   pw_buf1[2] = pws[gid].i[ 6];
373   pw_buf1[3] = pws[gid].i[ 7];
374
375   const u32 pw_len = pws[gid].pw_len;
376
377   /**
378    * salt
379    */
380
381   u32 salt_buf0[4];
382
383   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
384   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
385   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
386   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
387
388   u32 salt_buf1[4];
389
390   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
391   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
392   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
393   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
394
395   u32 salt_buf2[4];
396
397   salt_buf2[0] = 0;
398   salt_buf2[1] = 0;
399   salt_buf2[2] = 0;
400   salt_buf2[3] = 0;
401
402   u32 salt_buf3[4];
403
404   salt_buf3[0] = 0;
405   salt_buf3[1] = 0;
406   salt_buf3[2] = 0;
407   salt_buf3[3] = 0;
408
409   const u32 salt_len = salt_bufs[salt_pos].salt_len;
410
411   /**
412    * digest
413    */
414
415   const u32 search[4] =
416   {
417     digests_buf[digests_offset].digest_buf[DGST_R0],
418     digests_buf[digests_offset].digest_buf[DGST_R1],
419     digests_buf[digests_offset].digest_buf[DGST_R2],
420     digests_buf[digests_offset].digest_buf[DGST_R3]
421   };
422
423   /**
424    * reverse
425    */
426
427   const u32 e_rev = rotl32 (search[1], 2u);
428
429   /**
430    * loop
431    */
432
433   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
434   {
435     u32 w0_t[4];
436
437     w0_t[0] = pw_buf0[0];
438     w0_t[1] = pw_buf0[1];
439     w0_t[2] = pw_buf0[2];
440     w0_t[3] = pw_buf0[3];
441
442     u32 w1_t[4];
443
444     w1_t[0] = pw_buf1[0];
445     w1_t[1] = pw_buf1[1];
446     w1_t[2] = pw_buf1[2];
447     w1_t[3] = pw_buf1[3];
448
449     u32 w2_t[4];
450
451     w2_t[0] = 0;
452     w2_t[1] = 0;
453     w2_t[2] = 0;
454     w2_t[3] = 0;
455
456     u32 w3_t[4];
457
458     w3_t[0] = 0;
459     w3_t[1] = 0;
460     w3_t[2] = 0;
461     w3_t[3] = 0;
462
463     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0_t, w1_t, pw_len);
464
465     /**
466      * prepend salt
467      */
468
469     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
470
471     w0_t[0] |= salt_buf0[0];
472     w0_t[1] |= salt_buf0[1];
473     w0_t[2] |= salt_buf0[2];
474     w0_t[3] |= salt_buf0[3];
475     w1_t[0] |= salt_buf1[0];
476     w1_t[1] |= salt_buf1[1];
477     w1_t[2] |= salt_buf1[2];
478     w1_t[3] |= salt_buf1[3];
479     w2_t[0] |= salt_buf2[0];
480     w2_t[1] |= salt_buf2[1];
481     w2_t[2] |= salt_buf2[2];
482     w2_t[3] |= salt_buf2[3];
483     w3_t[0] |= salt_buf3[0];
484     w3_t[1] |= salt_buf3[1];
485     w3_t[2] |= salt_buf3[2];
486     w3_t[3] |= salt_buf3[3];
487
488     /**
489      * append salt
490      */
491
492     u32 s0[4];
493
494     s0[0] = salt_buf0[0];
495     s0[1] = salt_buf0[1];
496     s0[2] = salt_buf0[2];
497     s0[3] = salt_buf0[3];
498
499     u32 s1[4];
500
501     s1[0] = salt_buf1[0];
502     s1[1] = salt_buf1[1];
503     s1[2] = salt_buf1[2];
504     s1[3] = salt_buf1[3];
505
506     u32 s2[4];
507
508     s2[0] = 0;
509     s2[1] = 0;
510     s2[2] = 0;
511     s2[3] = 0;
512
513     u32 s3[4];
514
515     s3[0] = 0;
516     s3[1] = 0;
517     s3[2] = 0;
518     s3[3] = 0;
519
520     switch_buffer_by_offset (s0, s1, s2, s3, salt_len + out_len);
521
522     w0_t[0] |= s0[0];
523     w0_t[1] |= s0[1];
524     w0_t[2] |= s0[2];
525     w0_t[3] |= s0[3];
526     w1_t[0] |= s1[0];
527     w1_t[1] |= s1[1];
528     w1_t[2] |= s1[2];
529     w1_t[3] |= s1[3];
530     w2_t[0] |= s2[0];
531     w2_t[1] |= s2[1];
532     w2_t[2] |= s2[2];
533     w2_t[3] |= s2[3];
534     w3_t[0] |= s3[0];
535     w3_t[1] |= s3[1];
536     w3_t[2] |= s3[2];
537     w3_t[3] |= s3[3];
538
539     const u32 pw_salt_len = salt_len + out_len + salt_len;
540
541     append_0x80_4x4 (w0_t, w1_t, w2_t, w3_t, pw_salt_len);
542
543     u32 w0 = swap32 (w0_t[0]);
544     u32 w1 = swap32 (w0_t[1]);
545     u32 w2 = swap32 (w0_t[2]);
546     u32 w3 = swap32 (w0_t[3]);
547     u32 w4 = swap32 (w1_t[0]);
548     u32 w5 = swap32 (w1_t[1]);
549     u32 w6 = swap32 (w1_t[2]);
550     u32 w7 = swap32 (w1_t[3]);
551     u32 w8 = swap32 (w2_t[0]);
552     u32 w9 = swap32 (w2_t[1]);
553     u32 wa = swap32 (w2_t[2]);
554     u32 wb = swap32 (w2_t[3]);
555     u32 wc = swap32 (w3_t[0]);
556     u32 wd = swap32 (w3_t[1]);
557     u32 we = 0;
558     u32 wf = pw_salt_len * 8;
559
560     /**
561      * sha1
562      */
563
564     u32 a = SHA1M_A;
565     u32 b = SHA1M_B;
566     u32 c = SHA1M_C;
567     u32 d = SHA1M_D;
568     u32 e = SHA1M_E;
569
570     #undef K
571     #define K SHA1C00
572
573     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0);
574     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1);
575     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2);
576     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3);
577     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4);
578     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5);
579     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6);
580     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7);
581     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8);
582     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9);
583     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa);
584     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb);
585     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc);
586     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd);
587     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we);
588     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf);
589     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0);
590     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1);
591     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2);
592     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3);
593
594     #undef K
595     #define K SHA1C01
596
597     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4);
598     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5);
599     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6);
600     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7);
601     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8);
602     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9);
603     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa);
604     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb);
605     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc);
606     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd);
607     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we);
608     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf);
609     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0);
610     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1);
611     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2);
612     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3);
613     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4);
614     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5);
615     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6);
616     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7);
617
618     #undef K
619     #define K SHA1C02
620
621     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8);
622     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9);
623     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa);
624     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb);
625     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc);
626     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd);
627     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we);
628     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf);
629     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0);
630     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1);
631     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2);
632     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3);
633     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4);
634     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5);
635     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6);
636     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7);
637     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8);
638     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9);
639     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa);
640     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb);
641
642     #undef K
643     #define K SHA1C03
644
645     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc);
646     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd);
647     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we);
648     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf);
649     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0);
650     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1);
651     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2);
652     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3);
653     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4);
654     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5);
655     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6);
656     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7);
657     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8);
658     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9);
659     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa);
660     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb);
661
662     if (allx (e != e_rev)) continue;
663
664     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc);
665     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd);
666     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we);
667     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf);
668
669     const u32 r0 = d;
670     const u32 r1 = e;
671     const u32 r2 = c;
672     const u32 r3 = b;
673
674     #include COMPARE_S
675   }
676 }
677
678 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m04900_s08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
679 {
680 }
681
682 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m04900_s16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
683 {
684 }