Initial commit
[hashcat.git] / amd / m00100_a1.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
32 #ifdef  VECT_SIZE1
33 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
34 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
35 #endif
36
37 #ifdef  VECT_SIZE2
38 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
39 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
40 #endif
41
42 #ifdef  VECT_SIZE4
43 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
44 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
45 #endif
46
47 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00100_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
48 {
49   /**
50    * modifier
51    */
52
53   const u32 lid = get_local_id (0);
54
55   /**
56    * base
57    */
58
59   const u32 gid = get_global_id (0);
60
61   if (gid >= gid_max) return;
62
63   u32x wordl0[4];
64
65   wordl0[0] = pws[gid].i[ 0];
66   wordl0[1] = pws[gid].i[ 1];
67   wordl0[2] = pws[gid].i[ 2];
68   wordl0[3] = pws[gid].i[ 3];
69
70   u32x wordl1[4];
71
72   wordl1[0] = pws[gid].i[ 4];
73   wordl1[1] = pws[gid].i[ 5];
74   wordl1[2] = pws[gid].i[ 6];
75   wordl1[3] = pws[gid].i[ 7];
76
77   u32x wordl2[4];
78
79   wordl2[0] = 0;
80   wordl2[1] = 0;
81   wordl2[2] = 0;
82   wordl2[3] = 0;
83
84   u32x wordl3[4];
85
86   wordl3[0] = 0;
87   wordl3[1] = 0;
88   wordl3[2] = 0;
89   wordl3[3] = 0;
90
91   const u32 pw_l_len = pws[gid].pw_len;
92
93   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
94   {
95     append_0x80_2 (wordl0, wordl1, pw_l_len);
96
97     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
98   }
99
100   /**
101    * loop
102    */
103
104   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
105   {
106     const u32 pw_r_len = combs_buf[il_pos].pw_len;
107
108     const u32 pw_len = pw_l_len + pw_r_len;
109
110     u32 wordr0[4];
111
112     wordr0[0] = combs_buf[il_pos].i[0];
113     wordr0[1] = combs_buf[il_pos].i[1];
114     wordr0[2] = combs_buf[il_pos].i[2];
115     wordr0[3] = combs_buf[il_pos].i[3];
116
117     u32 wordr1[4];
118
119     wordr1[0] = combs_buf[il_pos].i[4];
120     wordr1[1] = combs_buf[il_pos].i[5];
121     wordr1[2] = combs_buf[il_pos].i[6];
122     wordr1[3] = combs_buf[il_pos].i[7];
123
124     u32 wordr2[4];
125
126     wordr2[0] = 0;
127     wordr2[1] = 0;
128     wordr2[2] = 0;
129     wordr2[3] = 0;
130
131     u32 wordr3[4];
132
133     wordr3[0] = 0;
134     wordr3[1] = 0;
135     wordr3[2] = 0;
136     wordr3[3] = 0;
137
138     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
139     {
140       append_0x80_2 (wordr0, wordr1, pw_r_len);
141
142       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
143     }
144
145     u32x w0[4];
146
147     w0[0] = wordl0[0] | wordr0[0];
148     w0[1] = wordl0[1] | wordr0[1];
149     w0[2] = wordl0[2] | wordr0[2];
150     w0[3] = wordl0[3] | wordr0[3];
151
152     u32x w1[4];
153
154     w1[0] = wordl1[0] | wordr1[0];
155     w1[1] = wordl1[1] | wordr1[1];
156     w1[2] = wordl1[2] | wordr1[2];
157     w1[3] = wordl1[3] | wordr1[3];
158
159     u32x w2[4];
160
161     w2[0] = wordl2[0] | wordr2[0];
162     w2[1] = wordl2[1] | wordr2[1];
163     w2[2] = wordl2[2] | wordr2[2];
164     w2[3] = wordl2[3] | wordr2[3];
165
166     u32x w3[4];
167
168     w3[0] = wordl3[0] | wordr3[0];
169     w3[1] = wordl3[1] | wordr3[1];
170     w3[2] = 0;
171     w3[3] = 0;
172
173     /**
174      * sha1
175      */
176
177     u32x w0_t = swap_workaround (w0[0]);
178     u32x w1_t = swap_workaround (w0[1]);
179     u32x w2_t = swap_workaround (w0[2]);
180     u32x w3_t = swap_workaround (w0[3]);
181     u32x w4_t = swap_workaround (w1[0]);
182     u32x w5_t = swap_workaround (w1[1]);
183     u32x w6_t = swap_workaround (w1[2]);
184     u32x w7_t = swap_workaround (w1[3]);
185     u32x w8_t = swap_workaround (w2[0]);
186     u32x w9_t = swap_workaround (w2[1]);
187     u32x wa_t = swap_workaround (w2[2]);
188     u32x wb_t = swap_workaround (w2[3]);
189     u32x wc_t = swap_workaround (w3[0]);
190     u32x wd_t = swap_workaround (w3[1]);
191     u32x we_t = 0;
192     u32x wf_t = pw_len * 8;
193
194     u32x a = SHA1M_A;
195     u32x b = SHA1M_B;
196     u32x c = SHA1M_C;
197     u32x d = SHA1M_D;
198     u32x e = SHA1M_E;
199
200     #undef K
201     #define K SHA1C00
202
203     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
204     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
205     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
206     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
207     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
208     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
209     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
210     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
211     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
212     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
213     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
214     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
215     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
216     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
217     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
218     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
219     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
220     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
221     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
222     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
223
224     #undef K
225     #define K SHA1C01
226
227     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
228     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
229     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
230     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
231     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
232     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
233     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
234     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
235     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
236     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
237     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
238     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
239     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
240     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
241     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
242     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
243     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
244     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
245     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
246     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
247
248     #undef K
249     #define K SHA1C02
250
251     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
252     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
253     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
254     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
255     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
256     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
257     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
258     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
259     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
260     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
261     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
262     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
263     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
264     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
265     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
266     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
267     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
268     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
269     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
270     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
271
272     #undef K
273     #define K SHA1C03
274
275     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
276     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
277     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
278     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
279     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
280     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
281     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
282     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
283     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
284     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
285     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
286     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
287     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
288     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
289     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
290     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
291     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
292     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
293     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
294     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
295
296
297     const u32x r0 = d;
298     const u32x r1 = e;
299     const u32x r2 = c;
300     const u32x r3 = b;
301
302     #include VECT_COMPARE_M
303   }
304 }
305
306 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00100_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)
307 {
308 }
309
310 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00100_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)
311 {
312 }
313
314 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00100_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 combs_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   u32x wordl0[4];
331
332   wordl0[0] = pws[gid].i[ 0];
333   wordl0[1] = pws[gid].i[ 1];
334   wordl0[2] = pws[gid].i[ 2];
335   wordl0[3] = pws[gid].i[ 3];
336
337   u32x wordl1[4];
338
339   wordl1[0] = pws[gid].i[ 4];
340   wordl1[1] = pws[gid].i[ 5];
341   wordl1[2] = pws[gid].i[ 6];
342   wordl1[3] = pws[gid].i[ 7];
343
344   u32x wordl2[4];
345
346   wordl2[0] = 0;
347   wordl2[1] = 0;
348   wordl2[2] = 0;
349   wordl2[3] = 0;
350
351   u32x wordl3[4];
352
353   wordl3[0] = 0;
354   wordl3[1] = 0;
355   wordl3[2] = 0;
356   wordl3[3] = 0;
357
358   const u32 pw_l_len = pws[gid].pw_len;
359
360   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
361   {
362     append_0x80_2 (wordl0, wordl1, pw_l_len);
363
364     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
365   }
366
367   /**
368    * digest
369    */
370
371   const u32 search[4] =
372   {
373     digests_buf[digests_offset].digest_buf[DGST_R0],
374     digests_buf[digests_offset].digest_buf[DGST_R1],
375     digests_buf[digests_offset].digest_buf[DGST_R2],
376     digests_buf[digests_offset].digest_buf[DGST_R3]
377   };
378
379   /**
380    * reverse
381    */
382
383   const u32 e_rev = rotl32 (search[1], 2u);
384
385   /**
386    * loop
387    */
388
389   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
390   {
391     const u32 pw_r_len = combs_buf[il_pos].pw_len;
392
393     const u32 pw_len = pw_l_len + pw_r_len;
394
395     u32 wordr0[4];
396
397     wordr0[0] = combs_buf[il_pos].i[0];
398     wordr0[1] = combs_buf[il_pos].i[1];
399     wordr0[2] = combs_buf[il_pos].i[2];
400     wordr0[3] = combs_buf[il_pos].i[3];
401
402     u32 wordr1[4];
403
404     wordr1[0] = combs_buf[il_pos].i[4];
405     wordr1[1] = combs_buf[il_pos].i[5];
406     wordr1[2] = combs_buf[il_pos].i[6];
407     wordr1[3] = combs_buf[il_pos].i[7];
408
409     u32 wordr2[4];
410
411     wordr2[0] = 0;
412     wordr2[1] = 0;
413     wordr2[2] = 0;
414     wordr2[3] = 0;
415
416     u32 wordr3[4];
417
418     wordr3[0] = 0;
419     wordr3[1] = 0;
420     wordr3[2] = 0;
421     wordr3[3] = 0;
422
423     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
424     {
425       append_0x80_2 (wordr0, wordr1, pw_r_len);
426
427       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
428     }
429
430     u32x w0[4];
431
432     w0[0] = wordl0[0] | wordr0[0];
433     w0[1] = wordl0[1] | wordr0[1];
434     w0[2] = wordl0[2] | wordr0[2];
435     w0[3] = wordl0[3] | wordr0[3];
436
437     u32x w1[4];
438
439     w1[0] = wordl1[0] | wordr1[0];
440     w1[1] = wordl1[1] | wordr1[1];
441     w1[2] = wordl1[2] | wordr1[2];
442     w1[3] = wordl1[3] | wordr1[3];
443
444     u32x w2[4];
445
446     w2[0] = wordl2[0] | wordr2[0];
447     w2[1] = wordl2[1] | wordr2[1];
448     w2[2] = wordl2[2] | wordr2[2];
449     w2[3] = wordl2[3] | wordr2[3];
450
451     u32x w3[4];
452
453     w3[0] = wordl3[0] | wordr3[0];
454     w3[1] = wordl3[1] | wordr3[1];
455     w3[2] = 0;
456     w3[3] = 0;
457
458     /**
459      * sha1
460      */
461
462     u32x w0_t = swap_workaround (w0[0]);
463     u32x w1_t = swap_workaround (w0[1]);
464     u32x w2_t = swap_workaround (w0[2]);
465     u32x w3_t = swap_workaround (w0[3]);
466     u32x w4_t = swap_workaround (w1[0]);
467     u32x w5_t = swap_workaround (w1[1]);
468     u32x w6_t = swap_workaround (w1[2]);
469     u32x w7_t = swap_workaround (w1[3]);
470     u32x w8_t = swap_workaround (w2[0]);
471     u32x w9_t = swap_workaround (w2[1]);
472     u32x wa_t = swap_workaround (w2[2]);
473     u32x wb_t = swap_workaround (w2[3]);
474     u32x wc_t = swap_workaround (w3[0]);
475     u32x wd_t = swap_workaround (w3[1]);
476     u32x we_t = 0;
477     u32x wf_t = pw_len * 8;
478
479     u32x a = SHA1M_A;
480     u32x b = SHA1M_B;
481     u32x c = SHA1M_C;
482     u32x d = SHA1M_D;
483     u32x e = SHA1M_E;
484
485     #undef K
486     #define K SHA1C00
487
488     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
489     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
490     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
491     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
492     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
493     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
494     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
495     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
496     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
497     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
498     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
499     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
500     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
501     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
502     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
503     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
504     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
505     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
506     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
507     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
508
509     #undef K
510     #define K SHA1C01
511
512     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
513     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
514     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
515     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
516     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
517     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
518     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
519     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
520     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
521     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
522     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
523     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
524     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
525     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
526     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
527     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
528     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
529     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
530     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
531     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
532
533     #undef K
534     #define K SHA1C02
535
536     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
537     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
538     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
539     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
540     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
541     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
542     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
543     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
544     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
545     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
546     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
547     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
548     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
549     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
550     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
551     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
552     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
553     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
554     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
555     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
556
557     #undef K
558     #define K SHA1C03
559
560     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
561     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
562     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
563     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
564     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
565     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
566     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
567     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
568     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
569     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
570     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
571     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
572     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
573     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
574     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
575     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
576
577     if (allx (e != e_rev)) continue;
578
579     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
580     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
581     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
582     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
583
584
585     const u32x r0 = d;
586     const u32x r1 = e;
587     const u32x r2 = c;
588     const u32x r3 = b;
589
590     #include VECT_COMPARE_S
591   }
592 }
593
594 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00100_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)
595 {
596 }
597
598 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00100_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)
599 {
600 }