Merge pull request #241 from philsmd/master
[hashcat.git] / OpenCL / m02610_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_lower8(i) (u32x) (l_bin2asc[(i)])
29 #elif VECT_SIZE == 2
30 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
31 #elif VECT_SIZE == 4
32 #define uint_to_hex_lower8(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_lower8(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_lower8(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 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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
40 {
41   /**
42    * modifier
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    * base
51    */
52
53   u32 pw_buf0[4];
54
55   pw_buf0[0] = pws[gid].i[ 0];
56   pw_buf0[1] = pws[gid].i[ 1];
57   pw_buf0[2] = pws[gid].i[ 2];
58   pw_buf0[3] = pws[gid].i[ 3];
59
60   u32 pw_buf1[4];
61
62   pw_buf1[0] = pws[gid].i[ 4];
63   pw_buf1[1] = pws[gid].i[ 5];
64   pw_buf1[2] = pws[gid].i[ 6];
65   pw_buf1[3] = pws[gid].i[ 7];
66
67   const u32 pw_len = pws[gid].pw_len;
68
69   /**
70    * salt
71    */
72
73   const u32 salt_len = salt_bufs[salt_pos].salt_len;
74
75   u32 s[8];
76
77   s[0] = salt_bufs[salt_pos].salt_buf[0];
78   s[1] = salt_bufs[salt_pos].salt_buf[1];
79   s[2] = salt_bufs[salt_pos].salt_buf[2];
80   s[3] = salt_bufs[salt_pos].salt_buf[3];
81   s[4] = salt_bufs[salt_pos].salt_buf[4];
82   s[5] = salt_bufs[salt_pos].salt_buf[5];
83   s[6] = (32 + salt_len) * 8;
84   s[7] = 0;
85
86   /**
87    * bin2asc table
88    */
89
90   __local u32 l_bin2asc[256];
91
92   for (u32 i = lid; i < 256; i += lsz)
93   {
94     const u32 i0 = (i >> 0) & 15;
95     const u32 i1 = (i >> 4) & 15;
96
97     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
98                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
99   }
100
101   barrier (CLK_LOCAL_MEM_FENCE);
102
103   if (gid >= gid_max) return;
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     w0[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
201           | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
202     w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
203           | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
204     w0[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
205           | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
206     w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
207           | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
208     w1[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
209           | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
210     w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
211           | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
212     w1[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
213           | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
214     w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
215           | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
216
217     w2[0] = s[0];
218     w2[1] = s[1];
219     w2[2] = s[2];
220     w2[3] = s[3];
221
222     w3[0] = s[4];
223     w3[1] = s[5];
224     w3[2] = s[6];
225     w3[3] = s[7];
226
227     a = MD5M_A;
228     b = MD5M_B;
229     c = MD5M_C;
230     d = MD5M_D;
231
232     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
233     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
234     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
235     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
236     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
237     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
238     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
239     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
240     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
241     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
242     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
243     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
244     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
245     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
246     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
247     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
248
249     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
250     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
251     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
252     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
253     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
254     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
255     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
256     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
257     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
258     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
259     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
260     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
261     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
262     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
263     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
264     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
265
266     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
267     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
268     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
269     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
270     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
271     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
272     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
273     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
274     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
275     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
276     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
277     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
278     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
279     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
280     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
281     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
282
283     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
284     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
285     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
286     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
287     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
288     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
289     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
290     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
291     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
292     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
293     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
294     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
295     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
296     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
297     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
298     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
299
300     COMPARE_M_SIMD (a, d, c, b);
301   }
302 }
303
304 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
305 {
306 }
307
308 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
309 {
310 }
311
312 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
313 {
314   /**
315    * modifier
316    */
317
318   const u32 gid = get_global_id (0);
319   const u32 lid = get_local_id (0);
320   const u32 lsz = get_local_size (0);
321
322   /**
323    * base
324    */
325
326   u32 pw_buf0[4];
327
328   pw_buf0[0] = pws[gid].i[ 0];
329   pw_buf0[1] = pws[gid].i[ 1];
330   pw_buf0[2] = pws[gid].i[ 2];
331   pw_buf0[3] = pws[gid].i[ 3];
332
333   u32 pw_buf1[4];
334
335   pw_buf1[0] = pws[gid].i[ 4];
336   pw_buf1[1] = pws[gid].i[ 5];
337   pw_buf1[2] = pws[gid].i[ 6];
338   pw_buf1[3] = pws[gid].i[ 7];
339
340   const u32 pw_len = pws[gid].pw_len;
341
342   /**
343    * salt
344    */
345
346   const u32 salt_len = salt_bufs[salt_pos].salt_len;
347
348   u32 s[8];
349
350   s[0] = salt_bufs[salt_pos].salt_buf[0];
351   s[1] = salt_bufs[salt_pos].salt_buf[1];
352   s[2] = salt_bufs[salt_pos].salt_buf[2];
353   s[3] = salt_bufs[salt_pos].salt_buf[3];
354   s[4] = salt_bufs[salt_pos].salt_buf[4];
355   s[5] = salt_bufs[salt_pos].salt_buf[5];
356   s[6] = (32 + salt_len) * 8;
357   s[7] = 0;
358
359   /**
360    * digest
361    */
362
363   const u32 search[4] =
364   {
365     digests_buf[digests_offset].digest_buf[DGST_R0],
366     digests_buf[digests_offset].digest_buf[DGST_R1],
367     digests_buf[digests_offset].digest_buf[DGST_R2],
368     digests_buf[digests_offset].digest_buf[DGST_R3]
369   };
370
371   /**
372    * bin2asc table
373    */
374
375   __local u32 l_bin2asc[256];
376
377   for (u32 i = lid; i < 256; i += lsz)
378   {
379     const u32 i0 = (i >> 0) & 15;
380     const u32 i1 = (i >> 4) & 15;
381
382     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
383                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
384   }
385
386   barrier (CLK_LOCAL_MEM_FENCE);
387
388   if (gid >= gid_max) return;
389
390   /**
391    * loop
392    */
393
394   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
395   {
396     u32x w0[4] = { 0 };
397     u32x w1[4] = { 0 };
398     u32x w2[4] = { 0 };
399     u32x w3[4] = { 0 };
400
401     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
402
403     append_0x80_2x4_VV (w0, w1, out_len);
404
405     w3[2] = out_len * 8;
406
407     u32x a = MD5M_A;
408     u32x b = MD5M_B;
409     u32x c = MD5M_C;
410     u32x d = MD5M_D;
411
412     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
413     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
414     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
415     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
416     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
417     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
418     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
419     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
420     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
421     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
422     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
423     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
424     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
425     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
426     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
427     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
428
429     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
430     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
431     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
432     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
433     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
434     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
435     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
436     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
437     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
438     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
439     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
440     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
441     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
442     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
443     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
444     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
445
446     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
447     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
448     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
449     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
450     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
451     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
452     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
453     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
454     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
455     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
456     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
457     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
458     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
459     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
460     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
461     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
462
463     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
464     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
465     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
466     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
467     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
468     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
469     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
470     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
471     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
472     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
473     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
474     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
475     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
476     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
477     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
478     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
479
480     a += MD5M_A;
481     b += MD5M_B;
482     c += MD5M_C;
483     d += MD5M_D;
484
485     w0[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
486           | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
487     w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
488           | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
489     w0[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
490           | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
491     w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
492           | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
493     w1[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
494           | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
495     w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
496           | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
497     w1[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
498           | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
499     w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
500           | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
501
502     w2[0] = s[0];
503     w2[1] = s[1];
504     w2[2] = s[2];
505     w2[3] = s[3];
506
507     w3[0] = s[4];
508     w3[1] = s[5];
509     w3[2] = s[6];
510     w3[3] = s[7];
511
512     a = MD5M_A;
513     b = MD5M_B;
514     c = MD5M_C;
515     d = MD5M_D;
516
517     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
518     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
519     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
520     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
521     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
522     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
523     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
524     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
525     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
526     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
527     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
528     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
529     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
530     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
531     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
532     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
533
534     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
535     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
536     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
537     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
538     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
539     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
540     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
541     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
542     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
543     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
544     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
545     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
546     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
547     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
548     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
549     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
550
551     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
552     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
553     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
554     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
555     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
556     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
557     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
558     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
559     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
560     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
561     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
562     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
563     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
564     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
565     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
566     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
567
568     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
569     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
570     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
571     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
572     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
573     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
574     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
575     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
576     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
577     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
578     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
579     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
580     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
581
582     if (MATCHES_NONE_VS (a, search[0])) continue;
583
584     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
585     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
586     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
587
588     COMPARE_S_SIMD (a, d, c, b);
589   }
590 }
591
592 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
593 {
594 }
595
596 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
597 {
598 }