113bed720c64f0800001dd474fa8bdaf6f89f7f0
[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 "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19
20 #define COMPARE_S "OpenCL/check_single_comp4.c"
21 #define COMPARE_M "OpenCL/check_multi_comp4.c"
22
23 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
24
25 static void m03710m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 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 kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 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 m03710_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 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   const u32 lid = get_local_id (0);
601   const u32 lsz = get_local_size (0);
602
603   /**
604    * bin2asc table
605    */
606
607   __local u32 l_bin2asc[256];
608
609   for (u32 i = lid; i < 256; i += lsz)
610   {
611     const u32 i0 = (i >> 0) & 15;
612     const u32 i1 = (i >> 4) & 15;
613
614     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
615                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
616   }
617
618   barrier (CLK_LOCAL_MEM_FENCE);
619
620   if (gid >= gid_max) return;
621
622   /**
623    * modifier
624    */
625
626   u32 w0[4];
627
628   w0[0] = pws[gid].i[ 0];
629   w0[1] = pws[gid].i[ 1];
630   w0[2] = pws[gid].i[ 2];
631   w0[3] = pws[gid].i[ 3];
632
633   u32 w1[4];
634
635   w1[0] = 0;
636   w1[1] = 0;
637   w1[2] = 0;
638   w1[3] = 0;
639
640   u32 w2[4];
641
642   w2[0] = 0;
643   w2[1] = 0;
644   w2[2] = 0;
645   w2[3] = 0;
646
647   u32 w3[4];
648
649   w3[0] = 0;
650   w3[1] = 0;
651   w3[2] = pws[gid].i[14];
652   w3[3] = 0;
653
654   const u32 pw_len = pws[gid].pw_len;
655
656   /**
657    * main
658    */
659
660   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);
661 }
662
663 __kernel void m03710_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
664 {
665   /**
666    * base
667    */
668
669   const u32 gid = get_global_id (0);
670   const u32 lid = get_local_id (0);
671   const u32 lsz = get_local_size (0);
672
673   /**
674    * modifier
675    */
676
677   u32 w0[4];
678
679   w0[0] = pws[gid].i[ 0];
680   w0[1] = pws[gid].i[ 1];
681   w0[2] = pws[gid].i[ 2];
682   w0[3] = pws[gid].i[ 3];
683
684   u32 w1[4];
685
686   w1[0] = pws[gid].i[ 4];
687   w1[1] = pws[gid].i[ 5];
688   w1[2] = pws[gid].i[ 6];
689   w1[3] = pws[gid].i[ 7];
690
691   u32 w2[4];
692
693   w2[0] = 0;
694   w2[1] = 0;
695   w2[2] = 0;
696   w2[3] = 0;
697
698   u32 w3[4];
699
700   w3[0] = 0;
701   w3[1] = 0;
702   w3[2] = pws[gid].i[14];
703   w3[3] = 0;
704
705   const u32 pw_len = pws[gid].pw_len;
706
707   /**
708    * bin2asc table
709    */
710
711   __local u32 l_bin2asc[256];
712
713   const u32 lid4 = lid * 4;
714
715   const u32 lid40 = lid4 + 0;
716   const u32 lid41 = lid4 + 1;
717   const u32 lid42 = lid4 + 2;
718   const u32 lid43 = lid4 + 3;
719
720   const u32 v400 = (lid40 >> 0) & 15;
721   const u32 v401 = (lid40 >> 4) & 15;
722   const u32 v410 = (lid41 >> 0) & 15;
723   const u32 v411 = (lid41 >> 4) & 15;
724   const u32 v420 = (lid42 >> 0) & 15;
725   const u32 v421 = (lid42 >> 4) & 15;
726   const u32 v430 = (lid43 >> 0) & 15;
727   const u32 v431 = (lid43 >> 4) & 15;
728
729   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
730                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
731   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
732                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
733   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
734                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
735   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
736                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
737
738   barrier (CLK_LOCAL_MEM_FENCE);
739
740   if (gid >= gid_max) return;
741
742   /**
743    * main
744    */
745
746   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);
747 }
748
749 __kernel void m03710_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
750 {
751   /**
752    * base
753    */
754
755   const u32 gid = get_global_id (0);
756   const u32 lid = get_local_id (0);
757   const u32 lsz = get_local_size (0);
758
759   /**
760    * modifier
761    */
762
763   u32 w0[4];
764
765   w0[0] = pws[gid].i[ 0];
766   w0[1] = pws[gid].i[ 1];
767   w0[2] = pws[gid].i[ 2];
768   w0[3] = pws[gid].i[ 3];
769
770   u32 w1[4];
771
772   w1[0] = pws[gid].i[ 4];
773   w1[1] = pws[gid].i[ 5];
774   w1[2] = pws[gid].i[ 6];
775   w1[3] = pws[gid].i[ 7];
776
777   u32 w2[4];
778
779   w2[0] = pws[gid].i[ 8];
780   w2[1] = pws[gid].i[ 9];
781   w2[2] = pws[gid].i[10];
782   w2[3] = pws[gid].i[11];
783
784   u32 w3[4];
785
786   w3[0] = pws[gid].i[12];
787   w3[1] = pws[gid].i[13];
788   w3[2] = pws[gid].i[14];
789   w3[3] = pws[gid].i[15];
790
791   const u32 pw_len = pws[gid].pw_len;
792
793   /**
794    * bin2asc table
795    */
796
797   __local u32 l_bin2asc[256];
798
799   const u32 lid4 = lid * 4;
800
801   const u32 lid40 = lid4 + 0;
802   const u32 lid41 = lid4 + 1;
803   const u32 lid42 = lid4 + 2;
804   const u32 lid43 = lid4 + 3;
805
806   const u32 v400 = (lid40 >> 0) & 15;
807   const u32 v401 = (lid40 >> 4) & 15;
808   const u32 v410 = (lid41 >> 0) & 15;
809   const u32 v411 = (lid41 >> 4) & 15;
810   const u32 v420 = (lid42 >> 0) & 15;
811   const u32 v421 = (lid42 >> 4) & 15;
812   const u32 v430 = (lid43 >> 0) & 15;
813   const u32 v431 = (lid43 >> 4) & 15;
814
815   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
816                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
817   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
818                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
819   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
820                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
821   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
822                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
823
824   barrier (CLK_LOCAL_MEM_FENCE);
825
826   if (gid >= gid_max) return;
827
828   /**
829    * main
830    */
831
832   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);
833 }
834
835 __kernel void m03710_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
836 {
837   /**
838    * base
839    */
840
841   const u32 gid = get_global_id (0);
842   const u32 lid = get_local_id (0);
843   const u32 lsz = get_local_size (0);
844
845   /**
846    * modifier
847    */
848
849   u32 w0[4];
850
851   w0[0] = pws[gid].i[ 0];
852   w0[1] = pws[gid].i[ 1];
853   w0[2] = pws[gid].i[ 2];
854   w0[3] = pws[gid].i[ 3];
855
856   u32 w1[4];
857
858   w1[0] = 0;
859   w1[1] = 0;
860   w1[2] = 0;
861   w1[3] = 0;
862
863   u32 w2[4];
864
865   w2[0] = 0;
866   w2[1] = 0;
867   w2[2] = 0;
868   w2[3] = 0;
869
870   u32 w3[4];
871
872   w3[0] = 0;
873   w3[1] = 0;
874   w3[2] = pws[gid].i[14];
875   w3[3] = 0;
876
877   const u32 pw_len = pws[gid].pw_len;
878
879   /**
880    * bin2asc table
881    */
882
883   __local u32 l_bin2asc[256];
884
885   const u32 lid4 = lid * 4;
886
887   const u32 lid40 = lid4 + 0;
888   const u32 lid41 = lid4 + 1;
889   const u32 lid42 = lid4 + 2;
890   const u32 lid43 = lid4 + 3;
891
892   const u32 v400 = (lid40 >> 0) & 15;
893   const u32 v401 = (lid40 >> 4) & 15;
894   const u32 v410 = (lid41 >> 0) & 15;
895   const u32 v411 = (lid41 >> 4) & 15;
896   const u32 v420 = (lid42 >> 0) & 15;
897   const u32 v421 = (lid42 >> 4) & 15;
898   const u32 v430 = (lid43 >> 0) & 15;
899   const u32 v431 = (lid43 >> 4) & 15;
900
901   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
902                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
903   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
904                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
905   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
906                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
907   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
908                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
909
910   barrier (CLK_LOCAL_MEM_FENCE);
911
912   if (gid >= gid_max) return;
913
914   /**
915    * main
916    */
917
918   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);
919 }
920
921 __kernel void m03710_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
922 {
923   /**
924    * base
925    */
926
927   const u32 gid = get_global_id (0);
928   const u32 lid = get_local_id (0);
929   const u32 lsz = get_local_size (0);
930
931   /**
932    * modifier
933    */
934
935   u32 w0[4];
936
937   w0[0] = pws[gid].i[ 0];
938   w0[1] = pws[gid].i[ 1];
939   w0[2] = pws[gid].i[ 2];
940   w0[3] = pws[gid].i[ 3];
941
942   u32 w1[4];
943
944   w1[0] = pws[gid].i[ 4];
945   w1[1] = pws[gid].i[ 5];
946   w1[2] = pws[gid].i[ 6];
947   w1[3] = pws[gid].i[ 7];
948
949   u32 w2[4];
950
951   w2[0] = 0;
952   w2[1] = 0;
953   w2[2] = 0;
954   w2[3] = 0;
955
956   u32 w3[4];
957
958   w3[0] = 0;
959   w3[1] = 0;
960   w3[2] = pws[gid].i[14];
961   w3[3] = 0;
962
963   const u32 pw_len = pws[gid].pw_len;
964
965   /**
966    * bin2asc table
967    */
968
969   __local u32 l_bin2asc[256];
970
971   const u32 lid4 = lid * 4;
972
973   const u32 lid40 = lid4 + 0;
974   const u32 lid41 = lid4 + 1;
975   const u32 lid42 = lid4 + 2;
976   const u32 lid43 = lid4 + 3;
977
978   const u32 v400 = (lid40 >> 0) & 15;
979   const u32 v401 = (lid40 >> 4) & 15;
980   const u32 v410 = (lid41 >> 0) & 15;
981   const u32 v411 = (lid41 >> 4) & 15;
982   const u32 v420 = (lid42 >> 0) & 15;
983   const u32 v421 = (lid42 >> 4) & 15;
984   const u32 v430 = (lid43 >> 0) & 15;
985   const u32 v431 = (lid43 >> 4) & 15;
986
987   l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
988                    | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
989   l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
990                    | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
991   l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
992                    | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
993   l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
994                    | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
995
996   barrier (CLK_LOCAL_MEM_FENCE);
997
998   if (gid >= gid_max) return;
999
1000   /**
1001    * main
1002    */
1003
1004   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);
1005 }
1006
1007 __kernel void m03710_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
1008 {
1009   /**
1010    * base
1011    */
1012
1013   const u32 gid = get_global_id (0);
1014   const u32 lid = get_local_id (0);
1015   const u32 lsz = get_local_size (0);
1016
1017   /**
1018    * bin2asc table
1019    */
1020
1021   __local u32 l_bin2asc[256];
1022
1023   for (u32 i = lid; i < 256; i += lsz)
1024   {
1025     const u32 i0 = (i >> 0) & 15;
1026     const u32 i1 = (i >> 4) & 15;
1027
1028     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
1029                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
1030   }
1031
1032   barrier (CLK_LOCAL_MEM_FENCE);
1033
1034   if (gid >= gid_max) return;
1035
1036   /**
1037    * modifier
1038    */
1039
1040   u32 w0[4];
1041
1042   w0[0] = pws[gid].i[ 0];
1043   w0[1] = pws[gid].i[ 1];
1044   w0[2] = pws[gid].i[ 2];
1045   w0[3] = pws[gid].i[ 3];
1046
1047   u32 w1[4];
1048
1049   w1[0] = pws[gid].i[ 4];
1050   w1[1] = pws[gid].i[ 5];
1051   w1[2] = pws[gid].i[ 6];
1052   w1[3] = pws[gid].i[ 7];
1053
1054   u32 w2[4];
1055
1056   w2[0] = pws[gid].i[ 8];
1057   w2[1] = pws[gid].i[ 9];
1058   w2[2] = pws[gid].i[10];
1059   w2[3] = pws[gid].i[11];
1060
1061   u32 w3[4];
1062
1063   w3[0] = pws[gid].i[12];
1064   w3[1] = pws[gid].i[13];
1065   w3[2] = pws[gid].i[14];
1066   w3[3] = pws[gid].i[15];
1067
1068   const u32 pw_len = pws[gid].pw_len;
1069
1070   /**
1071    * main
1072    */
1073
1074   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);
1075 }