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