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