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