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