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