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