Initial commit
[hashcat.git] / amd / m00190_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 0
24 #define DGST_R1 4
25 #define DGST_R2 3
26 #define DGST_R3 2
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))) m00190_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     a += SHA1M_A;
297     e += SHA1M_E;
298     d += SHA1M_D;
299     c += SHA1M_C;
300
301     {
302       const u32x r0 = a;
303       const u32x r1 = e;
304       const u32x r2 = d;
305       const u32x r3 = c;
306
307       #include VECT_COMPARE_M
308     }
309
310     a &= 0x00000fff;
311
312     {
313       const u32x r0 = a;
314       const u32x r1 = e;
315       const u32x r2 = d;
316       const u32x r3 = c;
317
318       #include VECT_COMPARE_M
319     }
320   }
321 }
322
323 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00190_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)
324 {
325 }
326
327 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00190_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)
328 {
329 }
330
331 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00190_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)
332 {
333   /**
334    * modifier
335    */
336
337   const u32 lid = get_local_id (0);
338
339   /**
340    * base
341    */
342
343   const u32 gid = get_global_id (0);
344
345   if (gid >= gid_max) return;
346
347   u32x wordl0[4];
348
349   wordl0[0] = pws[gid].i[ 0];
350   wordl0[1] = pws[gid].i[ 1];
351   wordl0[2] = pws[gid].i[ 2];
352   wordl0[3] = pws[gid].i[ 3];
353
354   u32x wordl1[4];
355
356   wordl1[0] = pws[gid].i[ 4];
357   wordl1[1] = pws[gid].i[ 5];
358   wordl1[2] = pws[gid].i[ 6];
359   wordl1[3] = pws[gid].i[ 7];
360
361   u32x wordl2[4];
362
363   wordl2[0] = 0;
364   wordl2[1] = 0;
365   wordl2[2] = 0;
366   wordl2[3] = 0;
367
368   u32x wordl3[4];
369
370   wordl3[0] = 0;
371   wordl3[1] = 0;
372   wordl3[2] = 0;
373   wordl3[3] = 0;
374
375   const u32 pw_l_len = pws[gid].pw_len;
376
377   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
378   {
379     append_0x80_2 (wordl0, wordl1, pw_l_len);
380
381     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
382   }
383
384   /**
385    * digest
386    */
387
388   const u32 search[4] =
389   {
390     digests_buf[digests_offset].digest_buf[DGST_R0],
391     digests_buf[digests_offset].digest_buf[DGST_R1],
392     digests_buf[digests_offset].digest_buf[DGST_R2],
393     digests_buf[digests_offset].digest_buf[DGST_R3]
394   };
395
396   /**
397    * loop
398    */
399
400   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
401   {
402     const u32 pw_r_len = combs_buf[il_pos].pw_len;
403
404     const u32 pw_len = pw_l_len + pw_r_len;
405
406     u32 wordr0[4];
407
408     wordr0[0] = combs_buf[il_pos].i[0];
409     wordr0[1] = combs_buf[il_pos].i[1];
410     wordr0[2] = combs_buf[il_pos].i[2];
411     wordr0[3] = combs_buf[il_pos].i[3];
412
413     u32 wordr1[4];
414
415     wordr1[0] = combs_buf[il_pos].i[4];
416     wordr1[1] = combs_buf[il_pos].i[5];
417     wordr1[2] = combs_buf[il_pos].i[6];
418     wordr1[3] = combs_buf[il_pos].i[7];
419
420     u32 wordr2[4];
421
422     wordr2[0] = 0;
423     wordr2[1] = 0;
424     wordr2[2] = 0;
425     wordr2[3] = 0;
426
427     u32 wordr3[4];
428
429     wordr3[0] = 0;
430     wordr3[1] = 0;
431     wordr3[2] = 0;
432     wordr3[3] = 0;
433
434     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
435     {
436       append_0x80_2 (wordr0, wordr1, pw_r_len);
437
438       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
439     }
440
441     u32x w0[4];
442
443     w0[0] = wordl0[0] | wordr0[0];
444     w0[1] = wordl0[1] | wordr0[1];
445     w0[2] = wordl0[2] | wordr0[2];
446     w0[3] = wordl0[3] | wordr0[3];
447
448     u32x w1[4];
449
450     w1[0] = wordl1[0] | wordr1[0];
451     w1[1] = wordl1[1] | wordr1[1];
452     w1[2] = wordl1[2] | wordr1[2];
453     w1[3] = wordl1[3] | wordr1[3];
454
455     u32x w2[4];
456
457     w2[0] = wordl2[0] | wordr2[0];
458     w2[1] = wordl2[1] | wordr2[1];
459     w2[2] = wordl2[2] | wordr2[2];
460     w2[3] = wordl2[3] | wordr2[3];
461
462     u32x w3[4];
463
464     w3[0] = wordl3[0] | wordr3[0];
465     w3[1] = wordl3[1] | wordr3[1];
466     w3[2] = 0;
467     w3[3] = 0;
468
469     /**
470      * sha1
471      */
472
473     u32x w0_t = swap_workaround (w0[0]);
474     u32x w1_t = swap_workaround (w0[1]);
475     u32x w2_t = swap_workaround (w0[2]);
476     u32x w3_t = swap_workaround (w0[3]);
477     u32x w4_t = swap_workaround (w1[0]);
478     u32x w5_t = swap_workaround (w1[1]);
479     u32x w6_t = swap_workaround (w1[2]);
480     u32x w7_t = swap_workaround (w1[3]);
481     u32x w8_t = swap_workaround (w2[0]);
482     u32x w9_t = swap_workaround (w2[1]);
483     u32x wa_t = swap_workaround (w2[2]);
484     u32x wb_t = swap_workaround (w2[3]);
485     u32x wc_t = swap_workaround (w3[0]);
486     u32x wd_t = swap_workaround (w3[1]);
487     u32x we_t = 0;
488     u32x wf_t = pw_len * 8;
489
490     u32x a = SHA1M_A;
491     u32x b = SHA1M_B;
492     u32x c = SHA1M_C;
493     u32x d = SHA1M_D;
494     u32x e = SHA1M_E;
495
496     #undef K
497     #define K SHA1C00
498
499     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
500     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
501     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
502     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
503     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
504     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
505     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
506     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
507     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
508     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
509     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
510     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
511     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
512     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
513     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
514     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
515     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
516     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
517     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
518     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
519
520     #undef K
521     #define K SHA1C01
522
523     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
524     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
525     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
526     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
527     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
528     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
529     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
530     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
531     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
532     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
533     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
534     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
535     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
536     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
537     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
538     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
539     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
540     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
541     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
542     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
543
544     #undef K
545     #define K SHA1C02
546
547     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
548     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
549     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
550     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
551     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
552     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
553     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
554     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
555     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
556     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
557     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
558     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
559     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
560     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
561     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
562     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
563     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
564     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
565     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
566     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
567
568     #undef K
569     #define K SHA1C03
570
571     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
572     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
573     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
574     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
575     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
576     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
577     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
578     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
579     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
580     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
581     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
582     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
583     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
584     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
585     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
586     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
587     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
588     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
589     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
590     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
591
592     a += SHA1M_A;
593     e += SHA1M_E;
594     d += SHA1M_D;
595     c += SHA1M_C;
596
597     {
598       const u32x r0 = a;
599       const u32x r1 = e;
600       const u32x r2 = d;
601       const u32x r3 = c;
602
603       #include VECT_COMPARE_S
604     }
605
606     a &= 0x00000fff;
607
608     {
609       const u32x r0 = a;
610       const u32x r1 = e;
611       const u32x r2 = d;
612       const u32x r3 = c;
613
614       #include VECT_COMPARE_S
615     }
616   }
617 }
618
619 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00190_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)
620 {
621 }
622
623 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00190_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)
624 {
625 }