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