2 * Author......: Jens Steube <jens.steube@gmail.com>
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
16 #include "include/kernel_functions.c"
17 #include "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
20 #define COMPARE_S "OpenCL/check_single_comp4.c"
21 #define COMPARE_M "OpenCL/check_multi_comp4.c"
23 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
25 __kernel void m11100_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
31 const u32 gid = get_global_id (0);
32 const u32 lid = get_local_id (0);
33 const u32 lsz = get_local_size (0);
39 __local u32 l_bin2asc[256];
41 for (u32 i = lid; i < 256; i += lsz)
43 const u32 i0 = (i >> 0) & 15;
44 const u32 i1 = (i >> 4) & 15;
46 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
47 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
50 barrier (CLK_LOCAL_MEM_FENCE);
52 if (gid >= gid_max) return;
60 wordl0[0] = pws[gid].i[ 0];
61 wordl0[1] = pws[gid].i[ 1];
62 wordl0[2] = pws[gid].i[ 2];
63 wordl0[3] = pws[gid].i[ 3];
67 wordl1[0] = pws[gid].i[ 4];
68 wordl1[1] = pws[gid].i[ 5];
69 wordl1[2] = pws[gid].i[ 6];
70 wordl1[3] = pws[gid].i[ 7];
86 const u32 pw_l_len = pws[gid].pw_len;
88 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
90 switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
99 challenge = salt_bufs[salt_pos].salt_buf[0];
107 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug
108 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
109 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
110 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
114 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
115 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
116 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
117 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
119 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
125 for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
127 const u32 pw_r_len = combs_buf[il_pos].pw_len;
129 const u32 pw_len = pw_l_len + pw_r_len;
133 wordr0[0] = combs_buf[il_pos].i[0];
134 wordr0[1] = combs_buf[il_pos].i[1];
135 wordr0[2] = combs_buf[il_pos].i[2];
136 wordr0[3] = combs_buf[il_pos].i[3];
140 wordr1[0] = combs_buf[il_pos].i[4];
141 wordr1[1] = combs_buf[il_pos].i[5];
142 wordr1[2] = combs_buf[il_pos].i[6];
143 wordr1[3] = combs_buf[il_pos].i[7];
159 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
161 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
166 w0_t[0] = salt_buf0[0];
167 w0_t[1] = salt_buf0[1];
168 w0_t[2] = salt_buf0[2];
169 w0_t[3] = salt_buf0[3];
173 w1_t[0] = salt_buf1[0];
174 w1_t[1] = salt_buf1[1];
175 w1_t[2] = salt_buf1[2];
176 w1_t[3] = salt_buf1[3];
196 switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, pw_len);
198 const u32 pw_salt_len = pw_len + salt_len;
200 w0_t[0] |= wordl0[0] | wordr0[0];
201 w0_t[1] |= wordl0[1] | wordr0[1];
202 w0_t[2] |= wordl0[2] | wordr0[2];
203 w0_t[3] |= wordl0[3] | wordr0[3];
205 w1_t[0] |= wordl1[0] | wordr1[0];
206 w1_t[1] |= wordl1[1] | wordr1[1];
207 w1_t[2] |= wordl1[2] | wordr1[2];
208 w1_t[3] |= wordl1[3] | wordr1[3];
210 w2_t[0] |= wordl2[0] | wordr2[0];
211 w2_t[1] |= wordl2[1] | wordr2[1];
212 w2_t[2] |= wordl2[2] | wordr2[2];
213 w2_t[3] |= wordl2[3] | wordr2[3];
215 w3_t[0] |= wordl3[0] | wordr3[0];
216 w3_t[1] |= wordl3[0] | wordr3[0];
217 w3_t[2] = pw_salt_len * 8;
229 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
230 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
231 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
232 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
233 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
234 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
235 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
236 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
237 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
238 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
239 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
240 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
241 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
242 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
243 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
244 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
246 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
247 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
248 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
249 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
250 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
251 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
252 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
253 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
254 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
255 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
256 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
257 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
258 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
259 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
260 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
261 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
263 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
264 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
265 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
266 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
267 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
268 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
269 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
270 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
271 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
272 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
273 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
274 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
275 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
276 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
277 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
278 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
280 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
281 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
282 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
283 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
284 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
285 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
286 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
287 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
288 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
289 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
290 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
291 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
292 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
293 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
294 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
295 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
302 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
303 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
304 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
305 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
306 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
307 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
308 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
309 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
310 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
311 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
312 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
313 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
314 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
315 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
316 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
317 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
319 // add the 4 byte challenge here
322 w2_t[1] = 0x00000080;
328 w3_t[2] = (32 + 4) * 8;
332 * md5 ($hash.$challenge)
340 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
341 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
342 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
343 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
344 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
345 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
346 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
347 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
348 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
349 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
350 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
351 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
352 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
353 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
354 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
355 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
357 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
358 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
359 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
360 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
361 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
362 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
363 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
364 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
365 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
366 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
367 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
368 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
369 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
370 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
371 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
372 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
374 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
375 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
376 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
377 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
378 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
379 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
380 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
381 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
382 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
383 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
384 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
385 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
386 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
387 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
388 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
389 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
391 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
392 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
393 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
394 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
395 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
396 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
397 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
398 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
399 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
400 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
401 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
402 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
403 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
404 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
405 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
406 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
417 __kernel void m11100_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
421 __kernel void m11100_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
425 __kernel void m11100_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
431 const u32 gid = get_global_id (0);
432 const u32 lid = get_local_id (0);
433 const u32 lsz = get_local_size (0);
439 __local u32 l_bin2asc[256];
441 for (u32 i = lid; i < 256; i += lsz)
443 const u32 i0 = (i >> 0) & 15;
444 const u32 i1 = (i >> 4) & 15;
446 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
447 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
450 barrier (CLK_LOCAL_MEM_FENCE);
452 if (gid >= gid_max) return;
460 wordl0[0] = pws[gid].i[ 0];
461 wordl0[1] = pws[gid].i[ 1];
462 wordl0[2] = pws[gid].i[ 2];
463 wordl0[3] = pws[gid].i[ 3];
467 wordl1[0] = pws[gid].i[ 4];
468 wordl1[1] = pws[gid].i[ 5];
469 wordl1[2] = pws[gid].i[ 6];
470 wordl1[3] = pws[gid].i[ 7];
486 const u32 pw_l_len = pws[gid].pw_len;
488 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
490 switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
499 challenge = salt_bufs[salt_pos].salt_buf[0];
507 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug
508 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
509 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
510 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
514 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
515 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
516 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
517 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
519 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
525 const u32 search[4] =
527 digests_buf[digests_offset].digest_buf[DGST_R0],
528 digests_buf[digests_offset].digest_buf[DGST_R1],
529 digests_buf[digests_offset].digest_buf[DGST_R2],
530 digests_buf[digests_offset].digest_buf[DGST_R3]
537 for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
539 const u32 pw_r_len = combs_buf[il_pos].pw_len;
541 const u32 pw_len = pw_l_len + pw_r_len;
545 wordr0[0] = combs_buf[il_pos].i[0];
546 wordr0[1] = combs_buf[il_pos].i[1];
547 wordr0[2] = combs_buf[il_pos].i[2];
548 wordr0[3] = combs_buf[il_pos].i[3];
552 wordr1[0] = combs_buf[il_pos].i[4];
553 wordr1[1] = combs_buf[il_pos].i[5];
554 wordr1[2] = combs_buf[il_pos].i[6];
555 wordr1[3] = combs_buf[il_pos].i[7];
571 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
573 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
578 w0_t[0] = salt_buf0[0];
579 w0_t[1] = salt_buf0[1];
580 w0_t[2] = salt_buf0[2];
581 w0_t[3] = salt_buf0[3];
585 w1_t[0] = salt_buf1[0];
586 w1_t[1] = salt_buf1[1];
587 w1_t[2] = salt_buf1[2];
588 w1_t[3] = salt_buf1[3];
608 switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, pw_len);
610 const u32 pw_salt_len = pw_len + salt_len;
612 w0_t[0] |= wordl0[0] | wordr0[0];
613 w0_t[1] |= wordl0[1] | wordr0[1];
614 w0_t[2] |= wordl0[2] | wordr0[2];
615 w0_t[3] |= wordl0[3] | wordr0[3];
617 w1_t[0] |= wordl1[0] | wordr1[0];
618 w1_t[1] |= wordl1[1] | wordr1[1];
619 w1_t[2] |= wordl1[2] | wordr1[2];
620 w1_t[3] |= wordl1[3] | wordr1[3];
622 w2_t[0] |= wordl2[0] | wordr2[0];
623 w2_t[1] |= wordl2[1] | wordr2[1];
624 w2_t[2] |= wordl2[2] | wordr2[2];
625 w2_t[3] |= wordl2[3] | wordr2[3];
627 w3_t[0] |= wordl3[0] | wordr3[0];
628 w3_t[1] |= wordl3[0] | wordr3[0];
629 w3_t[2] = pw_salt_len * 8;
641 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
642 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
643 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
644 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
645 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
646 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
647 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
648 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
649 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
650 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
651 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
652 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
653 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
654 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
655 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
656 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
658 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
659 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
660 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
661 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
662 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
663 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
664 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
665 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
666 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
667 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
668 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
669 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
670 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
671 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
672 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
673 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
675 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
676 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
677 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
678 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
679 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
680 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
681 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
682 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
683 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
684 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
685 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
686 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
687 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
688 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
689 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
690 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
692 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
693 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
694 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
695 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
696 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
697 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
698 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
699 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
700 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
701 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
702 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
703 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
704 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
705 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
706 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
707 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
714 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
715 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
716 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
717 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
718 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
719 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
720 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
721 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
722 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
723 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
724 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
725 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
726 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
727 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
728 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
729 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
731 // add the 4 byte challenge here
734 w2_t[1] = 0x00000080;
740 w3_t[2] = (32 + 4) * 8;
744 * md5 ($hash.$challenge)
752 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
753 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
754 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
755 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
756 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
757 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
758 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
759 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
760 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
761 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
762 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
763 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
764 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
765 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
766 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
767 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
769 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
770 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
771 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
772 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
773 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
774 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
775 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
776 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
777 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
778 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
779 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
780 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
781 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
782 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
783 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
784 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
786 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
787 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
788 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
789 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
790 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
791 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
792 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
793 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
794 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
795 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
796 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
797 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
798 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
799 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
800 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
801 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
803 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
804 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
805 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
806 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
807 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
808 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
809 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
810 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
811 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
812 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
813 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
814 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
815 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
816 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
817 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
818 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
829 __kernel void m11100_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
833 __kernel void m11100_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)