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