Upgrade kernel to support dynamic local work sizes
[hashcat.git] / OpenCL / m04310_a0.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 #include "include/rp_kernel.h"
20 #include "OpenCL/rp.c"
21
22 #define COMPARE_S "OpenCL/check_single_comp4.c"
23 #define COMPARE_M "OpenCL/check_multi_comp4.c"
24
25 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
26
27 __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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
28 {
29   /**
30    * base
31    */
32
33   const u32 gid = get_global_id (0);
34   const u32 lid = get_local_id (0);
35   const u32 lsz = get_local_size (0);
36
37   /**
38    * bin2asc table
39    */
40
41   __local u32 l_bin2asc[256];
42
43   for (u32 i = lid; i < 256; i += lsz)
44   {
45     const u32 i0 = (i >> 0) & 15;
46     const u32 i1 = (i >> 4) & 15;
47
48     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
49                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
50   }
51
52   barrier (CLK_LOCAL_MEM_FENCE);
53
54   if (gid >= gid_max) return;
55
56   /**
57    * base
58    */
59
60   u32 pw_buf0[4];
61
62   pw_buf0[0] = pws[gid].i[ 0];
63   pw_buf0[1] = pws[gid].i[ 1];
64   pw_buf0[2] = pws[gid].i[ 2];
65   pw_buf0[3] = pws[gid].i[ 3];
66
67   u32 pw_buf1[4];
68
69   pw_buf1[0] = pws[gid].i[ 4];
70   pw_buf1[1] = pws[gid].i[ 5];
71   pw_buf1[2] = pws[gid].i[ 6];
72   pw_buf1[3] = pws[gid].i[ 7];
73
74   const u32 pw_len = pws[gid].pw_len;
75
76   /**
77    * salt
78    */
79
80   const u32 salt_len = salt_bufs[salt_pos].salt_len;
81
82   u32 s[8];
83
84   s[0] = salt_bufs[salt_pos].salt_buf[0];
85   s[1] = salt_bufs[salt_pos].salt_buf[1];
86   s[2] = salt_bufs[salt_pos].salt_buf[2];
87   s[3] = salt_bufs[salt_pos].salt_buf[3];
88   s[4] = salt_bufs[salt_pos].salt_buf[4];
89   s[5] = salt_bufs[salt_pos].salt_buf[5];
90   s[6] = (32 + salt_len) * 8;
91   s[7] = 0;
92
93   /**
94    * loop
95    */
96
97   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
98   {
99     u32 w0[4];
100
101     w0[0] = pw_buf0[0];
102     w0[1] = pw_buf0[1];
103     w0[2] = pw_buf0[2];
104     w0[3] = pw_buf0[3];
105
106     u32 w1[4];
107
108     w1[0] = pw_buf1[0];
109     w1[1] = pw_buf1[1];
110     w1[2] = pw_buf1[2];
111     w1[3] = pw_buf1[3];
112
113     u32 w2[4];
114
115     w2[0] = 0;
116     w2[1] = 0;
117     w2[2] = 0;
118     w2[3] = 0;
119
120     u32 w3[4];
121
122     w3[0] = 0;
123     w3[1] = 0;
124     w3[2] = 0;
125     w3[3] = 0;
126
127     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
128
129     append_0x80_2x4 (w0, w1, out_len);
130
131     w3[2] = out_len * 8;
132
133     u32 a = MD5M_A;
134     u32 b = MD5M_B;
135     u32 c = MD5M_C;
136     u32 d = MD5M_D;
137
138     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
139     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
140     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
141     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
142     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
143     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
144     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
145     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
146     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
147     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
148     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
149     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
150     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
151     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
152     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
153     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
154
155     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
156     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
157     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
158     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
159     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
160     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
161     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
162     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
163     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
164     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
165     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
166     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
167     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
168     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
169     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
170     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
171
172     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
173     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
174     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
175     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
176     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
177     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
178     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
179     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
180     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
181     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
182     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
183     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
184     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
185     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
186     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
187     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
188
189     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
190     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
191     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
192     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
193     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
194     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
195     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
196     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
197     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
198     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
199     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
200     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
201     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
202     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
203     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
204     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
205
206     a += MD5M_A;
207     b += MD5M_B;
208     c += MD5M_C;
209     d += MD5M_D;
210
211     const u32 w0_t = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
212                      | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
213     const u32 w1_t = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
214                      | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
215     const u32 w2_t = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
216                      | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
217     const u32 w3_t = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
218                      | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
219     const u32 w4_t = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
220                      | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
221     const u32 w5_t = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
222                      | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
223     const u32 w6_t = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
224                      | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
225     const u32 w7_t = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
226                      | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
227
228     const u32 w8_t = s[0];
229     const u32 w9_t = s[1];
230     const u32 wa_t = s[2];
231     const u32 wb_t = s[3];
232     const u32 wc_t = s[4];
233     const u32 wd_t = s[5];
234     const u32 we_t = s[6];
235     const u32 wf_t = s[7];
236
237     a = MD5M_A;
238     b = MD5M_B;
239     c = MD5M_C;
240     d = MD5M_D;
241
242     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
243     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
244     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
245     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
246     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
247     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
248     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
249     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
250     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
251     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
252     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
253     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
254     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
255     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
256     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
257     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
258
259     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
260     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
261     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
262     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
263     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
264     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
265     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
266     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
267     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
268     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
269     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
270     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
271     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
272     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
273     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
274     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
275
276     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
277     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
278     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
279     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
280     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
281     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
282     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
283     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
284     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
285     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
286     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
287     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
288     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
289     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
290     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
291     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
292
293     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
294     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
295     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
296     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
297     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
298     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
299     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
300     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
301     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
302     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
303     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
304     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
305     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
306     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
307     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
308     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
309
310     const u32 r0 = a;
311     const u32 r1 = d;
312     const u32 r2 = c;
313     const u32 r3 = b;
314
315     #include COMPARE_M
316   }
317 }
318
319 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
320 {
321 }
322
323 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
324 {
325 }
326
327 __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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
328 {
329   /**
330    * base
331    */
332
333   const u32 gid = get_global_id (0);
334   const u32 lid = get_local_id (0);
335   const u32 lsz = get_local_size (0);
336
337   /**
338    * bin2asc table
339    */
340
341   __local u32 l_bin2asc[256];
342
343   for (u32 i = lid; i < 256; i += lsz)
344   {
345     const u32 i0 = (i >> 0) & 15;
346     const u32 i1 = (i >> 4) & 15;
347
348     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8
349                  | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0;
350   }
351
352   barrier (CLK_LOCAL_MEM_FENCE);
353
354   if (gid >= gid_max) return;
355
356   /**
357    * base
358    */
359
360   u32 pw_buf0[4];
361
362   pw_buf0[0] = pws[gid].i[ 0];
363   pw_buf0[1] = pws[gid].i[ 1];
364   pw_buf0[2] = pws[gid].i[ 2];
365   pw_buf0[3] = pws[gid].i[ 3];
366
367   u32 pw_buf1[4];
368
369   pw_buf1[0] = pws[gid].i[ 4];
370   pw_buf1[1] = pws[gid].i[ 5];
371   pw_buf1[2] = pws[gid].i[ 6];
372   pw_buf1[3] = pws[gid].i[ 7];
373
374   const u32 pw_len = pws[gid].pw_len;
375
376   /**
377    * salt
378    */
379
380   const u32 salt_len = salt_bufs[salt_pos].salt_len;
381
382   u32 s[8];
383
384   s[0] = salt_bufs[salt_pos].salt_buf[0];
385   s[1] = salt_bufs[salt_pos].salt_buf[1];
386   s[2] = salt_bufs[salt_pos].salt_buf[2];
387   s[3] = salt_bufs[salt_pos].salt_buf[3];
388   s[4] = salt_bufs[salt_pos].salt_buf[4];
389   s[5] = salt_bufs[salt_pos].salt_buf[5];
390   s[6] = (32 + salt_len) * 8;
391   s[7] = 0;
392
393   /**
394    * digest
395    */
396
397   const u32 search[4] =
398   {
399     digests_buf[digests_offset].digest_buf[DGST_R0],
400     digests_buf[digests_offset].digest_buf[DGST_R1],
401     digests_buf[digests_offset].digest_buf[DGST_R2],
402     digests_buf[digests_offset].digest_buf[DGST_R3]
403   };
404
405   /**
406    * loop
407    */
408
409   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
410   {
411     u32 w0[4];
412
413     w0[0] = pw_buf0[0];
414     w0[1] = pw_buf0[1];
415     w0[2] = pw_buf0[2];
416     w0[3] = pw_buf0[3];
417
418     u32 w1[4];
419
420     w1[0] = pw_buf1[0];
421     w1[1] = pw_buf1[1];
422     w1[2] = pw_buf1[2];
423     w1[3] = pw_buf1[3];
424
425     u32 w2[4];
426
427     w2[0] = 0;
428     w2[1] = 0;
429     w2[2] = 0;
430     w2[3] = 0;
431
432     u32 w3[4];
433
434     w3[0] = 0;
435     w3[1] = 0;
436     w3[2] = 0;
437     w3[3] = 0;
438
439     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
440
441     append_0x80_2x4 (w0, w1, out_len);
442
443     w3[2] = out_len * 8;
444
445     u32 a = MD5M_A;
446     u32 b = MD5M_B;
447     u32 c = MD5M_C;
448     u32 d = MD5M_D;
449
450     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
451     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
452     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
453     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
454     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
455     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
456     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
457     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
458     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
459     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
460     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
461     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
462     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
463     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
464     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
465     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
466
467     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
468     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
469     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
470     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
471     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
472     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
473     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
474     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
475     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
476     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
477     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
478     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
479     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
480     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
481     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
482     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
483
484     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
485     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
486     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
487     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
488     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
489     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
490     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
491     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
492     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
493     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
494     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
495     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
496     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
497     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
498     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
499     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
500
501     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
502     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
503     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
504     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
505     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
506     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
507     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
508     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
509     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
510     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
511     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
512     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
513     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
514     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
515     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
516     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
517
518     a += MD5M_A;
519     b += MD5M_B;
520     c += MD5M_C;
521     d += MD5M_D;
522
523     const u32 w0_t = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
524                      | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
525     const u32 w1_t = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
526                      | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
527     const u32 w2_t = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
528                      | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
529     const u32 w3_t = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
530                      | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
531     const u32 w4_t = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
532                      | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
533     const u32 w5_t = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
534                      | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
535     const u32 w6_t = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
536                      | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
537     const u32 w7_t = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
538                      | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
539
540     const u32 w8_t = s[0];
541     const u32 w9_t = s[1];
542     const u32 wa_t = s[2];
543     const u32 wb_t = s[3];
544     const u32 wc_t = s[4];
545     const u32 wd_t = s[5];
546     const u32 we_t = s[6];
547     const u32 wf_t = s[7];
548
549     a = MD5M_A;
550     b = MD5M_B;
551     c = MD5M_C;
552     d = MD5M_D;
553
554     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
555     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
556     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
557     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
558     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
559     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
560     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
561     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
562     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
563     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
564     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
565     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
566     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
567     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
568     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
569     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
570
571     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
572     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
573     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
574     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
575     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
576     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
577     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
578     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
579     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
580     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
581     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
582     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
583     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
584     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
585     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
586     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
587
588     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
589     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
590     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
591     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
592     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
593     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
594     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
595     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
596     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
597     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
598     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
599     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
600     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
601     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
602     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
603     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
604
605     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
606     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
607     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
608     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
609     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
610     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
611     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
612     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
613     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
614     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
615     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
616     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
617     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
618     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
619     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
620     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
621
622     const u32 r0 = a;
623     const u32 r1 = d;
624     const u32 r2 = c;
625     const u32 r3 = b;
626
627     #include COMPARE_S
628   }
629 }
630
631 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
632 {
633 }
634
635 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
636 {
637 }