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