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