2 * Author......: Jens Steube <jens.steube@gmail.com>
10 #include "inc_vendor.cl"
11 #include "inc_hash_constants.h"
12 #include "inc_hash_functions.cl"
13 #include "inc_types.cl"
14 #include "inc_common.cl"
15 #include "inc_simd.cl"
18 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)])
20 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
22 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
24 #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])
26 #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])
29 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
35 const u32 gid = get_global_id (0);
36 const u32 lid = get_local_id (0);
37 const u32 lsz = get_local_size (0);
43 __local u32 l_bin2asc[256];
45 for (u32 i = lid; i < 256; i += lsz)
47 const u32 i0 = (i >> 0) & 15;
48 const u32 i1 = (i >> 4) & 15;
50 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
51 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
54 barrier (CLK_LOCAL_MEM_FENCE);
56 if (gid >= gid_max) return;
65 pw_buf0[0] = pws[gid].i[0];
66 pw_buf0[1] = pws[gid].i[1];
67 pw_buf0[2] = pws[gid].i[2];
68 pw_buf0[3] = pws[gid].i[3];
69 pw_buf1[0] = pws[gid].i[4];
70 pw_buf1[1] = pws[gid].i[5];
71 pw_buf1[2] = pws[gid].i[6];
72 pw_buf1[3] = pws[gid].i[7];
74 const u32 pw_l_len = pws[gid].pw_len;
85 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0];
86 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1];
87 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2];
88 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[3];
89 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[4];
90 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[5];
102 const u32 salt_len = salt_bufs[salt_pos].salt_len;
108 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
110 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
112 const u32x pw_len = pw_l_len + pw_r_len;
115 * concat password candidate
118 u32x wordl0[4] = { 0 };
119 u32x wordl1[4] = { 0 };
120 u32x wordl2[4] = { 0 };
121 u32x wordl3[4] = { 0 };
123 wordl0[0] = pw_buf0[0];
124 wordl0[1] = pw_buf0[1];
125 wordl0[2] = pw_buf0[2];
126 wordl0[3] = pw_buf0[3];
127 wordl1[0] = pw_buf1[0];
128 wordl1[1] = pw_buf1[1];
129 wordl1[2] = pw_buf1[2];
130 wordl1[3] = pw_buf1[3];
132 u32x wordr0[4] = { 0 };
133 u32x wordr1[4] = { 0 };
134 u32x wordr2[4] = { 0 };
135 u32x wordr3[4] = { 0 };
137 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
138 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
139 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
140 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
141 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
142 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
143 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
144 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
146 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
148 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
152 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
160 w0[0] = wordl0[0] | wordr0[0];
161 w0[1] = wordl0[1] | wordr0[1];
162 w0[2] = wordl0[2] | wordr0[2];
163 w0[3] = wordl0[3] | wordr0[3];
164 w1[0] = wordl1[0] | wordr1[0];
165 w1[1] = wordl1[1] | wordr1[1];
166 w1[2] = wordl1[2] | wordr1[2];
167 w1[3] = wordl1[3] | wordr1[3];
168 w2[0] = wordl2[0] | wordr2[0];
169 w2[1] = wordl2[1] | wordr2[1];
170 w2[2] = wordl2[2] | wordr2[2];
171 w2[3] = wordl2[3] | wordr2[3];
172 w3[0] = wordl3[0] | wordr3[0];
173 w3[1] = wordl3[1] | wordr3[1];
186 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
187 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
188 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
189 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
190 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
191 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
192 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
193 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
194 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
195 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
196 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
197 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
198 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
199 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
200 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
201 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
203 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
204 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
205 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
206 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
207 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
208 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
209 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
210 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
211 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
212 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
213 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
214 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
215 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
216 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
217 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
218 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
220 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
221 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
222 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
223 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
224 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
225 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
226 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
227 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
228 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
229 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
230 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
231 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
232 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
233 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
234 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
235 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
237 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
238 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
239 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
240 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
241 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
242 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
243 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
244 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
245 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
246 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
247 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
248 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
249 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
250 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
251 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
252 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
259 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
260 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
261 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
262 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
263 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
264 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
265 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
266 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
267 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
268 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
269 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
270 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
271 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
272 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
273 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
274 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
276 w2[0] = salt_buf0[0];
277 w2[1] = salt_buf0[1];
278 w2[2] = salt_buf0[2];
279 w2[3] = salt_buf0[3];
280 w3[0] = salt_buf1[0];
281 w3[1] = salt_buf1[1];
282 w3[2] = (32 + salt_len) * 8;
290 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
291 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
292 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
293 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
294 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
295 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
296 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
297 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
298 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
299 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
300 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
301 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
302 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
303 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
304 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
305 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
307 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
308 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
309 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
310 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
311 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
312 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
313 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
314 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
315 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
316 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
317 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
318 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
319 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
320 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
321 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
322 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
324 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
325 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
326 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
327 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
328 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
329 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
330 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
331 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
332 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
333 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
334 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
335 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
336 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
337 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
338 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
339 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
341 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
342 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
343 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
344 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
345 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
346 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
347 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
348 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
349 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
350 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
351 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
352 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
353 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
354 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
355 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
356 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
358 COMPARE_M_SIMD (a, d, c, b);
362 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
366 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
370 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
376 const u32 gid = get_global_id (0);
377 const u32 lid = get_local_id (0);
378 const u32 lsz = get_local_size (0);
384 __local u32 l_bin2asc[256];
386 for (u32 i = lid; i < 256; i += lsz)
388 const u32 i0 = (i >> 0) & 15;
389 const u32 i1 = (i >> 4) & 15;
391 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
392 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
395 barrier (CLK_LOCAL_MEM_FENCE);
397 if (gid >= gid_max) return;
406 pw_buf0[0] = pws[gid].i[0];
407 pw_buf0[1] = pws[gid].i[1];
408 pw_buf0[2] = pws[gid].i[2];
409 pw_buf0[3] = pws[gid].i[3];
410 pw_buf1[0] = pws[gid].i[4];
411 pw_buf1[1] = pws[gid].i[5];
412 pw_buf1[2] = pws[gid].i[6];
413 pw_buf1[3] = pws[gid].i[7];
415 const u32 pw_l_len = pws[gid].pw_len;
426 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0];
427 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1];
428 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2];
429 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[3];
430 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[4];
431 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[5];
443 const u32 salt_len = salt_bufs[salt_pos].salt_len;
449 const u32 search[4] =
451 digests_buf[digests_offset].digest_buf[DGST_R0],
452 digests_buf[digests_offset].digest_buf[DGST_R1],
453 digests_buf[digests_offset].digest_buf[DGST_R2],
454 digests_buf[digests_offset].digest_buf[DGST_R3]
461 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
463 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
465 const u32x pw_len = pw_l_len + pw_r_len;
468 * concat password candidate
471 u32x wordl0[4] = { 0 };
472 u32x wordl1[4] = { 0 };
473 u32x wordl2[4] = { 0 };
474 u32x wordl3[4] = { 0 };
476 wordl0[0] = pw_buf0[0];
477 wordl0[1] = pw_buf0[1];
478 wordl0[2] = pw_buf0[2];
479 wordl0[3] = pw_buf0[3];
480 wordl1[0] = pw_buf1[0];
481 wordl1[1] = pw_buf1[1];
482 wordl1[2] = pw_buf1[2];
483 wordl1[3] = pw_buf1[3];
485 u32x wordr0[4] = { 0 };
486 u32x wordr1[4] = { 0 };
487 u32x wordr2[4] = { 0 };
488 u32x wordr3[4] = { 0 };
490 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
491 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
492 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
493 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
494 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
495 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
496 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
497 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
499 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
501 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
505 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
513 w0[0] = wordl0[0] | wordr0[0];
514 w0[1] = wordl0[1] | wordr0[1];
515 w0[2] = wordl0[2] | wordr0[2];
516 w0[3] = wordl0[3] | wordr0[3];
517 w1[0] = wordl1[0] | wordr1[0];
518 w1[1] = wordl1[1] | wordr1[1];
519 w1[2] = wordl1[2] | wordr1[2];
520 w1[3] = wordl1[3] | wordr1[3];
521 w2[0] = wordl2[0] | wordr2[0];
522 w2[1] = wordl2[1] | wordr2[1];
523 w2[2] = wordl2[2] | wordr2[2];
524 w2[3] = wordl2[3] | wordr2[3];
525 w3[0] = wordl3[0] | wordr3[0];
526 w3[1] = wordl3[1] | wordr3[1];
539 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
540 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
541 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
542 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
543 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
544 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
545 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
546 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
547 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
548 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
549 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
550 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
551 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
552 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
553 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
554 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
556 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
557 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
558 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
559 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
560 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
561 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
562 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
563 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
564 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
565 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
566 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
567 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
568 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
569 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
570 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
571 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
573 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
574 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
575 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
576 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
577 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
578 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
579 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
580 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
581 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
582 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
583 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
584 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
585 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
586 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
587 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
588 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
590 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
591 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
592 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
593 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
594 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
595 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
596 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
597 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
598 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
599 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
600 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
601 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
602 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
603 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
604 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
605 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
612 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
613 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
614 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
615 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
616 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
617 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
618 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
619 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
620 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
621 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
622 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
623 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
624 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
625 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
626 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
627 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
629 w2[0] = salt_buf0[0];
630 w2[1] = salt_buf0[1];
631 w2[2] = salt_buf0[2];
632 w2[3] = salt_buf0[3];
633 w3[0] = salt_buf1[0];
634 w3[1] = salt_buf1[1];
635 w3[2] = (32 + salt_len) * 8;
643 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
644 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
645 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
646 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
647 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
648 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
649 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
650 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
651 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
652 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
653 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
654 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
655 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
656 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
657 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
658 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
660 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
661 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
662 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
663 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
664 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
665 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
666 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
667 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
668 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
669 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
670 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
671 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
672 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
673 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
674 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
675 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
677 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
678 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
679 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
680 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
681 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
682 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
683 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
684 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
685 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
686 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
687 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
688 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
689 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
690 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
691 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
692 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
694 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
695 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
696 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
697 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
698 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
699 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
700 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
701 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
702 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
703 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
704 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
705 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
706 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
708 if (MATCHES_NONE_VS (a, search[0])) continue;
710 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
711 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
712 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
714 COMPARE_S_SIMD (a, d, c, b);
718 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
722 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)