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