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