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 __kernel void m01000_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)
29 const u32 lid = get_local_id (0);
35 const u32 gid = get_global_id (0);
37 if (gid >= gid_max) return;
41 wordl0[0] = pws[gid].i[ 0];
42 wordl0[1] = pws[gid].i[ 1];
43 wordl0[2] = pws[gid].i[ 2];
44 wordl0[3] = pws[gid].i[ 3];
48 wordl1[0] = pws[gid].i[ 4];
49 wordl1[1] = pws[gid].i[ 5];
50 wordl1[2] = pws[gid].i[ 6];
51 wordl1[3] = pws[gid].i[ 7];
67 const u32 pw_l_len = pws[gid].pw_len;
69 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
71 append_0x80_2x4 (wordl0, wordl1, pw_l_len);
73 switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
80 for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
82 const u32 pw_r_len = combs_buf[il_pos].pw_len;
84 const u32 pw_len = pw_l_len + pw_r_len;
88 wordr0[0] = combs_buf[il_pos].i[0];
89 wordr0[1] = combs_buf[il_pos].i[1];
90 wordr0[2] = combs_buf[il_pos].i[2];
91 wordr0[3] = combs_buf[il_pos].i[3];
95 wordr1[0] = combs_buf[il_pos].i[4];
96 wordr1[1] = combs_buf[il_pos].i[5];
97 wordr1[2] = combs_buf[il_pos].i[6];
98 wordr1[3] = combs_buf[il_pos].i[7];
114 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
116 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
121 w0[0] = wordl0[0] | wordr0[0];
122 w0[1] = wordl0[1] | wordr0[1];
123 w0[2] = wordl0[2] | wordr0[2];
124 w0[3] = wordl0[3] | wordr0[3];
128 w1[0] = wordl1[0] | wordr1[0];
129 w1[1] = wordl1[1] | wordr1[1];
130 w1[2] = wordl1[2] | wordr1[2];
131 w1[3] = wordl1[3] | wordr1[3];
152 make_unicode (w0, w0_t, w1_t);
153 make_unicode (w1, w2_t, w3_t);
155 w3_t[2] = pw_len * 8 * 2;
162 MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
163 MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
164 MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
165 MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
166 MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
167 MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
168 MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
169 MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
170 MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
171 MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
172 MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
173 MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
174 MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
175 MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
176 MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
177 MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
179 MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
180 MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
181 MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
182 MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
183 MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
184 MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
185 MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
186 MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
187 MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
188 MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
189 MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
190 MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
191 MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
192 MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
193 MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
194 MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
196 MD4_STEP (MD4_H , a, b, c, d, w0_t[0], MD4C02, MD4S20);
197 MD4_STEP (MD4_H , d, a, b, c, w2_t[0], MD4C02, MD4S21);
198 MD4_STEP (MD4_H , c, d, a, b, w1_t[0], MD4C02, MD4S22);
199 MD4_STEP (MD4_H , b, c, d, a, w3_t[0], MD4C02, MD4S23);
200 MD4_STEP (MD4_H , a, b, c, d, w0_t[2], MD4C02, MD4S20);
201 MD4_STEP (MD4_H , d, a, b, c, w2_t[2], MD4C02, MD4S21);
202 MD4_STEP (MD4_H , c, d, a, b, w1_t[2], MD4C02, MD4S22);
203 MD4_STEP (MD4_H , b, c, d, a, w3_t[2], MD4C02, MD4S23);
204 MD4_STEP (MD4_H , a, b, c, d, w0_t[1], MD4C02, MD4S20);
205 MD4_STEP (MD4_H , d, a, b, c, w2_t[1], MD4C02, MD4S21);
206 MD4_STEP (MD4_H , c, d, a, b, w1_t[1], MD4C02, MD4S22);
207 MD4_STEP (MD4_H , b, c, d, a, w3_t[1], MD4C02, MD4S23);
208 MD4_STEP (MD4_H , a, b, c, d, w0_t[3], MD4C02, MD4S20);
209 MD4_STEP (MD4_H , d, a, b, c, w2_t[3], MD4C02, MD4S21);
210 MD4_STEP (MD4_H , c, d, a, b, w1_t[3], MD4C02, MD4S22);
211 MD4_STEP (MD4_H , b, c, d, a, w3_t[3], MD4C02, MD4S23);
222 __kernel void m01000_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)
226 __kernel void m01000_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)
230 __kernel void m01000_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)
236 const u32 lid = get_local_id (0);
242 const u32 gid = get_global_id (0);
244 if (gid >= gid_max) return;
248 wordl0[0] = pws[gid].i[ 0];
249 wordl0[1] = pws[gid].i[ 1];
250 wordl0[2] = pws[gid].i[ 2];
251 wordl0[3] = pws[gid].i[ 3];
255 wordl1[0] = pws[gid].i[ 4];
256 wordl1[1] = pws[gid].i[ 5];
257 wordl1[2] = pws[gid].i[ 6];
258 wordl1[3] = pws[gid].i[ 7];
274 const u32 pw_l_len = pws[gid].pw_len;
276 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
278 append_0x80_2x4 (wordl0, wordl1, pw_l_len);
280 switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
287 const u32 search[4] =
289 digests_buf[digests_offset].digest_buf[DGST_R0],
290 digests_buf[digests_offset].digest_buf[DGST_R1],
291 digests_buf[digests_offset].digest_buf[DGST_R2],
292 digests_buf[digests_offset].digest_buf[DGST_R3]
299 for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
301 const u32 pw_r_len = combs_buf[il_pos].pw_len;
303 const u32 pw_len = pw_l_len + pw_r_len;
307 wordr0[0] = combs_buf[il_pos].i[0];
308 wordr0[1] = combs_buf[il_pos].i[1];
309 wordr0[2] = combs_buf[il_pos].i[2];
310 wordr0[3] = combs_buf[il_pos].i[3];
314 wordr1[0] = combs_buf[il_pos].i[4];
315 wordr1[1] = combs_buf[il_pos].i[5];
316 wordr1[2] = combs_buf[il_pos].i[6];
317 wordr1[3] = combs_buf[il_pos].i[7];
333 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
335 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
340 w0[0] = wordl0[0] | wordr0[0];
341 w0[1] = wordl0[1] | wordr0[1];
342 w0[2] = wordl0[2] | wordr0[2];
343 w0[3] = wordl0[3] | wordr0[3];
347 w1[0] = wordl1[0] | wordr1[0];
348 w1[1] = wordl1[1] | wordr1[1];
349 w1[2] = wordl1[2] | wordr1[2];
350 w1[3] = wordl1[3] | wordr1[3];
371 make_unicode (w0, w0_t, w1_t);
372 make_unicode (w1, w2_t, w3_t);
374 w3_t[2] = pw_len * 8 * 2;
381 MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
382 MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
383 MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
384 MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
385 MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
386 MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
387 MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
388 MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
389 MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
390 MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
391 MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
392 MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
393 MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
394 MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
395 MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
396 MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
398 MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
399 MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
400 MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
401 MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
402 MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
403 MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
404 MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
405 MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
406 MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
407 MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
408 MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
409 MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
410 MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
411 MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
412 MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
413 MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
415 MD4_STEP (MD4_H , a, b, c, d, w0_t[0], MD4C02, MD4S20);
416 MD4_STEP (MD4_H , d, a, b, c, w2_t[0], MD4C02, MD4S21);
417 MD4_STEP (MD4_H , c, d, a, b, w1_t[0], MD4C02, MD4S22);
418 MD4_STEP (MD4_H , b, c, d, a, w3_t[0], MD4C02, MD4S23);
419 MD4_STEP (MD4_H , a, b, c, d, w0_t[2], MD4C02, MD4S20);
420 MD4_STEP (MD4_H , d, a, b, c, w2_t[2], MD4C02, MD4S21);
421 MD4_STEP (MD4_H , c, d, a, b, w1_t[2], MD4C02, MD4S22);
422 MD4_STEP (MD4_H , b, c, d, a, w3_t[2], MD4C02, MD4S23);
423 MD4_STEP (MD4_H , a, b, c, d, w0_t[1], MD4C02, MD4S20);
424 MD4_STEP (MD4_H , d, a, b, c, w2_t[1], MD4C02, MD4S21);
425 MD4_STEP (MD4_H , c, d, a, b, w1_t[1], MD4C02, MD4S22);
426 MD4_STEP (MD4_H , b, c, d, a, w3_t[1], MD4C02, MD4S23);
427 MD4_STEP (MD4_H , a, b, c, d, w0_t[3], MD4C02, MD4S20);
428 MD4_STEP (MD4_H , d, a, b, c, w2_t[3], MD4C02, MD4S21);
429 MD4_STEP (MD4_H , c, d, a, b, w1_t[3], MD4C02, MD4S22);
430 MD4_STEP (MD4_H , b, c, d, a, w3_t[3], MD4C02, MD4S23);
441 __kernel void m01000_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)
445 __kernel void m01000_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)