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