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