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