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 "types_ocl.c"
19 #include "include/rp_gpu.h"
22 #define COMPARE_S "check_single_comp4.c"
23 #define COMPARE_M "check_multi_comp4.c"
26 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
30 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
34 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
37 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m11100_m04 (__global pw_t *pws, __global gpu_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
43 const u32 lid = get_local_id (0);
49 const u32 gid = get_global_id (0);
53 pw_buf0[0] = pws[gid].i[ 0];
54 pw_buf0[1] = pws[gid].i[ 1];
55 pw_buf0[2] = pws[gid].i[ 2];
56 pw_buf0[3] = pws[gid].i[ 3];
60 pw_buf1[0] = pws[gid].i[ 4];
61 pw_buf1[1] = pws[gid].i[ 5];
62 pw_buf1[2] = pws[gid].i[ 6];
63 pw_buf1[3] = pws[gid].i[ 7];
65 const u32 pw_len = pws[gid].pw_len;
73 challenge = salt_bufs[salt_pos].salt_buf[0];
81 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug
82 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
83 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
84 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
88 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
89 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
90 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
91 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
93 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
99 __local u32 l_bin2asc[256];
101 const u32 lid4 = lid * 4;
103 const u32 lid40 = lid4 + 0;
104 const u32 lid41 = lid4 + 1;
105 const u32 lid42 = lid4 + 2;
106 const u32 lid43 = lid4 + 3;
108 const u32 v400 = (lid40 >> 0) & 15;
109 const u32 v401 = (lid40 >> 4) & 15;
110 const u32 v410 = (lid41 >> 0) & 15;
111 const u32 v411 = (lid41 >> 4) & 15;
112 const u32 v420 = (lid42 >> 0) & 15;
113 const u32 v421 = (lid42 >> 4) & 15;
114 const u32 v430 = (lid43 >> 0) & 15;
115 const u32 v431 = (lid43 >> 4) & 15;
117 l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
118 | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
119 l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
120 | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
121 l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
122 | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
123 l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
124 | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
126 barrier (CLK_LOCAL_MEM_FENCE);
128 if (gid >= gid_max) return;
134 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
164 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
168 w0_t[0] = salt_buf0[0];
169 w0_t[1] = salt_buf0[1];
170 w0_t[2] = salt_buf0[2];
171 w0_t[3] = salt_buf0[3];
175 w1_t[0] = salt_buf1[0];
176 w1_t[1] = salt_buf1[1];
177 w1_t[2] = salt_buf1[2];
178 w1_t[3] = salt_buf1[3];
198 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
200 const u32 pw_salt_len = out_len + salt_len;
219 w3_t[2] = pw_salt_len * 8;
231 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
232 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
233 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
234 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
235 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
236 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
237 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
238 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
239 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
240 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
241 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
242 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
243 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
244 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
245 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
246 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
248 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
249 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
250 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
251 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
252 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
253 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
254 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
255 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
256 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
257 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
258 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
259 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
260 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
261 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
262 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
263 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
265 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
266 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
267 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
268 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
269 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
270 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
271 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
272 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
273 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
274 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
275 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
276 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
277 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
278 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
279 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
280 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
282 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
283 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
284 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
285 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
286 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
287 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
288 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
289 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
290 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
291 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
292 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
293 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
294 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
295 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
296 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
297 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
304 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
305 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
306 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
307 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
308 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
309 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
310 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
311 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
312 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
313 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
314 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
315 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
316 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
317 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
318 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
319 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
321 // add the 4 byte challenge here
324 w2_t[1] = 0x00000080;
330 w3_t[2] = (32 + 4) * 8;
334 * md5 ($hash.$challenge)
342 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
343 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
344 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
345 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
346 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
347 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
348 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
349 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
350 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
351 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
352 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
353 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
354 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
355 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
356 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
357 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
359 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
360 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
361 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
362 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
363 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
364 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
365 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
366 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
367 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
368 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
369 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
370 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
371 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
372 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
373 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
374 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
376 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
377 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
378 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
379 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
380 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
381 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
382 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
383 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
384 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
385 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
386 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
387 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
388 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
389 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
390 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
391 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
393 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
394 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
395 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
396 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
397 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
398 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
399 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
400 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
401 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
402 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
403 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
404 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
405 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
406 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
407 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
408 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
419 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m11100_m08 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
423 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m11100_m16 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
427 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m11100_s04 (__global pw_t *pws, __global gpu_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
433 const u32 lid = get_local_id (0);
439 const u32 gid = get_global_id (0);
443 pw_buf0[0] = pws[gid].i[ 0];
444 pw_buf0[1] = pws[gid].i[ 1];
445 pw_buf0[2] = pws[gid].i[ 2];
446 pw_buf0[3] = pws[gid].i[ 3];
450 pw_buf1[0] = pws[gid].i[ 4];
451 pw_buf1[1] = pws[gid].i[ 5];
452 pw_buf1[2] = pws[gid].i[ 6];
453 pw_buf1[3] = pws[gid].i[ 7];
455 const u32 pw_len = pws[gid].pw_len;
463 challenge = salt_bufs[salt_pos].salt_buf[0];
471 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug
472 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
473 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
474 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
478 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
479 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
480 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
481 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
483 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
489 const u32 search[4] =
491 digests_buf[digests_offset].digest_buf[DGST_R0],
492 digests_buf[digests_offset].digest_buf[DGST_R1],
493 digests_buf[digests_offset].digest_buf[DGST_R2],
494 digests_buf[digests_offset].digest_buf[DGST_R3]
501 __local u32 l_bin2asc[256];
503 const u32 lid4 = lid * 4;
505 const u32 lid40 = lid4 + 0;
506 const u32 lid41 = lid4 + 1;
507 const u32 lid42 = lid4 + 2;
508 const u32 lid43 = lid4 + 3;
510 const u32 v400 = (lid40 >> 0) & 15;
511 const u32 v401 = (lid40 >> 4) & 15;
512 const u32 v410 = (lid41 >> 0) & 15;
513 const u32 v411 = (lid41 >> 4) & 15;
514 const u32 v420 = (lid42 >> 0) & 15;
515 const u32 v421 = (lid42 >> 4) & 15;
516 const u32 v430 = (lid43 >> 0) & 15;
517 const u32 v431 = (lid43 >> 4) & 15;
519 l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
520 | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
521 l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
522 | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
523 l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
524 | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
525 l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
526 | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
528 barrier (CLK_LOCAL_MEM_FENCE);
530 if (gid >= gid_max) return;
536 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
566 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
570 w0_t[0] = salt_buf0[0];
571 w0_t[1] = salt_buf0[1];
572 w0_t[2] = salt_buf0[2];
573 w0_t[3] = salt_buf0[3];
577 w1_t[0] = salt_buf1[0];
578 w1_t[1] = salt_buf1[1];
579 w1_t[2] = salt_buf1[2];
580 w1_t[3] = salt_buf1[3];
600 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
602 const u32 pw_salt_len = out_len + salt_len;
621 w3_t[2] = pw_salt_len * 8;
633 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
634 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
635 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
636 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
637 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
638 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
639 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
640 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
641 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
642 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
643 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
644 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
645 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
646 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
647 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
648 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
650 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
651 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
652 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
653 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
654 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
655 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
656 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
657 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
658 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
659 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
660 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
661 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
662 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
663 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
664 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
665 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
667 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
668 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
669 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
670 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
671 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
672 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
673 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
674 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
675 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
676 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
677 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
678 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
679 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
680 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
681 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
682 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
684 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
685 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
686 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
687 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
688 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
689 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
690 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
691 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
692 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
693 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
694 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
695 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
696 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
697 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
698 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
699 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
706 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
707 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
708 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
709 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
710 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
711 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
712 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
713 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
714 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
715 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
716 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
717 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
718 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
719 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
720 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
721 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
723 // add the 4 byte challenge here
726 w2_t[1] = 0x00000080;
732 w3_t[2] = (32 + 4) * 8;
736 * md5 ($hash.$challenge)
744 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
745 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
746 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
747 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
748 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
749 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
750 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
751 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
752 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
753 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
754 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
755 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
756 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
757 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
758 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
759 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
761 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
762 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
763 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
764 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
765 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
766 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
767 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
768 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
769 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
770 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
771 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
772 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
773 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
774 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
775 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
776 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
778 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
779 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
780 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
781 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
782 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
783 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
784 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
785 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
786 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
787 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
788 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
789 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
790 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
791 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
792 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
793 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
795 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
796 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
797 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
798 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
799 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
800 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
801 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
802 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
803 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
804 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
805 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
806 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
807 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
808 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
809 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
810 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
821 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m11100_s08 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
825 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m11100_s16 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)