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