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