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