Converted to new SIMD: -m 4900 -a 0
[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 #define NEW_SIMD_CODE
9
10 #include "include/constants.h"
11 #include "include/kernel_vendor.h"
12
13 #define DGST_R0 3
14 #define DGST_R1 4
15 #define DGST_R2 2
16 #define DGST_R3 1
17
18 #include "include/kernel_functions.c"
19 #include "OpenCL/types_ocl.c"
20 #include "OpenCL/common.c"
21 #include "include/rp_kernel.h"
22 #include "OpenCL/rp.c"
23 #include "OpenCL/simd.c"
24
25 __kernel void m04900_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 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 += VECT_SIZE)
96   {
97     u32x 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     u32x 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     u32x 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     u32x 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_le (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     u32x 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     u32x 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     u32x s2[4];
169
170     s2[0] = 0;
171     s2[1] = 0;
172     s2[2] = 0;
173     s2[3] = 0;
174
175     u32x 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_le (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     u32x w0 = swap32 (w0_t[0]);
206     u32x w1 = swap32 (w0_t[1]);
207     u32x w2 = swap32 (w0_t[2]);
208     u32x w3 = swap32 (w0_t[3]);
209     u32x w4 = swap32 (w1_t[0]);
210     u32x w5 = swap32 (w1_t[1]);
211     u32x w6 = swap32 (w1_t[2]);
212     u32x w7 = swap32 (w1_t[3]);
213     u32x w8 = swap32 (w2_t[0]);
214     u32x w9 = swap32 (w2_t[1]);
215     u32x wa = swap32 (w2_t[2]);
216     u32x wb = swap32 (w2_t[3]);
217     u32x wc = swap32 (w3_t[0]);
218     u32x wd = swap32 (w3_t[1]);
219     u32x we = 0;
220     u32x wf = pw_salt_len * 8;
221
222     /**
223      * sha1
224      */
225
226     u32x a = SHA1M_A;
227     u32x b = SHA1M_B;
228     u32x c = SHA1M_C;
229     u32x d = SHA1M_D;
230     u32x 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     COMPARE_M_SIMD (d, e, c, b);
329   }
330 }
331
332 __kernel void m04900_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
333 {
334 }
335
336 __kernel void m04900_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
337 {
338 }
339
340 __kernel void m04900_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
341 {
342   /**
343    * modifier
344    */
345
346   const u32 lid = get_local_id (0);
347
348   /**
349    * base
350    */
351
352   const u32 gid = get_global_id (0);
353
354   if (gid >= gid_max) return;
355
356   u32 pw_buf0[4];
357
358   pw_buf0[0] = pws[gid].i[ 0];
359   pw_buf0[1] = pws[gid].i[ 1];
360   pw_buf0[2] = pws[gid].i[ 2];
361   pw_buf0[3] = pws[gid].i[ 3];
362
363   u32 pw_buf1[4];
364
365   pw_buf1[0] = pws[gid].i[ 4];
366   pw_buf1[1] = pws[gid].i[ 5];
367   pw_buf1[2] = pws[gid].i[ 6];
368   pw_buf1[3] = pws[gid].i[ 7];
369
370   const u32 pw_len = pws[gid].pw_len;
371
372   /**
373    * salt
374    */
375
376   u32 salt_buf0[4];
377
378   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
379   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
380   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
381   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
382
383   u32 salt_buf1[4];
384
385   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
386   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
387   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
388   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
389
390   u32 salt_buf2[4];
391
392   salt_buf2[0] = 0;
393   salt_buf2[1] = 0;
394   salt_buf2[2] = 0;
395   salt_buf2[3] = 0;
396
397   u32 salt_buf3[4];
398
399   salt_buf3[0] = 0;
400   salt_buf3[1] = 0;
401   salt_buf3[2] = 0;
402   salt_buf3[3] = 0;
403
404   const u32 salt_len = salt_bufs[salt_pos].salt_len;
405
406   /**
407    * digest
408    */
409
410   const u32 search[4] =
411   {
412     digests_buf[digests_offset].digest_buf[DGST_R0],
413     digests_buf[digests_offset].digest_buf[DGST_R1],
414     digests_buf[digests_offset].digest_buf[DGST_R2],
415     digests_buf[digests_offset].digest_buf[DGST_R3]
416   };
417
418   /**
419    * reverse
420    */
421
422   const u32 e_rev = rotl32_S (search[1], 2u);
423
424   /**
425    * loop
426    */
427
428   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
429   {
430     u32x w0_t[4];
431
432     w0_t[0] = pw_buf0[0];
433     w0_t[1] = pw_buf0[1];
434     w0_t[2] = pw_buf0[2];
435     w0_t[3] = pw_buf0[3];
436
437     u32x w1_t[4];
438
439     w1_t[0] = pw_buf1[0];
440     w1_t[1] = pw_buf1[1];
441     w1_t[2] = pw_buf1[2];
442     w1_t[3] = pw_buf1[3];
443
444     u32x w2_t[4];
445
446     w2_t[0] = 0;
447     w2_t[1] = 0;
448     w2_t[2] = 0;
449     w2_t[3] = 0;
450
451     u32x w3_t[4];
452
453     w3_t[0] = 0;
454     w3_t[1] = 0;
455     w3_t[2] = 0;
456     w3_t[3] = 0;
457
458     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0_t, w1_t, pw_len);
459
460     /**
461      * prepend salt
462      */
463
464     switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, salt_len);
465
466     w0_t[0] |= salt_buf0[0];
467     w0_t[1] |= salt_buf0[1];
468     w0_t[2] |= salt_buf0[2];
469     w0_t[3] |= salt_buf0[3];
470     w1_t[0] |= salt_buf1[0];
471     w1_t[1] |= salt_buf1[1];
472     w1_t[2] |= salt_buf1[2];
473     w1_t[3] |= salt_buf1[3];
474     w2_t[0] |= salt_buf2[0];
475     w2_t[1] |= salt_buf2[1];
476     w2_t[2] |= salt_buf2[2];
477     w2_t[3] |= salt_buf2[3];
478     w3_t[0] |= salt_buf3[0];
479     w3_t[1] |= salt_buf3[1];
480     w3_t[2] |= salt_buf3[2];
481     w3_t[3] |= salt_buf3[3];
482
483     /**
484      * append salt
485      */
486
487     u32x s0[4];
488
489     s0[0] = salt_buf0[0];
490     s0[1] = salt_buf0[1];
491     s0[2] = salt_buf0[2];
492     s0[3] = salt_buf0[3];
493
494     u32x s1[4];
495
496     s1[0] = salt_buf1[0];
497     s1[1] = salt_buf1[1];
498     s1[2] = salt_buf1[2];
499     s1[3] = salt_buf1[3];
500
501     u32x s2[4];
502
503     s2[0] = 0;
504     s2[1] = 0;
505     s2[2] = 0;
506     s2[3] = 0;
507
508     u32x s3[4];
509
510     s3[0] = 0;
511     s3[1] = 0;
512     s3[2] = 0;
513     s3[3] = 0;
514
515     switch_buffer_by_offset_le (s0, s1, s2, s3, salt_len + out_len);
516
517     w0_t[0] |= s0[0];
518     w0_t[1] |= s0[1];
519     w0_t[2] |= s0[2];
520     w0_t[3] |= s0[3];
521     w1_t[0] |= s1[0];
522     w1_t[1] |= s1[1];
523     w1_t[2] |= s1[2];
524     w1_t[3] |= s1[3];
525     w2_t[0] |= s2[0];
526     w2_t[1] |= s2[1];
527     w2_t[2] |= s2[2];
528     w2_t[3] |= s2[3];
529     w3_t[0] |= s3[0];
530     w3_t[1] |= s3[1];
531     w3_t[2] |= s3[2];
532     w3_t[3] |= s3[3];
533
534     const u32 pw_salt_len = salt_len + out_len + salt_len;
535
536     append_0x80_4x4 (w0_t, w1_t, w2_t, w3_t, pw_salt_len);
537
538     u32x w0 = swap32 (w0_t[0]);
539     u32x w1 = swap32 (w0_t[1]);
540     u32x w2 = swap32 (w0_t[2]);
541     u32x w3 = swap32 (w0_t[3]);
542     u32x w4 = swap32 (w1_t[0]);
543     u32x w5 = swap32 (w1_t[1]);
544     u32x w6 = swap32 (w1_t[2]);
545     u32x w7 = swap32 (w1_t[3]);
546     u32x w8 = swap32 (w2_t[0]);
547     u32x w9 = swap32 (w2_t[1]);
548     u32x wa = swap32 (w2_t[2]);
549     u32x wb = swap32 (w2_t[3]);
550     u32x wc = swap32 (w3_t[0]);
551     u32x wd = swap32 (w3_t[1]);
552     u32x we = 0;
553     u32x wf = pw_salt_len * 8;
554
555     /**
556      * sha1
557      */
558
559     u32x a = SHA1M_A;
560     u32x b = SHA1M_B;
561     u32x c = SHA1M_C;
562     u32x d = SHA1M_D;
563     u32x e = SHA1M_E;
564
565     #undef K
566     #define K SHA1C00
567
568     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0);
569     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1);
570     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2);
571     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3);
572     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4);
573     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5);
574     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6);
575     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7);
576     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8);
577     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9);
578     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa);
579     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb);
580     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc);
581     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd);
582     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we);
583     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf);
584     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0);
585     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1);
586     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2);
587     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3);
588
589     #undef K
590     #define K SHA1C01
591
592     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4);
593     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5);
594     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6);
595     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7);
596     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8);
597     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9);
598     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa);
599     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb);
600     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc);
601     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd);
602     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we);
603     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf);
604     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0);
605     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1);
606     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2);
607     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3);
608     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4);
609     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5);
610     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6);
611     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7);
612
613     #undef K
614     #define K SHA1C02
615
616     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8);
617     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9);
618     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa);
619     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb);
620     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc);
621     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd);
622     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we);
623     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf);
624     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0);
625     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1);
626     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2);
627     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3);
628     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4);
629     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5);
630     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6);
631     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7);
632     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8);
633     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9);
634     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa);
635     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb);
636
637     #undef K
638     #define K SHA1C03
639
640     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc);
641     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd);
642     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we);
643     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf);
644     w0 = rotl32 ((wd ^ w8 ^ w2 ^ w0), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0);
645     w1 = rotl32 ((we ^ w9 ^ w3 ^ w1), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1);
646     w2 = rotl32 ((wf ^ wa ^ w4 ^ w2), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2);
647     w3 = rotl32 ((w0 ^ wb ^ w5 ^ w3), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3);
648     w4 = rotl32 ((w1 ^ wc ^ w6 ^ w4), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4);
649     w5 = rotl32 ((w2 ^ wd ^ w7 ^ w5), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5);
650     w6 = rotl32 ((w3 ^ we ^ w8 ^ w6), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6);
651     w7 = rotl32 ((w4 ^ wf ^ w9 ^ w7), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7);
652     w8 = rotl32 ((w5 ^ w0 ^ wa ^ w8), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8);
653     w9 = rotl32 ((w6 ^ w1 ^ wb ^ w9), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9);
654     wa = rotl32 ((w7 ^ w2 ^ wc ^ wa), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa);
655     wb = rotl32 ((w8 ^ w3 ^ wd ^ wb), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb);
656
657     if (MATCHES_NONE_VS (e, e_rev)) continue;
658
659     wc = rotl32 ((w9 ^ w4 ^ we ^ wc), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc);
660     wd = rotl32 ((wa ^ w5 ^ wf ^ wd), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd);
661     we = rotl32 ((wb ^ w6 ^ w0 ^ we), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we);
662     wf = rotl32 ((wc ^ w7 ^ w1 ^ wf), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf);
663
664     COMPARE_S_SIMD (d, e, c, b);
665   }
666 }
667
668 __kernel void m04900_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
669 {
670 }
671
672 __kernel void m04900_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
673 {
674 }