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