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