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