2 * Author......: Jens Steube <jens.steube@gmail.com>
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
24 #include "include/kernel_functions.c"
26 #include "common_nv.c"
29 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
30 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
34 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
35 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
38 __device__ __constant__ u32 padding[8] =
50 __device__ static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
74 MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
75 MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
76 MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
77 MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
78 MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
79 MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
80 MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
81 MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
82 MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
83 MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
84 MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
85 MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
86 MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
87 MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
88 MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
89 MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
91 MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
92 MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
93 MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
94 MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
95 MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
96 MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
97 MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
98 MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
99 MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
100 MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
101 MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
102 MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
103 MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
104 MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
105 MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
106 MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
108 MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
109 MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
110 MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
111 MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
112 MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
113 MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
114 MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
115 MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
116 MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
117 MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
118 MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
119 MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
120 MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
121 MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
122 MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
123 MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
125 MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
126 MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
127 MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
128 MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
129 MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
130 MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
131 MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
132 MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
133 MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
134 MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
135 MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
136 MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
137 MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
138 MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
139 MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
140 MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
148 __device__ __constant__ comb_t c_combs[1024];
150 extern "C" __global__ void __launch_bounds__ (256, 1) m10420_m04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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)
156 const u32 lid = threadIdx.x;
162 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
164 if (gid >= gid_max) return;
168 wordl0[0] = pws[gid].i[ 0];
169 wordl0[1] = pws[gid].i[ 1];
170 wordl0[2] = pws[gid].i[ 2];
171 wordl0[3] = pws[gid].i[ 3];
175 wordl1[0] = pws[gid].i[ 4];
176 wordl1[1] = pws[gid].i[ 5];
177 wordl1[2] = pws[gid].i[ 6];
178 wordl1[3] = pws[gid].i[ 7];
194 const u32 pw_l_len = pws[gid].pw_len;
196 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
198 append_0x80_2 (wordl0, wordl1, pw_l_len);
200 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
209 o_buf[0] = pdf_bufs[salt_pos].o_buf[0];
210 o_buf[1] = pdf_bufs[salt_pos].o_buf[1];
211 o_buf[2] = pdf_bufs[salt_pos].o_buf[2];
212 o_buf[3] = pdf_bufs[salt_pos].o_buf[3];
213 o_buf[4] = pdf_bufs[salt_pos].o_buf[4];
214 o_buf[5] = pdf_bufs[salt_pos].o_buf[5];
215 o_buf[6] = pdf_bufs[salt_pos].o_buf[6];
216 o_buf[7] = pdf_bufs[salt_pos].o_buf[7];
218 u32 P = pdf_bufs[salt_pos].P;
222 id_buf[0] = pdf_bufs[salt_pos].id_buf[0];
223 id_buf[1] = pdf_bufs[salt_pos].id_buf[1];
224 id_buf[2] = pdf_bufs[salt_pos].id_buf[2];
225 id_buf[3] = pdf_bufs[salt_pos].id_buf[3];
231 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
233 const u32 pw_r_len = c_combs[il_pos].pw_len;
235 const u32 pw_len = pw_l_len + pw_r_len;
239 wordr0[0] = c_combs[il_pos].i[0];
240 wordr0[1] = c_combs[il_pos].i[1];
241 wordr0[2] = c_combs[il_pos].i[2];
242 wordr0[3] = c_combs[il_pos].i[3];
246 wordr1[0] = c_combs[il_pos].i[4];
247 wordr1[1] = c_combs[il_pos].i[5];
248 wordr1[2] = c_combs[il_pos].i[6];
249 wordr1[3] = c_combs[il_pos].i[7];
265 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
267 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
272 w0[0] = wordl0[0] | wordr0[0];
273 w0[1] = wordl0[1] | wordr0[1];
274 w0[2] = wordl0[2] | wordr0[2];
275 w0[3] = wordl0[3] | wordr0[3];
279 w1[0] = wordl1[0] | wordr1[0];
280 w1[1] = wordl1[1] | wordr1[1];
281 w1[2] = wordl1[2] | wordr1[2];
282 w1[3] = wordl1[3] | wordr1[3];
286 w2[0] = wordl2[0] | wordr2[0];
287 w2[1] = wordl2[1] | wordr2[1];
288 w2[2] = wordl2[2] | wordr2[2];
289 w2[3] = wordl2[3] | wordr2[3];
293 w3[0] = wordl3[0] | wordr3[0];
294 w3[1] = wordl3[1] | wordr3[1];
295 w3[2] = wordl3[2] | wordr3[2];
296 w3[3] = wordl3[3] | wordr3[3];
303 // max length supported by pdf11 is 32
305 w0_t[0] = padding[0];
306 w0_t[1] = padding[1];
307 w0_t[2] = padding[2];
308 w0_t[3] = padding[3];
309 w1_t[0] = padding[4];
310 w1_t[1] = padding[5];
311 w1_t[2] = padding[6];
312 w1_t[3] = padding[7];
322 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
325 // truncate at 32 is wanted, not a bug!
352 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
371 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
374 u32x b = digest[1] & 0xff;
381 #include VECT_COMPARE_M
385 extern "C" __global__ void __launch_bounds__ (256, 1) m10420_m08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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)
389 extern "C" __global__ void __launch_bounds__ (256, 1) m10420_m16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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)
393 extern "C" __global__ void __launch_bounds__ (256, 1) m10420_s04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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)
399 const u32 lid = threadIdx.x;
405 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
407 if (gid >= gid_max) return;
411 wordl0[0] = pws[gid].i[ 0];
412 wordl0[1] = pws[gid].i[ 1];
413 wordl0[2] = pws[gid].i[ 2];
414 wordl0[3] = pws[gid].i[ 3];
418 wordl1[0] = pws[gid].i[ 4];
419 wordl1[1] = pws[gid].i[ 5];
420 wordl1[2] = pws[gid].i[ 6];
421 wordl1[3] = pws[gid].i[ 7];
437 const u32 pw_l_len = pws[gid].pw_len;
439 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
441 append_0x80_2 (wordl0, wordl1, pw_l_len);
443 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
450 const u32 search[4] =
452 digests_buf[digests_offset].digest_buf[DGST_R0],
453 digests_buf[digests_offset].digest_buf[DGST_R1],
454 digests_buf[digests_offset].digest_buf[DGST_R2],
455 digests_buf[digests_offset].digest_buf[DGST_R3]
464 o_buf[0] = pdf_bufs[salt_pos].o_buf[0];
465 o_buf[1] = pdf_bufs[salt_pos].o_buf[1];
466 o_buf[2] = pdf_bufs[salt_pos].o_buf[2];
467 o_buf[3] = pdf_bufs[salt_pos].o_buf[3];
468 o_buf[4] = pdf_bufs[salt_pos].o_buf[4];
469 o_buf[5] = pdf_bufs[salt_pos].o_buf[5];
470 o_buf[6] = pdf_bufs[salt_pos].o_buf[6];
471 o_buf[7] = pdf_bufs[salt_pos].o_buf[7];
473 u32 P = pdf_bufs[salt_pos].P;
477 id_buf[0] = pdf_bufs[salt_pos].id_buf[0];
478 id_buf[1] = pdf_bufs[salt_pos].id_buf[1];
479 id_buf[2] = pdf_bufs[salt_pos].id_buf[2];
480 id_buf[3] = pdf_bufs[salt_pos].id_buf[3];
486 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
488 const u32 pw_r_len = c_combs[il_pos].pw_len;
490 const u32 pw_len = pw_l_len + pw_r_len;
494 wordr0[0] = c_combs[il_pos].i[0];
495 wordr0[1] = c_combs[il_pos].i[1];
496 wordr0[2] = c_combs[il_pos].i[2];
497 wordr0[3] = c_combs[il_pos].i[3];
501 wordr1[0] = c_combs[il_pos].i[4];
502 wordr1[1] = c_combs[il_pos].i[5];
503 wordr1[2] = c_combs[il_pos].i[6];
504 wordr1[3] = c_combs[il_pos].i[7];
520 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
522 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
527 w0[0] = wordl0[0] | wordr0[0];
528 w0[1] = wordl0[1] | wordr0[1];
529 w0[2] = wordl0[2] | wordr0[2];
530 w0[3] = wordl0[3] | wordr0[3];
534 w1[0] = wordl1[0] | wordr1[0];
535 w1[1] = wordl1[1] | wordr1[1];
536 w1[2] = wordl1[2] | wordr1[2];
537 w1[3] = wordl1[3] | wordr1[3];
541 w2[0] = wordl2[0] | wordr2[0];
542 w2[1] = wordl2[1] | wordr2[1];
543 w2[2] = wordl2[2] | wordr2[2];
544 w2[3] = wordl2[3] | wordr2[3];
548 w3[0] = wordl3[0] | wordr3[0];
549 w3[1] = wordl3[1] | wordr3[1];
550 w3[2] = wordl3[2] | wordr3[2];
551 w3[3] = wordl3[3] | wordr3[3];
558 // max length supported by pdf11 is 32
560 w0_t[0] = padding[0];
561 w0_t[1] = padding[1];
562 w0_t[2] = padding[2];
563 w0_t[3] = padding[3];
564 w1_t[0] = padding[4];
565 w1_t[1] = padding[5];
566 w1_t[2] = padding[6];
567 w1_t[3] = padding[7];
577 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
580 // truncate at 32 is wanted, not a bug!
607 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
626 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
629 u32x b = digest[1] & 0xff;
636 #include VECT_COMPARE_S
640 extern "C" __global__ void __launch_bounds__ (256, 1) m10420_s08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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)
644 extern "C" __global__ void __launch_bounds__ (256, 1) m10420_s16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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)