a5d860cce31195e7709ca95775a95ce7f56d55b1
[hashcat.git] / OpenCL / m11100_a3.cl
1 /**
2  * Authors.....: Jens Steube <jens.steube@gmail.com>
3  *               Gabriele Gristina <matrix@hashcat.net>
4  *               magnum <john.magnum@hushmail.com>
5  *
6  * License.....: MIT
7  */
8
9 #define _MD5_
10
11 #define NEW_SIMD_CODE
12
13 #include "inc_hash_constants.h"
14 #include "inc_vendor.cl"
15
16 #define DGST_R0 0
17 #define DGST_R1 3
18 #define DGST_R2 2
19 #define DGST_R3 1
20
21 #include "inc_hash_functions.cl"
22 #include "inc_types.cl"
23 #include "inc_common.cl"
24 #include "inc_simd.cl"
25
26 #if   VECT_SIZE == 1
27 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)])
28 #elif VECT_SIZE == 2
29 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
30 #elif VECT_SIZE == 4
31 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
32 #elif VECT_SIZE == 8
33 #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])
34 #elif VECT_SIZE == 16
35 #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])
36 #endif
37
38 void m11100m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __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, __local u32 *l_bin2asc)
39 {
40   /**
41    * modifier
42    */
43
44   const u32 gid = get_global_id (0);
45   const u32 lid = get_local_id (0);
46
47   /**
48    * challenge
49    */
50
51   u32 challenge;
52
53   challenge = salt_bufs[salt_pos].salt_buf[0];
54
55   /**
56    * salt
57    */
58
59   u32 salt_buf0[4];
60   u32 salt_buf1[4];
61
62   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
63   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
64   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
65   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
66   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
67   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
68   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
69   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
70
71   const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
72
73   u32 s0[4];
74   u32 s1[4];
75   u32 s2[4];
76   u32 s3[4];
77
78   s0[0] = salt_buf0[0];
79   s0[1] = salt_buf0[1];
80   s0[2] = salt_buf0[2];
81   s0[3] = salt_buf0[3];
82   s1[0] = salt_buf1[0];
83   s1[1] = salt_buf1[1];
84   s1[2] = salt_buf1[2];
85   s1[3] = salt_buf1[3];
86   s2[0] = 0;
87   s2[1] = 0;
88   s2[2] = 0;
89   s2[3] = 0;
90   s3[0] = 0;
91   s3[1] = 0;
92   s3[2] = 0;
93   s3[3] = 0;
94
95   switch_buffer_by_offset_le_S (s0, s1, s2, s3, pw_len);
96
97   const u32 pw_salt_len = pw_len + salt_len;
98
99   w0[0] |= s0[0];
100   w0[1] |= s0[1];
101   w0[2] |= s0[2];
102   w0[3] |= s0[3];
103   w1[0] |= s1[0];
104   w1[1] |= s1[1];
105   w1[2] |= s1[2];
106   w1[3] |= s1[3];
107   w2[0] |= s2[0];
108   w2[1] |= s2[1];
109   w2[2] |= s2[2];
110   w2[3] |= s2[3];
111   w3[0] |= s3[0];
112   w3[1] |= s3[1];
113   w3[2]  = pw_salt_len * 8;
114   w3[3]  = 0;
115
116   /**
117    * loop
118    */
119
120   u32 w0l = w0[0];
121
122   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
123   {
124     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
125
126     const u32x w0lr = w0l | w0r;
127
128     u32x w0_t[4];
129     u32x w1_t[4];
130     u32x w2_t[4];
131     u32x w3_t[4];
132
133     w0_t[0] = w0lr;
134     w0_t[1] = w0[1];
135     w0_t[2] = w0[2];
136     w0_t[3] = w0[3];
137     w1_t[0] = w1[0];
138     w1_t[1] = w1[1];
139     w1_t[2] = w1[2];
140     w1_t[3] = w1[3];
141     w2_t[0] = w2[0];
142     w2_t[1] = w2[1];
143     w2_t[2] = w2[2];
144     w2_t[3] = w2[3];
145     w3_t[0] = w3[0];
146     w3_t[1] = w3[1];
147     w3_t[2] = w3[2];
148     w3_t[3] = w3[3];
149
150     /*
151      * md5 ($pass.$salt)
152      */
153
154     u32x a = MD5M_A;
155     u32x b = MD5M_B;
156     u32x c = MD5M_C;
157     u32x d = MD5M_D;
158
159     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
160     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
161     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
162     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
163     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
164     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
165     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
166     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
167     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
168     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
169     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
170     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
171     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
172     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
173     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
174     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
175
176     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
177     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
178     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
179     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
180     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
181     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
182     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
183     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
184     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
185     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
186     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
187     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
188     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
189     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
190     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
191     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
192
193     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
194     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
195     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
196     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
197     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
198     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
199     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
200     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
201     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
202     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
203     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
204     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
205     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
206     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
207     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
208     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
209
210     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
211     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
212     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
213     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
214     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
215     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
216     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
217     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
218     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
219     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
220     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
221     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
222     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
223     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
224     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
225     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
226
227     a += MD5M_A;
228     b += MD5M_B;
229     c += MD5M_C;
230     d += MD5M_D;
231
232     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
233             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
234     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
235             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
236     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
237             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
238     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
239             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
240     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
241             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
242     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
243             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
244     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
245             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
246     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
247             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
248
249     // add the 4 byte challenge here
250
251     w2_t[0] = challenge;
252     w2_t[1] = 0x00000080;
253     w2_t[2] = 0;
254     w2_t[3] = 0;
255     w3_t[0] = 0;
256     w3_t[1] = 0;
257     w3_t[2] = (32 + 4) * 8;
258     w3_t[3] = 0;
259
260     /**
261      * md5 ($hash.$challenge)
262      */
263
264     a = MD5M_A;
265     b = MD5M_B;
266     c = MD5M_C;
267     d = MD5M_D;
268
269     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
270     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
271     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
272     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
273     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
274     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
275     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
276     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
277     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
278     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
279     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
280     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
281     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
282     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
283     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
284     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
285
286     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
287     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
288     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
289     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
290     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
291     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
292     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
293     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
294     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
295     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
296     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
297     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
298     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
299     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
300     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
301     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
302
303     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
304     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
305     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
306     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
307     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
308     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
309     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
310     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
311     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
312     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
313     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
314     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
315     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
316     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
317     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
318     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
319
320     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
321     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
322     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
323     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
324     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
325     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
326     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
327     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
328     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
329     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
330     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
331     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
332     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
333     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
334     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
335     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
336
337     COMPARE_M_SIMD (a, d, c, b);
338   }
339 }
340
341 void m11100s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __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, __local u32 *l_bin2asc)
342 {
343   /**
344    * modifier
345    */
346
347   const u32 gid = get_global_id (0);
348   const u32 lid = get_local_id (0);
349
350   /**
351    * challenge
352    */
353
354   u32 challenge;
355
356   challenge = salt_bufs[salt_pos].salt_buf[0];
357
358   /**
359    * salt
360    */
361
362   u32 salt_buf0[4];
363   u32 salt_buf1[4];
364
365   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
366   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
367   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
368   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
369   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
370   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
371   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
372   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
373
374   const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
375
376   u32 s0[4];
377   u32 s1[4];
378   u32 s2[4];
379   u32 s3[4];
380
381   s0[0] = salt_buf0[0];
382   s0[1] = salt_buf0[1];
383   s0[2] = salt_buf0[2];
384   s0[3] = salt_buf0[3];
385   s1[0] = salt_buf1[0];
386   s1[1] = salt_buf1[1];
387   s1[2] = salt_buf1[2];
388   s1[3] = salt_buf1[3];
389   s2[0] = 0;
390   s2[1] = 0;
391   s2[2] = 0;
392   s2[3] = 0;
393   s3[0] = 0;
394   s3[1] = 0;
395   s3[2] = 0;
396   s3[3] = 0;
397
398   switch_buffer_by_offset_le_S (s0, s1, s2, s3, pw_len);
399
400   const u32 pw_salt_len = pw_len + salt_len;
401
402   w0[0] |= s0[0];
403   w0[1] |= s0[1];
404   w0[2] |= s0[2];
405   w0[3] |= s0[3];
406   w1[0] |= s1[0];
407   w1[1] |= s1[1];
408   w1[2] |= s1[2];
409   w1[3] |= s1[3];
410   w2[0] |= s2[0];
411   w2[1] |= s2[1];
412   w2[2] |= s2[2];
413   w2[3] |= s2[3];
414   w3[0] |= s3[0];
415   w3[1] |= s3[1];
416   w3[2]  = pw_salt_len * 8;
417   w3[3]  = 0;
418
419   /**
420    * digest
421    */
422
423   const u32 search[4] =
424   {
425     digests_buf[digests_offset].digest_buf[DGST_R0],
426     digests_buf[digests_offset].digest_buf[DGST_R1],
427     digests_buf[digests_offset].digest_buf[DGST_R2],
428     digests_buf[digests_offset].digest_buf[DGST_R3]
429   };
430
431   /**
432    * loop
433    */
434
435   u32 w0l = w0[0];
436
437   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
438   {
439     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
440
441     const u32x w0lr = w0l | w0r;
442
443     u32x w0_t[4];
444     u32x w1_t[4];
445     u32x w2_t[4];
446     u32x w3_t[4];
447
448     w0_t[0] = w0lr;
449     w0_t[1] = w0[1];
450     w0_t[2] = w0[2];
451     w0_t[3] = w0[3];
452     w1_t[0] = w1[0];
453     w1_t[1] = w1[1];
454     w1_t[2] = w1[2];
455     w1_t[3] = w1[3];
456     w2_t[0] = w2[0];
457     w2_t[1] = w2[1];
458     w2_t[2] = w2[2];
459     w2_t[3] = w2[3];
460     w3_t[0] = w3[0];
461     w3_t[1] = w3[1];
462     w3_t[2] = w3[2];
463     w3_t[3] = w3[3];
464
465     /*
466      * md5 ($pass.$salt)
467      */
468
469     u32x a = MD5M_A;
470     u32x b = MD5M_B;
471     u32x c = MD5M_C;
472     u32x d = MD5M_D;
473
474     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
475     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
476     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
477     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
478     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
479     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
480     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
481     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
482     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
483     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
484     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
485     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
486     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
487     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
488     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
489     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
490
491     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
492     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
493     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
494     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
495     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
496     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
497     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
498     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
499     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
500     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
501     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
502     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
503     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
504     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
505     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
506     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
507
508     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
509     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
510     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
511     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
512     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
513     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
514     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
515     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
516     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
517     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
518     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
519     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
520     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
521     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
522     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
523     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
524
525     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
526     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
527     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
528     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
529     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
530     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
531     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
532     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
533     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
534     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
535     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
536     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
537     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
538     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
539     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
540     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
541
542     a += MD5M_A;
543     b += MD5M_B;
544     c += MD5M_C;
545     d += MD5M_D;
546
547     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
548             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
549     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
550             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
551     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
552             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
553     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
554             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
555     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
556             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
557     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
558             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
559     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
560             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
561     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
562             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
563
564     // add the 4 byte challenge here
565
566     w2_t[0] = challenge;
567     w2_t[1] = 0x00000080;
568     w2_t[2] = 0;
569     w2_t[3] = 0;
570     w3_t[0] = 0;
571     w3_t[1] = 0;
572     w3_t[2] = (32 + 4) * 8;
573     w3_t[3] = 0;
574
575     /**
576      * md5 ($hash.$challenge)
577      */
578
579     a = MD5M_A;
580     b = MD5M_B;
581     c = MD5M_C;
582     d = MD5M_D;
583
584     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
585     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
586     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
587     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
588     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
589     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
590     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
591     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
592     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
593     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
594     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
595     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
596     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
597     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
598     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
599     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
600
601     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
602     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
603     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
604     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
605     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
606     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
607     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
608     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
609     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
610     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
611     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
612     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
613     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
614     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
615     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
616     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
617
618     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
619     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
620     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
621     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
622     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
623     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
624     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
625     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
626     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
627     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
628     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
629     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
630     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
631     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
632     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
633     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
634
635     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
636     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
637     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
638     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
639     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
640     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
641     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
642     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
643     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
644     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
645     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
646     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
647     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
648
649     if (MATCHES_NONE_VS (a, search[0])) continue;
650
651     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
652     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
653     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
654
655     COMPARE_S_SIMD (a, d, c, b);
656   }
657 }
658
659 __kernel void m11100_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)
660 {
661   /**
662    * base
663    */
664
665   const u32 gid = get_global_id (0);
666   const u32 lid = get_local_id (0);
667   const u32 lsz = get_local_size (0);
668
669   /**
670    * bin2asc table
671    */
672
673   __local u32 l_bin2asc[256];
674
675   for (u32 i = lid; i < 256; i += lsz)
676   {
677     const u32 i0 = (i >> 0) & 15;
678     const u32 i1 = (i >> 4) & 15;
679
680     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
681                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
682   }
683
684   barrier (CLK_LOCAL_MEM_FENCE);
685
686   if (gid >= gid_max) return;
687
688   /**
689    * modifier
690    */
691
692   u32 w0[4];
693
694   w0[0] = pws[gid].i[ 0];
695   w0[1] = pws[gid].i[ 1];
696   w0[2] = pws[gid].i[ 2];
697   w0[3] = pws[gid].i[ 3];
698
699   u32 w1[4];
700
701   w1[0] = 0;
702   w1[1] = 0;
703   w1[2] = 0;
704   w1[3] = 0;
705
706   u32 w2[4];
707
708   w2[0] = 0;
709   w2[1] = 0;
710   w2[2] = 0;
711   w2[3] = 0;
712
713   u32 w3[4];
714
715   w3[0] = 0;
716   w3[1] = 0;
717   w3[2] = pws[gid].i[14];
718   w3[3] = 0;
719
720   const u32 pw_len = pws[gid].pw_len;
721
722   /**
723    * main
724    */
725
726   m11100m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
727 }
728
729 __kernel void m11100_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)
730 {
731   /**
732    * base
733    */
734
735   const u32 gid = get_global_id (0);
736   const u32 lid = get_local_id (0);
737   const u32 lsz = get_local_size (0);
738
739   /**
740    * bin2asc table
741    */
742
743   __local u32 l_bin2asc[256];
744
745   for (u32 i = lid; i < 256; i += lsz)
746   {
747     const u32 i0 = (i >> 0) & 15;
748     const u32 i1 = (i >> 4) & 15;
749
750     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
751                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
752   }
753
754   barrier (CLK_LOCAL_MEM_FENCE);
755
756   if (gid >= gid_max) return;
757
758   /**
759    * modifier
760    */
761
762   u32 w0[4];
763
764   w0[0] = pws[gid].i[ 0];
765   w0[1] = pws[gid].i[ 1];
766   w0[2] = pws[gid].i[ 2];
767   w0[3] = pws[gid].i[ 3];
768
769   u32 w1[4];
770
771   w1[0] = pws[gid].i[ 4];
772   w1[1] = pws[gid].i[ 5];
773   w1[2] = pws[gid].i[ 6];
774   w1[3] = pws[gid].i[ 7];
775
776   u32 w2[4];
777
778   w2[0] = 0;
779   w2[1] = 0;
780   w2[2] = 0;
781   w2[3] = 0;
782
783   u32 w3[4];
784
785   w3[0] = 0;
786   w3[1] = 0;
787   w3[2] = pws[gid].i[14];
788   w3[3] = 0;
789
790   const u32 pw_len = pws[gid].pw_len;
791
792   /**
793    * main
794    */
795
796   m11100m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
797 }
798
799 __kernel void m11100_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)
800 {
801   /**
802    * base
803    */
804
805   const u32 gid = get_global_id (0);
806   const u32 lid = get_local_id (0);
807   const u32 lsz = get_local_size (0);
808
809   /**
810    * bin2asc table
811    */
812
813   __local u32 l_bin2asc[256];
814
815   for (u32 i = lid; i < 256; i += lsz)
816   {
817     const u32 i0 = (i >> 0) & 15;
818     const u32 i1 = (i >> 4) & 15;
819
820     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
821                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
822   }
823
824   barrier (CLK_LOCAL_MEM_FENCE);
825
826   if (gid >= gid_max) return;
827
828   /**
829    * modifier
830    */
831
832   u32 w0[4];
833
834   w0[0] = pws[gid].i[ 0];
835   w0[1] = pws[gid].i[ 1];
836   w0[2] = pws[gid].i[ 2];
837   w0[3] = pws[gid].i[ 3];
838
839   u32 w1[4];
840
841   w1[0] = pws[gid].i[ 4];
842   w1[1] = pws[gid].i[ 5];
843   w1[2] = pws[gid].i[ 6];
844   w1[3] = pws[gid].i[ 7];
845
846   u32 w2[4];
847
848   w2[0] = pws[gid].i[ 8];
849   w2[1] = pws[gid].i[ 9];
850   w2[2] = pws[gid].i[10];
851   w2[3] = pws[gid].i[11];
852
853   u32 w3[4];
854
855   w3[0] = pws[gid].i[12];
856   w3[1] = pws[gid].i[13];
857   w3[2] = pws[gid].i[14];
858   w3[3] = pws[gid].i[15];
859
860   const u32 pw_len = pws[gid].pw_len;
861
862   /**
863    * main
864    */
865
866   m11100m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
867 }
868
869 __kernel void m11100_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)
870 {
871   /**
872    * base
873    */
874
875   const u32 gid = get_global_id (0);
876   const u32 lid = get_local_id (0);
877   const u32 lsz = get_local_size (0);
878
879   /**
880    * bin2asc table
881    */
882
883   __local u32 l_bin2asc[256];
884
885   for (u32 i = lid; i < 256; i += lsz)
886   {
887     const u32 i0 = (i >> 0) & 15;
888     const u32 i1 = (i >> 4) & 15;
889
890     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
891                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
892   }
893
894   barrier (CLK_LOCAL_MEM_FENCE);
895
896   if (gid >= gid_max) return;
897
898   /**
899    * modifier
900    */
901
902   u32 w0[4];
903
904   w0[0] = pws[gid].i[ 0];
905   w0[1] = pws[gid].i[ 1];
906   w0[2] = pws[gid].i[ 2];
907   w0[3] = pws[gid].i[ 3];
908
909   u32 w1[4];
910
911   w1[0] = 0;
912   w1[1] = 0;
913   w1[2] = 0;
914   w1[3] = 0;
915
916   u32 w2[4];
917
918   w2[0] = 0;
919   w2[1] = 0;
920   w2[2] = 0;
921   w2[3] = 0;
922
923   u32 w3[4];
924
925   w3[0] = 0;
926   w3[1] = 0;
927   w3[2] = pws[gid].i[14];
928   w3[3] = 0;
929
930   const u32 pw_len = pws[gid].pw_len;
931
932   /**
933    * main
934    */
935
936   m11100s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
937 }
938
939 __kernel void m11100_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)
940 {
941   /**
942    * base
943    */
944
945   const u32 gid = get_global_id (0);
946   const u32 lid = get_local_id (0);
947   const u32 lsz = get_local_size (0);
948
949   /**
950    * bin2asc table
951    */
952
953   __local u32 l_bin2asc[256];
954
955   for (u32 i = lid; i < 256; i += lsz)
956   {
957     const u32 i0 = (i >> 0) & 15;
958     const u32 i1 = (i >> 4) & 15;
959
960     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
961                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
962   }
963
964   barrier (CLK_LOCAL_MEM_FENCE);
965
966   if (gid >= gid_max) return;
967
968   /**
969    * modifier
970    */
971
972   u32 w0[4];
973
974   w0[0] = pws[gid].i[ 0];
975   w0[1] = pws[gid].i[ 1];
976   w0[2] = pws[gid].i[ 2];
977   w0[3] = pws[gid].i[ 3];
978
979   u32 w1[4];
980
981   w1[0] = pws[gid].i[ 4];
982   w1[1] = pws[gid].i[ 5];
983   w1[2] = pws[gid].i[ 6];
984   w1[3] = pws[gid].i[ 7];
985
986   u32 w2[4];
987
988   w2[0] = 0;
989   w2[1] = 0;
990   w2[2] = 0;
991   w2[3] = 0;
992
993   u32 w3[4];
994
995   w3[0] = 0;
996   w3[1] = 0;
997   w3[2] = pws[gid].i[14];
998   w3[3] = 0;
999
1000   const u32 pw_len = pws[gid].pw_len;
1001
1002   /**
1003    * main
1004    */
1005
1006   m11100s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
1007 }
1008
1009 __kernel void m11100_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)
1010 {
1011   /**
1012    * base
1013    */
1014
1015   const u32 gid = get_global_id (0);
1016   const u32 lid = get_local_id (0);
1017   const u32 lsz = get_local_size (0);
1018
1019   /**
1020    * bin2asc table
1021    */
1022
1023   __local u32 l_bin2asc[256];
1024
1025   for (u32 i = lid; i < 256; i += lsz)
1026   {
1027     const u32 i0 = (i >> 0) & 15;
1028     const u32 i1 = (i >> 4) & 15;
1029
1030     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
1031                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
1032   }
1033
1034   barrier (CLK_LOCAL_MEM_FENCE);
1035
1036   if (gid >= gid_max) return;
1037
1038   /**
1039    * modifier
1040    */
1041
1042   u32 w0[4];
1043
1044   w0[0] = pws[gid].i[ 0];
1045   w0[1] = pws[gid].i[ 1];
1046   w0[2] = pws[gid].i[ 2];
1047   w0[3] = pws[gid].i[ 3];
1048
1049   u32 w1[4];
1050
1051   w1[0] = pws[gid].i[ 4];
1052   w1[1] = pws[gid].i[ 5];
1053   w1[2] = pws[gid].i[ 6];
1054   w1[3] = pws[gid].i[ 7];
1055
1056   u32 w2[4];
1057
1058   w2[0] = pws[gid].i[ 8];
1059   w2[1] = pws[gid].i[ 9];
1060   w2[2] = pws[gid].i[10];
1061   w2[3] = pws[gid].i[11];
1062
1063   u32 w3[4];
1064
1065   w3[0] = pws[gid].i[12];
1066   w3[1] = pws[gid].i[13];
1067   w3[2] = pws[gid].i[14];
1068   w3[3] = pws[gid].i[15];
1069
1070   const u32 pw_len = pws[gid].pw_len;
1071
1072   /**
1073    * main
1074    */
1075
1076   m11100s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
1077 }