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"
19 #include "include/rp_gpu.h"
22 #define COMPARE_S "OpenCL/check_single_comp4.c"
23 #define COMPARE_M "OpenCL/check_multi_comp4.c"
25 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
27 __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)
33 const u32 lid = get_local_id (0);
39 const u32 gid = get_global_id (0);
43 pw_buf0[0] = pws[gid].i[ 0];
44 pw_buf0[1] = pws[gid].i[ 1];
45 pw_buf0[2] = pws[gid].i[ 2];
46 pw_buf0[3] = pws[gid].i[ 3];
50 pw_buf1[0] = pws[gid].i[ 4];
51 pw_buf1[1] = pws[gid].i[ 5];
52 pw_buf1[2] = pws[gid].i[ 6];
53 pw_buf1[3] = pws[gid].i[ 7];
55 const u32 pw_len = pws[gid].pw_len;
63 challenge = salt_bufs[salt_pos].salt_buf[0];
71 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug
72 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
73 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
74 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
78 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
79 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
80 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
81 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
83 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
89 __local u32 l_bin2asc[256];
91 const u32 lid4 = lid * 4;
93 const u32 lid40 = lid4 + 0;
94 const u32 lid41 = lid4 + 1;
95 const u32 lid42 = lid4 + 2;
96 const u32 lid43 = lid4 + 3;
98 const u32 v400 = (lid40 >> 0) & 15;
99 const u32 v401 = (lid40 >> 4) & 15;
100 const u32 v410 = (lid41 >> 0) & 15;
101 const u32 v411 = (lid41 >> 4) & 15;
102 const u32 v420 = (lid42 >> 0) & 15;
103 const u32 v421 = (lid42 >> 4) & 15;
104 const u32 v430 = (lid43 >> 0) & 15;
105 const u32 v431 = (lid43 >> 4) & 15;
107 l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
108 | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
109 l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
110 | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
111 l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
112 | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
113 l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
114 | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
116 barrier (CLK_LOCAL_MEM_FENCE);
118 if (gid >= gid_max) return;
124 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
154 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
158 w0_t[0] = salt_buf0[0];
159 w0_t[1] = salt_buf0[1];
160 w0_t[2] = salt_buf0[2];
161 w0_t[3] = salt_buf0[3];
165 w1_t[0] = salt_buf1[0];
166 w1_t[1] = salt_buf1[1];
167 w1_t[2] = salt_buf1[2];
168 w1_t[3] = salt_buf1[3];
188 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
190 const u32 pw_salt_len = out_len + salt_len;
209 w3_t[2] = pw_salt_len * 8;
221 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
222 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
223 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
224 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
225 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
226 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
227 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
228 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
229 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
230 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
231 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
232 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
233 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
234 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
235 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
236 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
238 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
239 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
240 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
241 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
242 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
243 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
244 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
245 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
246 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
247 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
248 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
249 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
250 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
251 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
252 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
253 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
255 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
256 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
257 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
258 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
259 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
260 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
261 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
262 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
263 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
264 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
265 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
266 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
267 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
268 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
269 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
270 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
272 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
273 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
274 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
275 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
276 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
277 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
278 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
279 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
280 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
281 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
282 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
283 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
284 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
285 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
286 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
287 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
294 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
295 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
296 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
297 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
298 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
299 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
300 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
301 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
302 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
303 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
304 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
305 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
306 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
307 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
308 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
309 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
311 // add the 4 byte challenge here
314 w2_t[1] = 0x00000080;
320 w3_t[2] = (32 + 4) * 8;
324 * md5 ($hash.$challenge)
332 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
333 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
334 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
335 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
336 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
337 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
338 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
339 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
340 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
341 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
342 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
343 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
344 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
345 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
346 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
347 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
349 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
350 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
351 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
352 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
353 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
354 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
355 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
356 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
357 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
358 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
359 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
360 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
361 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
362 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
363 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
364 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
366 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
367 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
368 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
369 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
370 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
371 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
372 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
373 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
374 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
375 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
376 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
377 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
378 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
379 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
380 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
381 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
383 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
384 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
385 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
386 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
387 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
388 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
389 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
390 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
391 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
392 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
393 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
394 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
395 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
396 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
397 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
398 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
409 __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)
413 __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)
417 __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)
423 const u32 lid = get_local_id (0);
429 const u32 gid = get_global_id (0);
433 pw_buf0[0] = pws[gid].i[ 0];
434 pw_buf0[1] = pws[gid].i[ 1];
435 pw_buf0[2] = pws[gid].i[ 2];
436 pw_buf0[3] = pws[gid].i[ 3];
440 pw_buf1[0] = pws[gid].i[ 4];
441 pw_buf1[1] = pws[gid].i[ 5];
442 pw_buf1[2] = pws[gid].i[ 6];
443 pw_buf1[3] = pws[gid].i[ 7];
445 const u32 pw_len = pws[gid].pw_len;
453 challenge = salt_bufs[salt_pos].salt_buf[0];
461 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug
462 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
463 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
464 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
468 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
469 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
470 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
471 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
473 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
479 const u32 search[4] =
481 digests_buf[digests_offset].digest_buf[DGST_R0],
482 digests_buf[digests_offset].digest_buf[DGST_R1],
483 digests_buf[digests_offset].digest_buf[DGST_R2],
484 digests_buf[digests_offset].digest_buf[DGST_R3]
491 __local u32 l_bin2asc[256];
493 const u32 lid4 = lid * 4;
495 const u32 lid40 = lid4 + 0;
496 const u32 lid41 = lid4 + 1;
497 const u32 lid42 = lid4 + 2;
498 const u32 lid43 = lid4 + 3;
500 const u32 v400 = (lid40 >> 0) & 15;
501 const u32 v401 = (lid40 >> 4) & 15;
502 const u32 v410 = (lid41 >> 0) & 15;
503 const u32 v411 = (lid41 >> 4) & 15;
504 const u32 v420 = (lid42 >> 0) & 15;
505 const u32 v421 = (lid42 >> 4) & 15;
506 const u32 v430 = (lid43 >> 0) & 15;
507 const u32 v431 = (lid43 >> 4) & 15;
509 l_bin2asc[lid40] = ((v400 < 10) ? '0' + v400 : 'a' - 10 + v400) << 8
510 | ((v401 < 10) ? '0' + v401 : 'a' - 10 + v401) << 0;
511 l_bin2asc[lid41] = ((v410 < 10) ? '0' + v410 : 'a' - 10 + v410) << 8
512 | ((v411 < 10) ? '0' + v411 : 'a' - 10 + v411) << 0;
513 l_bin2asc[lid42] = ((v420 < 10) ? '0' + v420 : 'a' - 10 + v420) << 8
514 | ((v421 < 10) ? '0' + v421 : 'a' - 10 + v421) << 0;
515 l_bin2asc[lid43] = ((v430 < 10) ? '0' + v430 : 'a' - 10 + v430) << 8
516 | ((v431 < 10) ? '0' + v431 : 'a' - 10 + v431) << 0;
518 barrier (CLK_LOCAL_MEM_FENCE);
520 if (gid >= gid_max) return;
526 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
556 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
560 w0_t[0] = salt_buf0[0];
561 w0_t[1] = salt_buf0[1];
562 w0_t[2] = salt_buf0[2];
563 w0_t[3] = salt_buf0[3];
567 w1_t[0] = salt_buf1[0];
568 w1_t[1] = salt_buf1[1];
569 w1_t[2] = salt_buf1[2];
570 w1_t[3] = salt_buf1[3];
590 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
592 const u32 pw_salt_len = out_len + salt_len;
611 w3_t[2] = pw_salt_len * 8;
623 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
624 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
625 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
626 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
627 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
628 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
629 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
630 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
631 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
632 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
633 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
634 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
635 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
636 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
637 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
638 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
640 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
641 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
642 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
643 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
644 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
645 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
646 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
647 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
648 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
649 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
650 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
651 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
652 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
653 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
654 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
655 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
657 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
658 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
659 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
660 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
661 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
662 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
663 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
664 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
665 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
666 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
667 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
668 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
669 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
670 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
671 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
672 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
674 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
675 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
676 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
677 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
678 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
679 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
680 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
681 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
682 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
683 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
684 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
685 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
686 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
687 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
688 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
689 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
696 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
697 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
698 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
699 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
700 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
701 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
702 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
703 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
704 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
705 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
706 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
707 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
708 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
709 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
710 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
711 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
713 // add the 4 byte challenge here
716 w2_t[1] = 0x00000080;
722 w3_t[2] = (32 + 4) * 8;
726 * md5 ($hash.$challenge)
734 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
735 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
736 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
737 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
738 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
739 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
740 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
741 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
742 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
743 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
744 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
745 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
746 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
747 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
748 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
749 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
751 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
752 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
753 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
754 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
755 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
756 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
757 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
758 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
759 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
760 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
761 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
762 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
763 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
764 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
765 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
766 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
768 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
769 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
770 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
771 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
772 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
773 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
774 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
775 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
776 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
777 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
778 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
779 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
780 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
781 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
782 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
783 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
785 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
786 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
787 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
788 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
789 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
790 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
791 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
792 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
793 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
794 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
795 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
796 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
797 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
798 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
799 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
800 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
811 __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)
815 __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)