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