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