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