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