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