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