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