More kernel fixes for function calls and vector datatypes
[hashcat.git] / OpenCL / m03710_a3.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_
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 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
24
25 static void m03710m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, __local u32 l_bin2asc[256])
26 {
27   /**
28    * modifier
29    */
30
31   const u32 gid = get_global_id (0);
32   const u32 lid = get_local_id (0);
33
34   /**
35    * salt
36    */
37
38   u32 salt_buf0[4];
39
40   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
41   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
42   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
43   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
44
45   u32 salt_buf1[4];
46
47   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
48   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
49   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
50   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
51
52   u32 salt_buf2[4];
53
54   salt_buf2[0] = 0;
55   salt_buf2[1] = 0;
56   salt_buf2[2] = 0;
57   salt_buf2[3] = 0;
58
59   u32 salt_buf3[4];
60
61   salt_buf3[0] = 0;
62   salt_buf3[1] = 0;
63   salt_buf3[2] = 0;
64   salt_buf3[3] = 0;
65
66   const u32 salt_len = salt_bufs[salt_pos].salt_len;
67
68   const u32 pw_salt_len = 32 + salt_len;
69
70   /**
71    * loop
72    */
73
74   u32 w0l = w0[0];
75
76   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
77   {
78     const u32 w0r = bfs_buf[il_pos].i;
79
80     w0[0] = w0l | w0r;
81
82     u32 a = MD5M_A;
83     u32 b = MD5M_B;
84     u32 c = MD5M_C;
85     u32 d = MD5M_D;
86
87     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
88     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
89     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
90     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
91     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
92     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
93     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
94     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
95     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
96     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
97     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
98     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
99     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
100     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
101     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
102     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
103
104     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
105     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
106     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
107     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
108     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
109     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
110     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
111     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
112     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
113     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
114     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
115     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
116     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
117     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
118     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
119     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
120
121     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
122     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
123     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
124     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
125     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
126     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
127     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
128     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
129     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
130     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
131     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
132     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
133     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
134     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
135     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
136     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
137
138     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
139     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
140     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
141     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
142     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
143     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
144     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
145     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
146     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
147     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
148     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
149     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
150     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
151     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
152     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
153     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
154
155     a += MD5M_A;
156     b += MD5M_B;
157     c += MD5M_C;
158     d += MD5M_D;
159
160     u32 w0_t[4];
161     u32 w1_t[4];
162     u32 w2_t[4];
163     u32 w3_t[4];
164
165     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
166             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
167     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
168             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
169     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
170             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
171     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
172             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
173     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
174             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
175     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
176             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
177     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
178             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
179     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
180             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
181
182     w2_t[0] = 0x00000080;
183     w2_t[1] = 0;
184     w2_t[2] = 0;
185     w2_t[3] = 0;
186
187     w3_t[0] = 0;
188     w3_t[1] = 0;
189     w3_t[2] = 0;
190     w3_t[3] = 0;
191
192     /**
193      * prepend salt
194      */
195
196     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
197
198     w3_t[2] = pw_salt_len * 8;
199
200     w0_t[0] |= salt_buf0[0];
201     w0_t[1] |= salt_buf0[1];
202     w0_t[2] |= salt_buf0[2];
203     w0_t[3] |= salt_buf0[3];
204     w1_t[0] |= salt_buf1[0];
205     w1_t[1] |= salt_buf1[1];
206     w1_t[2] |= salt_buf1[2];
207     w1_t[3] |= salt_buf1[3];
208     w2_t[0] |= salt_buf2[0];
209     w2_t[1] |= salt_buf2[1];
210     w2_t[2] |= salt_buf2[2];
211     w2_t[3] |= salt_buf2[3];
212     w3_t[0] |= salt_buf3[0];
213     w3_t[1] |= salt_buf3[1];
214     w3_t[2] |= salt_buf3[2];
215     w3_t[3] |= salt_buf3[3];
216
217     /**
218      * md5
219      */
220
221     a = MD5M_A;
222     b = MD5M_B;
223     c = MD5M_C;
224     d = MD5M_D;
225
226     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
227     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
228     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
229     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
230     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
231     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
232     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
233     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
234     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
235     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
236     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
237     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
238     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
239     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
240     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
241     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
242
243     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
244     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
245     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
246     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
247     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
248     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
249     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
250     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
251     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
252     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
253     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
254     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
255     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
256     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
257     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
258     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
259
260     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
261     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
262     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
263     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
264     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
265     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
266     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
267     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
268     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
269     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
270     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
271     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
272     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
273     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
274     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
275     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
276
277     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
278     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
279     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
280     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
281     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
282     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
283     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
284     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
285     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
286     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
287     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
288     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
289     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
290     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
291     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
292     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
293
294     const u32 r0 = a;
295     const u32 r1 = d;
296     const u32 r2 = c;
297     const u32 r3 = b;
298
299     #include COMPARE_M
300   }
301 }
302
303 static void m03710s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, __local u32 l_bin2asc[256])
304 {
305   /**
306    * modifier
307    */
308
309   const u32 gid = get_global_id (0);
310   const u32 lid = get_local_id (0);
311
312   /**
313    * digest
314    */
315
316   const u32 search[4] =
317   {
318     digests_buf[digests_offset].digest_buf[DGST_R0],
319     digests_buf[digests_offset].digest_buf[DGST_R1],
320     digests_buf[digests_offset].digest_buf[DGST_R2],
321     digests_buf[digests_offset].digest_buf[DGST_R3]
322   };
323
324   /**
325    * salt
326    */
327
328   u32 salt_buf0[4];
329
330   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
331   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
332   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
333   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
334
335   u32 salt_buf1[4];
336
337   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
338   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
339   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
340   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
341
342   u32 salt_buf2[4];
343
344   salt_buf2[0] = 0;
345   salt_buf2[1] = 0;
346   salt_buf2[2] = 0;
347   salt_buf2[3] = 0;
348
349   u32 salt_buf3[4];
350
351   salt_buf3[0] = 0;
352   salt_buf3[1] = 0;
353   salt_buf3[2] = 0;
354   salt_buf3[3] = 0;
355
356   const u32 salt_len = salt_bufs[salt_pos].salt_len;
357
358   const u32 pw_salt_len = 32 + salt_len;
359
360   /**
361    * loop
362    */
363
364   u32 w0l = w0[0];
365
366   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
367   {
368     const u32 w0r = bfs_buf[il_pos].i;
369
370     w0[0] = w0l | w0r;
371
372     u32 a = MD5M_A;
373     u32 b = MD5M_B;
374     u32 c = MD5M_C;
375     u32 d = MD5M_D;
376
377     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
378     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
379     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
380     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
381     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
382     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
383     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
384     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
385     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
386     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
387     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
388     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
389     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
390     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
391     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
392     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
393
394     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
395     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
396     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
397     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
398     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
399     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
400     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
401     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
402     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
403     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
404     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
405     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
406     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
407     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
408     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
409     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
410
411     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
412     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
413     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
414     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
415     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
416     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
417     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
418     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
419     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
420     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
421     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
422     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
423     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
424     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
425     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
426     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
427
428     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
429     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
430     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
431     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
432     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
433     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
434     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
435     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
436     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
437     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
438     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
439     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
440     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
441     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
442     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
443     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
444
445     a += MD5M_A;
446     b += MD5M_B;
447     c += MD5M_C;
448     d += MD5M_D;
449
450     u32 w0_t[4];
451     u32 w1_t[4];
452     u32 w2_t[4];
453     u32 w3_t[4];
454
455     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
456             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
457     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
458             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
459     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
460             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
461     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
462             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
463     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
464             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
465     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
466             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
467     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
468             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
469     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
470             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
471
472     w2_t[0] = 0x00000080;
473     w2_t[1] = 0;
474     w2_t[2] = 0;
475     w2_t[3] = 0;
476
477     w3_t[0] = 0;
478     w3_t[1] = 0;
479     w3_t[2] = 0;
480     w3_t[3] = 0;
481
482     /**
483      * prepend salt
484      */
485
486     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
487
488     w3_t[2] = pw_salt_len * 8;
489
490     w0_t[0] |= salt_buf0[0];
491     w0_t[1] |= salt_buf0[1];
492     w0_t[2] |= salt_buf0[2];
493     w0_t[3] |= salt_buf0[3];
494     w1_t[0] |= salt_buf1[0];
495     w1_t[1] |= salt_buf1[1];
496     w1_t[2] |= salt_buf1[2];
497     w1_t[3] |= salt_buf1[3];
498     w2_t[0] |= salt_buf2[0];
499     w2_t[1] |= salt_buf2[1];
500     w2_t[2] |= salt_buf2[2];
501     w2_t[3] |= salt_buf2[3];
502     w3_t[0] |= salt_buf3[0];
503     w3_t[1] |= salt_buf3[1];
504     w3_t[2] |= salt_buf3[2];
505     w3_t[3] |= salt_buf3[3];
506
507     /**
508      * md5
509      */
510
511     a = MD5M_A;
512     b = MD5M_B;
513     c = MD5M_C;
514     d = MD5M_D;
515
516     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
517     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
518     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
519     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
520     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
521     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
522     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
523     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
524     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
525     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
526     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
527     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
528     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
529     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
530     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
531     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
532
533     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
534     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
535     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
536     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
537     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
538     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
539     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
540     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
541     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
542     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
543     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
544     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
545     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
546     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
547     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
548     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
549
550     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
551     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
552     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
553     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
554     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
555     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
556     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
557     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
558     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
559     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
560     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
561     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
562     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
563     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
564     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
565     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
566
567     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
568     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
569     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
570     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
571     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
572     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
573     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
574     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
575     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
576     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
577     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
578     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
579     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
580     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
581     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
582     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
583
584     const u32 r0 = a;
585     const u32 r1 = d;
586     const u32 r2 = c;
587     const u32 r3 = b;
588
589     #include COMPARE_S
590   }
591 }
592
593 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03710_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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
594 {
595   /**
596    * base
597    */
598
599   const u32 gid = get_global_id (0);
600
601   /**
602    * modifier
603    */
604
605   const u32 lid = get_local_id (0);
606
607   u32 w0[4];
608
609   w0[0] = pws[gid].i[ 0];
610   w0[1] = pws[gid].i[ 1];
611   w0[2] = pws[gid].i[ 2];
612   w0[3] = pws[gid].i[ 3];
613
614   u32 w1[4];
615
616   w1[0] = 0;
617   w1[1] = 0;
618   w1[2] = 0;
619   w1[3] = 0;
620
621   u32 w2[4];
622
623   w2[0] = 0;
624   w2[1] = 0;
625   w2[2] = 0;
626   w2[3] = 0;
627
628   u32 w3[4];
629
630   w3[0] = 0;
631   w3[1] = 0;
632   w3[2] = pws[gid].i[14];
633   w3[3] = 0;
634
635   const u32 pw_len = pws[gid].pw_len;
636
637   /**
638    * bin2asc table
639    */
640
641   __local u32 l_bin2asc[256];
642
643   const u32 lid4 = lid * 4;
644
645   const u32 lid40 = lid4 + 0;
646   const u32 lid41 = lid4 + 1;
647   const u32 lid42 = lid4 + 2;
648   const u32 lid43 = lid4 + 3;
649
650   const u32 v400 = (lid40 >> 0) & 15;
651   const u32 v401 = (lid40 >> 4) & 15;
652   const u32 v410 = (lid41 >> 0) & 15;
653   const u32 v411 = (lid41 >> 4) & 15;
654   const u32 v420 = (lid42 >> 0) & 15;
655   const u32 v421 = (lid42 >> 4) & 15;
656   const u32 v430 = (lid43 >> 0) & 15;
657   const u32 v431 = (lid43 >> 4) & 15;
658
659   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
660                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
661   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
662                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
663   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
664                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
665   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
666                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
667
668   barrier (CLK_LOCAL_MEM_FENCE);
669
670   if (gid >= gid_max) return;
671
672   /**
673    * main
674    */
675
676   m03710m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, l_bin2asc);
677 }
678
679 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03710_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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
680 {
681   /**
682    * base
683    */
684
685   const u32 gid = get_global_id (0);
686
687   /**
688    * modifier
689    */
690
691   const u32 lid = get_local_id (0);
692
693   u32 w0[4];
694
695   w0[0] = pws[gid].i[ 0];
696   w0[1] = pws[gid].i[ 1];
697   w0[2] = pws[gid].i[ 2];
698   w0[3] = pws[gid].i[ 3];
699
700   u32 w1[4];
701
702   w1[0] = pws[gid].i[ 4];
703   w1[1] = pws[gid].i[ 5];
704   w1[2] = pws[gid].i[ 6];
705   w1[3] = pws[gid].i[ 7];
706
707   u32 w2[4];
708
709   w2[0] = 0;
710   w2[1] = 0;
711   w2[2] = 0;
712   w2[3] = 0;
713
714   u32 w3[4];
715
716   w3[0] = 0;
717   w3[1] = 0;
718   w3[2] = pws[gid].i[14];
719   w3[3] = 0;
720
721   const u32 pw_len = pws[gid].pw_len;
722
723   /**
724    * bin2asc table
725    */
726
727   __local u32 l_bin2asc[256];
728
729   const u32 lid4 = lid * 4;
730
731   const u32 lid40 = lid4 + 0;
732   const u32 lid41 = lid4 + 1;
733   const u32 lid42 = lid4 + 2;
734   const u32 lid43 = lid4 + 3;
735
736   const u32 v400 = (lid40 >> 0) & 15;
737   const u32 v401 = (lid40 >> 4) & 15;
738   const u32 v410 = (lid41 >> 0) & 15;
739   const u32 v411 = (lid41 >> 4) & 15;
740   const u32 v420 = (lid42 >> 0) & 15;
741   const u32 v421 = (lid42 >> 4) & 15;
742   const u32 v430 = (lid43 >> 0) & 15;
743   const u32 v431 = (lid43 >> 4) & 15;
744
745   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
746                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
747   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
748                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
749   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
750                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
751   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
752                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
753
754   barrier (CLK_LOCAL_MEM_FENCE);
755
756   if (gid >= gid_max) return;
757
758   /**
759    * main
760    */
761
762   m03710m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, l_bin2asc);
763 }
764
765 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03710_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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
766 {
767   /**
768    * base
769    */
770
771   const u32 gid = get_global_id (0);
772
773   /**
774    * modifier
775    */
776
777   const u32 lid = get_local_id (0);
778
779   u32 w0[4];
780
781   w0[0] = pws[gid].i[ 0];
782   w0[1] = pws[gid].i[ 1];
783   w0[2] = pws[gid].i[ 2];
784   w0[3] = pws[gid].i[ 3];
785
786   u32 w1[4];
787
788   w1[0] = pws[gid].i[ 4];
789   w1[1] = pws[gid].i[ 5];
790   w1[2] = pws[gid].i[ 6];
791   w1[3] = pws[gid].i[ 7];
792
793   u32 w2[4];
794
795   w2[0] = pws[gid].i[ 8];
796   w2[1] = pws[gid].i[ 9];
797   w2[2] = pws[gid].i[10];
798   w2[3] = pws[gid].i[11];
799
800   u32 w3[4];
801
802   w3[0] = pws[gid].i[12];
803   w3[1] = pws[gid].i[13];
804   w3[2] = pws[gid].i[14];
805   w3[3] = pws[gid].i[15];
806
807   const u32 pw_len = pws[gid].pw_len;
808
809   /**
810    * bin2asc table
811    */
812
813   __local u32 l_bin2asc[256];
814
815   const u32 lid4 = lid * 4;
816
817   const u32 lid40 = lid4 + 0;
818   const u32 lid41 = lid4 + 1;
819   const u32 lid42 = lid4 + 2;
820   const u32 lid43 = lid4 + 3;
821
822   const u32 v400 = (lid40 >> 0) & 15;
823   const u32 v401 = (lid40 >> 4) & 15;
824   const u32 v410 = (lid41 >> 0) & 15;
825   const u32 v411 = (lid41 >> 4) & 15;
826   const u32 v420 = (lid42 >> 0) & 15;
827   const u32 v421 = (lid42 >> 4) & 15;
828   const u32 v430 = (lid43 >> 0) & 15;
829   const u32 v431 = (lid43 >> 4) & 15;
830
831   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
832                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
833   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
834                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
835   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
836                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
837   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
838                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
839
840   barrier (CLK_LOCAL_MEM_FENCE);
841
842   if (gid >= gid_max) return;
843
844   /**
845    * main
846    */
847
848   m03710m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, l_bin2asc);
849 }
850
851 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03710_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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
852 {
853   /**
854    * base
855    */
856
857   const u32 gid = get_global_id (0);
858
859   /**
860    * modifier
861    */
862
863   const u32 lid = get_local_id (0);
864
865   u32 w0[4];
866
867   w0[0] = pws[gid].i[ 0];
868   w0[1] = pws[gid].i[ 1];
869   w0[2] = pws[gid].i[ 2];
870   w0[3] = pws[gid].i[ 3];
871
872   u32 w1[4];
873
874   w1[0] = 0;
875   w1[1] = 0;
876   w1[2] = 0;
877   w1[3] = 0;
878
879   u32 w2[4];
880
881   w2[0] = 0;
882   w2[1] = 0;
883   w2[2] = 0;
884   w2[3] = 0;
885
886   u32 w3[4];
887
888   w3[0] = 0;
889   w3[1] = 0;
890   w3[2] = pws[gid].i[14];
891   w3[3] = 0;
892
893   const u32 pw_len = pws[gid].pw_len;
894
895   /**
896    * bin2asc table
897    */
898
899   __local u32 l_bin2asc[256];
900
901   const u32 lid4 = lid * 4;
902
903   const u32 lid40 = lid4 + 0;
904   const u32 lid41 = lid4 + 1;
905   const u32 lid42 = lid4 + 2;
906   const u32 lid43 = lid4 + 3;
907
908   const u32 v400 = (lid40 >> 0) & 15;
909   const u32 v401 = (lid40 >> 4) & 15;
910   const u32 v410 = (lid41 >> 0) & 15;
911   const u32 v411 = (lid41 >> 4) & 15;
912   const u32 v420 = (lid42 >> 0) & 15;
913   const u32 v421 = (lid42 >> 4) & 15;
914   const u32 v430 = (lid43 >> 0) & 15;
915   const u32 v431 = (lid43 >> 4) & 15;
916
917   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
918                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
919   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
920                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
921   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
922                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
923   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
924                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
925
926   barrier (CLK_LOCAL_MEM_FENCE);
927
928   if (gid >= gid_max) return;
929
930   /**
931    * main
932    */
933
934   m03710s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, l_bin2asc);
935 }
936
937 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03710_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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
938 {
939   /**
940    * base
941    */
942
943   const u32 gid = get_global_id (0);
944
945   /**
946    * modifier
947    */
948
949   const u32 lid = get_local_id (0);
950
951   u32 w0[4];
952
953   w0[0] = pws[gid].i[ 0];
954   w0[1] = pws[gid].i[ 1];
955   w0[2] = pws[gid].i[ 2];
956   w0[3] = pws[gid].i[ 3];
957
958   u32 w1[4];
959
960   w1[0] = pws[gid].i[ 4];
961   w1[1] = pws[gid].i[ 5];
962   w1[2] = pws[gid].i[ 6];
963   w1[3] = pws[gid].i[ 7];
964
965   u32 w2[4];
966
967   w2[0] = 0;
968   w2[1] = 0;
969   w2[2] = 0;
970   w2[3] = 0;
971
972   u32 w3[4];
973
974   w3[0] = 0;
975   w3[1] = 0;
976   w3[2] = pws[gid].i[14];
977   w3[3] = 0;
978
979   const u32 pw_len = pws[gid].pw_len;
980
981   /**
982    * bin2asc table
983    */
984
985   __local u32 l_bin2asc[256];
986
987   const u32 lid4 = lid * 4;
988
989   const u32 lid40 = lid4 + 0;
990   const u32 lid41 = lid4 + 1;
991   const u32 lid42 = lid4 + 2;
992   const u32 lid43 = lid4 + 3;
993
994   const u32 v400 = (lid40 >> 0) & 15;
995   const u32 v401 = (lid40 >> 4) & 15;
996   const u32 v410 = (lid41 >> 0) & 15;
997   const u32 v411 = (lid41 >> 4) & 15;
998   const u32 v420 = (lid42 >> 0) & 15;
999   const u32 v421 = (lid42 >> 4) & 15;
1000   const u32 v430 = (lid43 >> 0) & 15;
1001   const u32 v431 = (lid43 >> 4) & 15;
1002
1003   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
1004                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
1005   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
1006                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
1007   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
1008                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
1009   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
1010                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
1011
1012   barrier (CLK_LOCAL_MEM_FENCE);
1013
1014   if (gid >= gid_max) return;
1015
1016   /**
1017    * main
1018    */
1019
1020   m03710s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, l_bin2asc);
1021 }
1022
1023 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03710_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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
1024 {
1025   /**
1026    * base
1027    */
1028
1029   const u32 gid = get_global_id (0);
1030
1031   /**
1032    * modifier
1033    */
1034
1035   const u32 lid = get_local_id (0);
1036
1037   u32 w0[4];
1038
1039   w0[0] = pws[gid].i[ 0];
1040   w0[1] = pws[gid].i[ 1];
1041   w0[2] = pws[gid].i[ 2];
1042   w0[3] = pws[gid].i[ 3];
1043
1044   u32 w1[4];
1045
1046   w1[0] = pws[gid].i[ 4];
1047   w1[1] = pws[gid].i[ 5];
1048   w1[2] = pws[gid].i[ 6];
1049   w1[3] = pws[gid].i[ 7];
1050
1051   u32 w2[4];
1052
1053   w2[0] = pws[gid].i[ 8];
1054   w2[1] = pws[gid].i[ 9];
1055   w2[2] = pws[gid].i[10];
1056   w2[3] = pws[gid].i[11];
1057
1058   u32 w3[4];
1059
1060   w3[0] = pws[gid].i[12];
1061   w3[1] = pws[gid].i[13];
1062   w3[2] = pws[gid].i[14];
1063   w3[3] = pws[gid].i[15];
1064
1065   const u32 pw_len = pws[gid].pw_len;
1066
1067   /**
1068    * bin2asc table
1069    */
1070
1071   __local u32 l_bin2asc[256];
1072
1073   const u32 lid4 = lid * 4;
1074
1075   const u32 lid40 = lid4 + 0;
1076   const u32 lid41 = lid4 + 1;
1077   const u32 lid42 = lid4 + 2;
1078   const u32 lid43 = lid4 + 3;
1079
1080   const u32 v400 = (lid40 >> 0) & 15;
1081   const u32 v401 = (lid40 >> 4) & 15;
1082   const u32 v410 = (lid41 >> 0) & 15;
1083   const u32 v411 = (lid41 >> 4) & 15;
1084   const u32 v420 = (lid42 >> 0) & 15;
1085   const u32 v421 = (lid42 >> 4) & 15;
1086   const u32 v430 = (lid43 >> 0) & 15;
1087   const u32 v431 = (lid43 >> 4) & 15;
1088
1089   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
1090                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
1091   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
1092                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
1093   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
1094                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
1095   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
1096                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
1097
1098   barrier (CLK_LOCAL_MEM_FENCE);
1099
1100   if (gid >= gid_max) return;
1101
1102   /**
1103    * main
1104    */
1105
1106   m03710s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, l_bin2asc);
1107 }