Converted _a3 kernels, use SIMD for CPU and GPU
[hashcat.git] / OpenCL / m04400_a1.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_SHA1_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #define DGST_R0 0
12 #define DGST_R1 3
13 #define DGST_R2 2
14 #define DGST_R3 1
15
16 #include "include/kernel_functions.c"
17 #include "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19
20 #define COMPARE_S "OpenCL/check_single_comp4.c"
21 #define COMPARE_M "OpenCL/check_multi_comp4.c"
22
23 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
24
25 __kernel void m04400_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
26 {
27   /**
28    * base
29    */
30
31   const u32 gid = get_global_id (0);
32   const u32 lid = get_local_id (0);
33   const u32 lsz = get_local_size (0);
34
35   /**
36    * bin2asc table
37    */
38
39   __local u32 l_bin2asc[256];
40
41   for (u32 i = lid; i < 256; i += lsz)
42   {
43     const u32 i0 = (i >> 0) & 15;
44     const u32 i1 = (i >> 4) & 15;
45
46     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
47                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
48   }
49
50   barrier (CLK_LOCAL_MEM_FENCE);
51
52   if (gid >= gid_max) return;
53
54   /**
55    * base
56    */
57
58   u32 wordl0[4];
59
60   wordl0[0] = pws[gid].i[ 0];
61   wordl0[1] = pws[gid].i[ 1];
62   wordl0[2] = pws[gid].i[ 2];
63   wordl0[3] = pws[gid].i[ 3];
64
65   u32 wordl1[4];
66
67   wordl1[0] = pws[gid].i[ 4];
68   wordl1[1] = pws[gid].i[ 5];
69   wordl1[2] = pws[gid].i[ 6];
70   wordl1[3] = pws[gid].i[ 7];
71
72   u32 wordl2[4];
73
74   wordl2[0] = 0;
75   wordl2[1] = 0;
76   wordl2[2] = 0;
77   wordl2[3] = 0;
78
79   u32 wordl3[4];
80
81   wordl3[0] = 0;
82   wordl3[1] = 0;
83   wordl3[2] = 0;
84   wordl3[3] = 0;
85
86   const u32 pw_l_len = pws[gid].pw_len;
87
88   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
89   {
90     append_0x80_2x4 (wordl0, wordl1, pw_l_len);
91
92     switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
93   }
94
95   /**
96    * loop
97    */
98
99   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
100   {
101     const u32 pw_r_len = combs_buf[il_pos].pw_len;
102
103     const u32 pw_len = pw_l_len + pw_r_len;
104
105     u32 wordr0[4];
106
107     wordr0[0] = combs_buf[il_pos].i[0];
108     wordr0[1] = combs_buf[il_pos].i[1];
109     wordr0[2] = combs_buf[il_pos].i[2];
110     wordr0[3] = combs_buf[il_pos].i[3];
111
112     u32 wordr1[4];
113
114     wordr1[0] = combs_buf[il_pos].i[4];
115     wordr1[1] = combs_buf[il_pos].i[5];
116     wordr1[2] = combs_buf[il_pos].i[6];
117     wordr1[3] = combs_buf[il_pos].i[7];
118
119     u32 wordr2[4];
120
121     wordr2[0] = 0;
122     wordr2[1] = 0;
123     wordr2[2] = 0;
124     wordr2[3] = 0;
125
126     u32 wordr3[4];
127
128     wordr3[0] = 0;
129     wordr3[1] = 0;
130     wordr3[2] = 0;
131     wordr3[3] = 0;
132
133     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
134     {
135       append_0x80_2x4 (wordr0, wordr1, pw_r_len);
136
137       switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
138     }
139
140     u32 w0[4];
141
142     w0[0] = wordl0[0] | wordr0[0];
143     w0[1] = wordl0[1] | wordr0[1];
144     w0[2] = wordl0[2] | wordr0[2];
145     w0[3] = wordl0[3] | wordr0[3];
146
147     u32 w1[4];
148
149     w1[0] = wordl1[0] | wordr1[0];
150     w1[1] = wordl1[1] | wordr1[1];
151     w1[2] = wordl1[2] | wordr1[2];
152     w1[3] = wordl1[3] | wordr1[3];
153
154     u32 w2[4];
155
156     w2[0] = wordl2[0] | wordr2[0];
157     w2[1] = wordl2[1] | wordr2[1];
158     w2[2] = wordl2[2] | wordr2[2];
159     w2[3] = wordl2[3] | wordr2[3];
160
161     u32 w3[4];
162
163     w3[0] = wordl3[0] | wordr3[0];
164     w3[1] = wordl3[1] | wordr3[1];
165     w3[2] = 0;
166     w3[3] = 0;
167
168     /**
169      * sha1
170      */
171
172     u32 w0_t = swap32 (w0[0]);
173     u32 w1_t = swap32 (w0[1]);
174     u32 w2_t = swap32 (w0[2]);
175     u32 w3_t = swap32 (w0[3]);
176     u32 w4_t = swap32 (w1[0]);
177     u32 w5_t = swap32 (w1[1]);
178     u32 w6_t = swap32 (w1[2]);
179     u32 w7_t = swap32 (w1[3]);
180     u32 w8_t = swap32 (w2[0]);
181     u32 w9_t = swap32 (w2[1]);
182     u32 wa_t = swap32 (w2[2]);
183     u32 wb_t = swap32 (w2[3]);
184     u32 wc_t = swap32 (w3[0]);
185     u32 wd_t = swap32 (w3[1]);
186     u32 we_t = 0;
187     u32 wf_t = pw_len * 8;
188
189     u32 a = SHA1M_A;
190     u32 b = SHA1M_B;
191     u32 c = SHA1M_C;
192     u32 d = SHA1M_D;
193     u32 e = SHA1M_E;
194
195     #undef K
196     #define K SHA1C00
197
198     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
199     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
200     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
201     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
202     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
203     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
204     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
205     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
206     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
207     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
208     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
209     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
210     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
211     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
212     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
213     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
214     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
215     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
216     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
217     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
218
219     #undef K
220     #define K SHA1C01
221
222     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
223     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
224     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
225     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
226     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
227     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
228     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
229     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
230     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
231     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
232     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
233     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
234     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
235     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
236     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
237     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
238     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
239     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
240     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
241     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
242
243     #undef K
244     #define K SHA1C02
245
246     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
247     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
248     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
249     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
250     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
251     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
252     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
253     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
254     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
255     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
256     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
257     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
258     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
259     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
260     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
261     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
262     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
263     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
264     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
265     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
266
267     #undef K
268     #define K SHA1C03
269
270     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
271     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
272     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
273     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
274     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
275     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
276     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
277     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
278     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
279     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
280     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
281     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
282     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
283     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
284     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
285     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
286     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
287     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
288     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
289     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
290
291     a += SHA1M_A;
292     b += SHA1M_B;
293     c += SHA1M_C;
294     d += SHA1M_D;
295     e += SHA1M_E;
296
297     /**
298      * md5
299      */
300
301     w0_t = uint_to_hex_lower8 ((a >> 24) & 255) <<  0
302          | uint_to_hex_lower8 ((a >> 16) & 255) << 16;
303     w1_t = uint_to_hex_lower8 ((a >>  8) & 255) <<  0
304          | uint_to_hex_lower8 ((a >>  0) & 255) << 16;
305     w2_t = uint_to_hex_lower8 ((b >> 24) & 255) <<  0
306          | uint_to_hex_lower8 ((b >> 16) & 255) << 16;
307     w3_t = uint_to_hex_lower8 ((b >>  8) & 255) <<  0
308          | uint_to_hex_lower8 ((b >>  0) & 255) << 16;
309     w4_t = uint_to_hex_lower8 ((c >> 24) & 255) <<  0
310          | uint_to_hex_lower8 ((c >> 16) & 255) << 16;
311     w5_t = uint_to_hex_lower8 ((c >>  8) & 255) <<  0
312          | uint_to_hex_lower8 ((c >>  0) & 255) << 16;
313     w6_t = uint_to_hex_lower8 ((d >> 24) & 255) <<  0
314          | uint_to_hex_lower8 ((d >> 16) & 255) << 16;
315     w7_t = uint_to_hex_lower8 ((d >>  8) & 255) <<  0
316          | uint_to_hex_lower8 ((d >>  0) & 255) << 16;
317     w8_t = uint_to_hex_lower8 ((e >> 24) & 255) <<  0
318          | uint_to_hex_lower8 ((e >> 16) & 255) << 16;
319     w9_t = uint_to_hex_lower8 ((e >>  8) & 255) <<  0
320          | uint_to_hex_lower8 ((e >>  0) & 255) << 16;
321
322     wa_t = 0x80;
323     wb_t = 0;
324     wc_t = 0;
325     wd_t = 0;
326     we_t = 40 * 8;
327     wf_t = 0;
328
329     a = MD5M_A;
330     b = MD5M_B;
331     c = MD5M_C;
332     d = MD5M_D;
333
334     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
335     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
336     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
337     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
338     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
339     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
340     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
341     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
342     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
343     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
344     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
345     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
346     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
347     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
348     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
349     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
350
351     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
352     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
353     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
354     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
355     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
356     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
357     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
358     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
359     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
360     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
361     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
362     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
363     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
364     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
365     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
366     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
367
368     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
369     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
370     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
371     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
372     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
373     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
374     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
375     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
376     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
377     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
378     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
379     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
380     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
381     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
382     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
383     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
384
385     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
386     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
387     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
388     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
389     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
390     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
391     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
392     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
393     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
394     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
395     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
396     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
397     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
398     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
399     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
400     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
401
402     const u32 r0 = a;
403     const u32 r1 = d;
404     const u32 r2 = c;
405     const u32 r3 = b;
406
407     #include COMPARE_M
408   }
409 }
410
411 __kernel void m04400_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)
412 {
413 }
414
415 __kernel void m04400_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)
416 {
417 }
418
419 __kernel void m04400_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
420 {
421   /**
422    * base
423    */
424
425   const u32 gid = get_global_id (0);
426   const u32 lid = get_local_id (0);
427   const u32 lsz = get_local_size (0);
428
429   /**
430    * bin2asc table
431    */
432
433   __local u32 l_bin2asc[256];
434
435   for (u32 i = lid; i < 256; i += lsz)
436   {
437     const u32 i0 = (i >> 0) & 15;
438     const u32 i1 = (i >> 4) & 15;
439
440     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
441                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
442   }
443
444   barrier (CLK_LOCAL_MEM_FENCE);
445
446   if (gid >= gid_max) return;
447
448   /**
449    * base
450    */
451
452   u32 wordl0[4];
453
454   wordl0[0] = pws[gid].i[ 0];
455   wordl0[1] = pws[gid].i[ 1];
456   wordl0[2] = pws[gid].i[ 2];
457   wordl0[3] = pws[gid].i[ 3];
458
459   u32 wordl1[4];
460
461   wordl1[0] = pws[gid].i[ 4];
462   wordl1[1] = pws[gid].i[ 5];
463   wordl1[2] = pws[gid].i[ 6];
464   wordl1[3] = pws[gid].i[ 7];
465
466   u32 wordl2[4];
467
468   wordl2[0] = 0;
469   wordl2[1] = 0;
470   wordl2[2] = 0;
471   wordl2[3] = 0;
472
473   u32 wordl3[4];
474
475   wordl3[0] = 0;
476   wordl3[1] = 0;
477   wordl3[2] = 0;
478   wordl3[3] = 0;
479
480   const u32 pw_l_len = pws[gid].pw_len;
481
482   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
483   {
484     append_0x80_2x4 (wordl0, wordl1, pw_l_len);
485
486     switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
487   }
488
489   /**
490    * digest
491    */
492
493   const u32 search[4] =
494   {
495     digests_buf[digests_offset].digest_buf[DGST_R0],
496     digests_buf[digests_offset].digest_buf[DGST_R1],
497     digests_buf[digests_offset].digest_buf[DGST_R2],
498     digests_buf[digests_offset].digest_buf[DGST_R3]
499   };
500
501   /**
502    * loop
503    */
504
505   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
506   {
507     const u32 pw_r_len = combs_buf[il_pos].pw_len;
508
509     const u32 pw_len = pw_l_len + pw_r_len;
510
511     u32 wordr0[4];
512
513     wordr0[0] = combs_buf[il_pos].i[0];
514     wordr0[1] = combs_buf[il_pos].i[1];
515     wordr0[2] = combs_buf[il_pos].i[2];
516     wordr0[3] = combs_buf[il_pos].i[3];
517
518     u32 wordr1[4];
519
520     wordr1[0] = combs_buf[il_pos].i[4];
521     wordr1[1] = combs_buf[il_pos].i[5];
522     wordr1[2] = combs_buf[il_pos].i[6];
523     wordr1[3] = combs_buf[il_pos].i[7];
524
525     u32 wordr2[4];
526
527     wordr2[0] = 0;
528     wordr2[1] = 0;
529     wordr2[2] = 0;
530     wordr2[3] = 0;
531
532     u32 wordr3[4];
533
534     wordr3[0] = 0;
535     wordr3[1] = 0;
536     wordr3[2] = 0;
537     wordr3[3] = 0;
538
539     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
540     {
541       append_0x80_2x4 (wordr0, wordr1, pw_r_len);
542
543       switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
544     }
545
546     u32 w0[4];
547
548     w0[0] = wordl0[0] | wordr0[0];
549     w0[1] = wordl0[1] | wordr0[1];
550     w0[2] = wordl0[2] | wordr0[2];
551     w0[3] = wordl0[3] | wordr0[3];
552
553     u32 w1[4];
554
555     w1[0] = wordl1[0] | wordr1[0];
556     w1[1] = wordl1[1] | wordr1[1];
557     w1[2] = wordl1[2] | wordr1[2];
558     w1[3] = wordl1[3] | wordr1[3];
559
560     u32 w2[4];
561
562     w2[0] = wordl2[0] | wordr2[0];
563     w2[1] = wordl2[1] | wordr2[1];
564     w2[2] = wordl2[2] | wordr2[2];
565     w2[3] = wordl2[3] | wordr2[3];
566
567     u32 w3[4];
568
569     w3[0] = wordl3[0] | wordr3[0];
570     w3[1] = wordl3[1] | wordr3[1];
571     w3[2] = 0;
572     w3[3] = 0;
573
574     /**
575      * sha1
576      */
577
578     u32 w0_t = swap32 (w0[0]);
579     u32 w1_t = swap32 (w0[1]);
580     u32 w2_t = swap32 (w0[2]);
581     u32 w3_t = swap32 (w0[3]);
582     u32 w4_t = swap32 (w1[0]);
583     u32 w5_t = swap32 (w1[1]);
584     u32 w6_t = swap32 (w1[2]);
585     u32 w7_t = swap32 (w1[3]);
586     u32 w8_t = swap32 (w2[0]);
587     u32 w9_t = swap32 (w2[1]);
588     u32 wa_t = swap32 (w2[2]);
589     u32 wb_t = swap32 (w2[3]);
590     u32 wc_t = swap32 (w3[0]);
591     u32 wd_t = swap32 (w3[1]);
592     u32 we_t = 0;
593     u32 wf_t = pw_len * 8;
594
595     u32 a = SHA1M_A;
596     u32 b = SHA1M_B;
597     u32 c = SHA1M_C;
598     u32 d = SHA1M_D;
599     u32 e = SHA1M_E;
600
601     #undef K
602     #define K SHA1C00
603
604     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
605     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
606     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
607     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
608     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
609     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
610     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
611     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
612     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
613     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
614     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
615     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
616     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
617     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
618     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
619     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
620     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
621     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
622     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
623     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
624
625     #undef K
626     #define K SHA1C01
627
628     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
629     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
630     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
631     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
632     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
633     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
634     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
635     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
636     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
637     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
638     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
639     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
640     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
641     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
642     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
643     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
644     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
645     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
646     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
647     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
648
649     #undef K
650     #define K SHA1C02
651
652     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
653     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
654     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
655     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
656     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
657     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
658     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
659     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
660     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
661     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
662     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
663     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
664     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
665     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
666     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
667     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
668     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
669     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
670     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
671     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
672
673     #undef K
674     #define K SHA1C03
675
676     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
677     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
678     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
679     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
680     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
681     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
682     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
683     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
684     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
685     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
686     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
687     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
688     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
689     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
690     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
691     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
692     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
693     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
694     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
695     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
696
697     a += SHA1M_A;
698     b += SHA1M_B;
699     c += SHA1M_C;
700     d += SHA1M_D;
701     e += SHA1M_E;
702
703     /**
704      * md5
705      */
706
707     w0_t = uint_to_hex_lower8 ((a >> 24) & 255) <<  0
708          | uint_to_hex_lower8 ((a >> 16) & 255) << 16;
709     w1_t = uint_to_hex_lower8 ((a >>  8) & 255) <<  0
710          | uint_to_hex_lower8 ((a >>  0) & 255) << 16;
711     w2_t = uint_to_hex_lower8 ((b >> 24) & 255) <<  0
712          | uint_to_hex_lower8 ((b >> 16) & 255) << 16;
713     w3_t = uint_to_hex_lower8 ((b >>  8) & 255) <<  0
714          | uint_to_hex_lower8 ((b >>  0) & 255) << 16;
715     w4_t = uint_to_hex_lower8 ((c >> 24) & 255) <<  0
716          | uint_to_hex_lower8 ((c >> 16) & 255) << 16;
717     w5_t = uint_to_hex_lower8 ((c >>  8) & 255) <<  0
718          | uint_to_hex_lower8 ((c >>  0) & 255) << 16;
719     w6_t = uint_to_hex_lower8 ((d >> 24) & 255) <<  0
720          | uint_to_hex_lower8 ((d >> 16) & 255) << 16;
721     w7_t = uint_to_hex_lower8 ((d >>  8) & 255) <<  0
722          | uint_to_hex_lower8 ((d >>  0) & 255) << 16;
723     w8_t = uint_to_hex_lower8 ((e >> 24) & 255) <<  0
724          | uint_to_hex_lower8 ((e >> 16) & 255) << 16;
725     w9_t = uint_to_hex_lower8 ((e >>  8) & 255) <<  0
726          | uint_to_hex_lower8 ((e >>  0) & 255) << 16;
727
728     wa_t = 0x80;
729     wb_t = 0;
730     wc_t = 0;
731     wd_t = 0;
732     we_t = 40 * 8;
733     wf_t = 0;
734
735     a = MD5M_A;
736     b = MD5M_B;
737     c = MD5M_C;
738     d = MD5M_D;
739
740     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
741     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
742     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
743     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
744     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
745     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
746     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
747     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
748     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
749     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
750     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
751     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
752     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
753     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
754     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
755     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
756
757     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
758     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
759     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
760     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
761     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
762     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
763     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
764     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
765     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
766     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
767     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
768     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
769     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
770     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
771     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
772     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
773
774     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
775     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
776     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
777     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
778     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
779     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
780     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
781     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
782     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
783     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
784     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
785     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
786     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
787     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
788     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
789     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
790
791     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
792     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
793     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
794     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
795     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
796     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
797     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
798     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
799     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
800     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
801     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
802     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
803     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
804     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
805     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
806     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
807
808     const u32 r0 = a;
809     const u32 r1 = d;
810     const u32 r2 = c;
811     const u32 r3 = b;
812
813     #include COMPARE_S
814   }
815 }
816
817 __kernel void m04400_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)
818 {
819 }
820
821 __kernel void m04400_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)
822 {
823 }