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"
27 #include "include/rp_gpu.h"
31 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
32 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
36 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
37 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
41 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
42 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
45 __device__ static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
71 MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
72 MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
73 MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
74 MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
75 MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
76 MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
77 MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
78 MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
79 MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
80 MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
81 MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
82 MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
83 MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
84 MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
85 MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
86 MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
88 MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
89 MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
90 MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
91 MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
92 MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
93 MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
94 MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
95 MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
96 MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
97 MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
98 MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
99 MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
100 MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
101 MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
102 MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
103 MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
105 MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20);
106 MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21);
107 MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22);
108 MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23);
109 MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20);
110 MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21);
111 MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22);
112 MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23);
113 MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20);
114 MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21);
115 MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22);
116 MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23);
117 MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20);
118 MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21);
119 MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22);
120 MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23);
122 MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
123 MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
124 MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
125 MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
126 MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
127 MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
128 MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
129 MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
130 MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
131 MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
132 MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
133 MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
134 MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
135 MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
136 MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
137 MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
145 __device__ static void hmac_md5_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[4], u32x opad[4])
147 w0[0] = w0[0] ^ 0x36363636;
148 w0[1] = w0[1] ^ 0x36363636;
149 w0[2] = w0[2] ^ 0x36363636;
150 w0[3] = w0[3] ^ 0x36363636;
151 w1[0] = w1[0] ^ 0x36363636;
152 w1[1] = w1[1] ^ 0x36363636;
153 w1[2] = w1[2] ^ 0x36363636;
154 w1[3] = w1[3] ^ 0x36363636;
155 w2[0] = w2[0] ^ 0x36363636;
156 w2[1] = w2[1] ^ 0x36363636;
157 w2[2] = w2[2] ^ 0x36363636;
158 w2[3] = w2[3] ^ 0x36363636;
159 w3[0] = w3[0] ^ 0x36363636;
160 w3[1] = w3[1] ^ 0x36363636;
161 w3[2] = w3[2] ^ 0x36363636;
162 w3[3] = w3[3] ^ 0x36363636;
169 md5_transform (w0, w1, w2, w3, ipad);
171 w0[0] = w0[0] ^ 0x6a6a6a6a;
172 w0[1] = w0[1] ^ 0x6a6a6a6a;
173 w0[2] = w0[2] ^ 0x6a6a6a6a;
174 w0[3] = w0[3] ^ 0x6a6a6a6a;
175 w1[0] = w1[0] ^ 0x6a6a6a6a;
176 w1[1] = w1[1] ^ 0x6a6a6a6a;
177 w1[2] = w1[2] ^ 0x6a6a6a6a;
178 w1[3] = w1[3] ^ 0x6a6a6a6a;
179 w2[0] = w2[0] ^ 0x6a6a6a6a;
180 w2[1] = w2[1] ^ 0x6a6a6a6a;
181 w2[2] = w2[2] ^ 0x6a6a6a6a;
182 w2[3] = w2[3] ^ 0x6a6a6a6a;
183 w3[0] = w3[0] ^ 0x6a6a6a6a;
184 w3[1] = w3[1] ^ 0x6a6a6a6a;
185 w3[2] = w3[2] ^ 0x6a6a6a6a;
186 w3[3] = w3[3] ^ 0x6a6a6a6a;
193 md5_transform (w0, w1, w2, w3, opad);
196 __device__ static void hmac_md5_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[4], u32x opad[4], u32x digest[4])
203 md5_transform (w0, w1, w2, w3, digest);
219 w3[2] = (64 + 16) * 8;
227 md5_transform (w0, w1, w2, w3, digest);
230 __device__ __constant__ gpu_rule_t c_rules[1024];
232 extern "C" __global__ void __launch_bounds__ (256, 1) m00050_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 void *esalt_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
238 const u32 lid = threadIdx.x;
244 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
246 if (gid >= gid_max) return;
250 pw_buf0[0] = pws[gid].i[ 0];
251 pw_buf0[1] = pws[gid].i[ 1];
252 pw_buf0[2] = pws[gid].i[ 2];
253 pw_buf0[3] = pws[gid].i[ 3];
257 pw_buf1[0] = pws[gid].i[ 4];
258 pw_buf1[1] = pws[gid].i[ 5];
259 pw_buf1[2] = pws[gid].i[ 6];
260 pw_buf1[3] = pws[gid].i[ 7];
262 const u32 pw_len = pws[gid].pw_len;
270 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
271 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
272 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
273 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
277 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
278 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
279 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
280 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
284 salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
285 salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
286 salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
287 salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
291 salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
292 salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
293 salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
294 salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
296 const u32 salt_len = salt_bufs[salt_pos].salt_len;
302 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
332 const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
369 hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
371 w0_t[0] = salt_buf0[0];
372 w0_t[1] = salt_buf0[1];
373 w0_t[2] = salt_buf0[2];
374 w0_t[3] = salt_buf0[3];
375 w1_t[0] = salt_buf1[0];
376 w1_t[1] = salt_buf1[1];
377 w1_t[2] = salt_buf1[2];
378 w1_t[3] = salt_buf1[3];
379 w2_t[0] = salt_buf2[0];
380 w2_t[1] = salt_buf2[1];
381 w2_t[2] = salt_buf2[2];
382 w2_t[3] = salt_buf2[3];
383 w3_t[0] = salt_buf3[0];
384 w3_t[1] = salt_buf3[1];
385 w3_t[2] = (64 + salt_len) * 8;
390 hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
392 const u32x r0 = digest[0];
393 const u32x r1 = digest[3];
394 const u32x r2 = digest[2];
395 const u32x r3 = digest[1];
397 #include VECT_COMPARE_M
401 extern "C" __global__ void __launch_bounds__ (256, 1) m00050_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 void *esalt_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
405 extern "C" __global__ void __launch_bounds__ (256, 1) m00050_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 void *esalt_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
409 extern "C" __global__ void __launch_bounds__ (256, 1) m00050_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 void *esalt_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
415 const u32 lid = threadIdx.x;
421 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
423 if (gid >= gid_max) return;
427 pw_buf0[0] = pws[gid].i[ 0];
428 pw_buf0[1] = pws[gid].i[ 1];
429 pw_buf0[2] = pws[gid].i[ 2];
430 pw_buf0[3] = pws[gid].i[ 3];
434 pw_buf1[0] = pws[gid].i[ 4];
435 pw_buf1[1] = pws[gid].i[ 5];
436 pw_buf1[2] = pws[gid].i[ 6];
437 pw_buf1[3] = pws[gid].i[ 7];
439 const u32 pw_len = pws[gid].pw_len;
447 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
448 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
449 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
450 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
454 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
455 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
456 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
457 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
461 salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
462 salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
463 salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
464 salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
468 salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
469 salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
470 salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
471 salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
473 const u32 salt_len = salt_bufs[salt_pos].salt_len;
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 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
521 const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
558 hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
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];
564 w1_t[0] = salt_buf1[0];
565 w1_t[1] = salt_buf1[1];
566 w1_t[2] = salt_buf1[2];
567 w1_t[3] = salt_buf1[3];
568 w2_t[0] = salt_buf2[0];
569 w2_t[1] = salt_buf2[1];
570 w2_t[2] = salt_buf2[2];
571 w2_t[3] = salt_buf2[3];
572 w3_t[0] = salt_buf3[0];
573 w3_t[1] = salt_buf3[1];
574 w3_t[2] = (64 + salt_len) * 8;
579 hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
581 const u32x r0 = digest[0];
582 const u32x r1 = digest[3];
583 const u32x r2 = digest[2];
584 const u32x r3 = digest[1];
586 #include VECT_COMPARE_S
590 extern "C" __global__ void __launch_bounds__ (256, 1) m00050_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 void *esalt_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
594 extern "C" __global__ void __launch_bounds__ (256, 1) m00050_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 void *esalt_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)