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