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__ __constant__ gpu_rule_t c_rules[1024];
47 __device__ __constant__ u64 k_sha512[80] =
49 SHA512C00, SHA512C01, SHA512C02, SHA512C03,
50 SHA512C04, SHA512C05, SHA512C06, SHA512C07,
51 SHA512C08, SHA512C09, SHA512C0a, SHA512C0b,
52 SHA512C0c, SHA512C0d, SHA512C0e, SHA512C0f,
53 SHA512C10, SHA512C11, SHA512C12, SHA512C13,
54 SHA512C14, SHA512C15, SHA512C16, SHA512C17,
55 SHA512C18, SHA512C19, SHA512C1a, SHA512C1b,
56 SHA512C1c, SHA512C1d, SHA512C1e, SHA512C1f,
57 SHA512C20, SHA512C21, SHA512C22, SHA512C23,
58 SHA512C24, SHA512C25, SHA512C26, SHA512C27,
59 SHA512C28, SHA512C29, SHA512C2a, SHA512C2b,
60 SHA512C2c, SHA512C2d, SHA512C2e, SHA512C2f,
61 SHA512C30, SHA512C31, SHA512C32, SHA512C33,
62 SHA512C34, SHA512C35, SHA512C36, SHA512C37,
63 SHA512C38, SHA512C39, SHA512C3a, SHA512C3b,
64 SHA512C3c, SHA512C3d, SHA512C3e, SHA512C3f,
65 SHA512C40, SHA512C41, SHA512C42, SHA512C43,
66 SHA512C44, SHA512C45, SHA512C46, SHA512C47,
67 SHA512C48, SHA512C49, SHA512C4a, SHA512C4b,
68 SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f,
71 __device__ static void sha512_transform (const u64x w0[4], const u64x w1[4], const u64x w2[4], const u64x w3[4], u64x digest[8])
99 #define ROUND_EXPAND() \
101 w0_t = SHA512_EXPAND (we_t, w9_t, w1_t, w0_t); \
102 w1_t = SHA512_EXPAND (wf_t, wa_t, w2_t, w1_t); \
103 w2_t = SHA512_EXPAND (w0_t, wb_t, w3_t, w2_t); \
104 w3_t = SHA512_EXPAND (w1_t, wc_t, w4_t, w3_t); \
105 w4_t = SHA512_EXPAND (w2_t, wd_t, w5_t, w4_t); \
106 w5_t = SHA512_EXPAND (w3_t, we_t, w6_t, w5_t); \
107 w6_t = SHA512_EXPAND (w4_t, wf_t, w7_t, w6_t); \
108 w7_t = SHA512_EXPAND (w5_t, w0_t, w8_t, w7_t); \
109 w8_t = SHA512_EXPAND (w6_t, w1_t, w9_t, w8_t); \
110 w9_t = SHA512_EXPAND (w7_t, w2_t, wa_t, w9_t); \
111 wa_t = SHA512_EXPAND (w8_t, w3_t, wb_t, wa_t); \
112 wb_t = SHA512_EXPAND (w9_t, w4_t, wc_t, wb_t); \
113 wc_t = SHA512_EXPAND (wa_t, w5_t, wd_t, wc_t); \
114 wd_t = SHA512_EXPAND (wb_t, w6_t, we_t, wd_t); \
115 we_t = SHA512_EXPAND (wc_t, w7_t, wf_t, we_t); \
116 wf_t = SHA512_EXPAND (wd_t, w8_t, w0_t, wf_t); \
119 #define ROUND_STEP(i) \
121 SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha512[i + 0]); \
122 SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha512[i + 1]); \
123 SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha512[i + 2]); \
124 SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha512[i + 3]); \
125 SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha512[i + 4]); \
126 SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha512[i + 5]); \
127 SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha512[i + 6]); \
128 SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha512[i + 7]); \
129 SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha512[i + 8]); \
130 SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha512[i + 9]); \
131 SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha512[i + 10]); \
132 SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha512[i + 11]); \
133 SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha512[i + 12]); \
134 SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha512[i + 13]); \
135 SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, we_t, k_sha512[i + 14]); \
136 SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha512[i + 15]); \
141 for (int i = 16; i < 80; i += 16)
143 ROUND_EXPAND (); ROUND_STEP (i);
156 __device__ static void hmac_sha512_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u64x ipad[8], u64x opad[8])
163 w0_t[0] = hl32_to_64 (w0[0], w0[1]) ^ 0x3636363636363636;
164 w0_t[1] = hl32_to_64 (w0[2], w0[3]) ^ 0x3636363636363636;
165 w0_t[2] = hl32_to_64 (w1[0], w1[1]) ^ 0x3636363636363636;
166 w0_t[3] = hl32_to_64 (w1[2], w1[3]) ^ 0x3636363636363636;
167 w1_t[0] = hl32_to_64 (w2[0], w2[1]) ^ 0x3636363636363636;
168 w1_t[1] = hl32_to_64 (w2[2], w2[3]) ^ 0x3636363636363636;
169 w1_t[2] = hl32_to_64 (w3[0], w3[1]) ^ 0x3636363636363636;
170 w1_t[3] = hl32_to_64 (w3[2], w3[3]) ^ 0x3636363636363636;
171 w2_t[0] = 0 ^ 0x3636363636363636;
172 w2_t[1] = 0 ^ 0x3636363636363636;
173 w2_t[2] = 0 ^ 0x3636363636363636;
174 w2_t[3] = 0 ^ 0x3636363636363636;
175 w3_t[0] = 0 ^ 0x3636363636363636;
176 w3_t[1] = 0 ^ 0x3636363636363636;
177 w3_t[2] = 0 ^ 0x3636363636363636;
178 w3_t[3] = 0 ^ 0x3636363636363636;
189 sha512_transform (w0_t, w1_t, w2_t, w3_t, ipad);
191 w0_t[0] = hl32_to_64 (w0[0], w0[1]) ^ 0x5c5c5c5c5c5c5c5c;
192 w0_t[1] = hl32_to_64 (w0[2], w0[3]) ^ 0x5c5c5c5c5c5c5c5c;
193 w0_t[2] = hl32_to_64 (w1[0], w1[1]) ^ 0x5c5c5c5c5c5c5c5c;
194 w0_t[3] = hl32_to_64 (w1[2], w1[3]) ^ 0x5c5c5c5c5c5c5c5c;
195 w1_t[0] = hl32_to_64 (w2[0], w2[1]) ^ 0x5c5c5c5c5c5c5c5c;
196 w1_t[1] = hl32_to_64 (w2[2], w2[3]) ^ 0x5c5c5c5c5c5c5c5c;
197 w1_t[2] = hl32_to_64 (w3[0], w3[1]) ^ 0x5c5c5c5c5c5c5c5c;
198 w1_t[3] = hl32_to_64 (w3[2], w3[3]) ^ 0x5c5c5c5c5c5c5c5c;
199 w2_t[0] = 0 ^ 0x5c5c5c5c5c5c5c5c;
200 w2_t[1] = 0 ^ 0x5c5c5c5c5c5c5c5c;
201 w2_t[2] = 0 ^ 0x5c5c5c5c5c5c5c5c;
202 w2_t[3] = 0 ^ 0x5c5c5c5c5c5c5c5c;
203 w3_t[0] = 0 ^ 0x5c5c5c5c5c5c5c5c;
204 w3_t[1] = 0 ^ 0x5c5c5c5c5c5c5c5c;
205 w3_t[2] = 0 ^ 0x5c5c5c5c5c5c5c5c;
206 w3_t[3] = 0 ^ 0x5c5c5c5c5c5c5c5c;
217 sha512_transform (w0_t, w1_t, w2_t, w3_t, opad);
220 __device__ static void hmac_sha512_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u64x ipad[8], u64x opad[8], u64x digest[8])
227 w0_t[0] = hl32_to_64 (w0[0], w0[1]);
228 w0_t[1] = hl32_to_64 (w0[2], w0[3]);
229 w0_t[2] = hl32_to_64 (w1[0], w1[1]);
230 w0_t[3] = hl32_to_64 (w1[2], w1[3]);
231 w1_t[0] = hl32_to_64 (w2[0], w2[1]);
232 w1_t[1] = hl32_to_64 (w2[2], w2[3]);
233 w1_t[2] = hl32_to_64 (w3[0], w3[1]);
242 w3_t[3] = hl32_to_64 (w3[2], w3[3]);
253 sha512_transform (w0_t, w1_t, w2_t, w3_t, digest);
263 w2_t[0] = 0x8000000000000000;
270 w3_t[3] = (128 + 64) * 8;
281 sha512_transform (w0_t, w1_t, w2_t, w3_t, digest);
284 extern "C" __global__ void __launch_bounds__ (256, 1) m01750_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)
290 const u32 lid = threadIdx.x;
296 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
298 if (gid >= gid_max) return;
302 pw_buf0[0] = pws[gid].i[ 0];
303 pw_buf0[1] = pws[gid].i[ 1];
304 pw_buf0[2] = pws[gid].i[ 2];
305 pw_buf0[3] = pws[gid].i[ 3];
309 pw_buf1[0] = pws[gid].i[ 4];
310 pw_buf1[1] = pws[gid].i[ 5];
311 pw_buf1[2] = pws[gid].i[ 6];
312 pw_buf1[3] = pws[gid].i[ 7];
314 const u32 pw_len = pws[gid].pw_len;
322 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
323 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
324 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
325 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
329 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
330 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
331 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
332 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
334 const u32 salt_len = salt_bufs[salt_pos].salt_len;
340 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
370 const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
378 w0_t[0] = swap_workaround (w0[0]);
379 w0_t[1] = swap_workaround (w0[1]);
380 w0_t[2] = swap_workaround (w0[2]);
381 w0_t[3] = swap_workaround (w0[3]);
385 w1_t[0] = swap_workaround (w1[0]);
386 w1_t[1] = swap_workaround (w1[1]);
387 w1_t[2] = swap_workaround (w1[2]);
388 w1_t[3] = swap_workaround (w1[3]);
407 hmac_sha512_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
409 w0_t[0] = swap_workaround (salt_buf0[0]);
410 w0_t[1] = swap_workaround (salt_buf0[1]);
411 w0_t[2] = swap_workaround (salt_buf0[2]);
412 w0_t[3] = swap_workaround (salt_buf0[3]);
413 w1_t[0] = swap_workaround (salt_buf1[0]);
414 w1_t[1] = swap_workaround (salt_buf1[1]);
415 w1_t[2] = swap_workaround (salt_buf1[2]);
416 w1_t[3] = swap_workaround (salt_buf1[3]);
424 w3_t[3] = (128 + salt_len) * 8;
428 hmac_sha512_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
431 const u32x r0 = l32_from_64 (digest[7]);
432 const u32x r1 = h32_from_64 (digest[7]);
433 const u32x r2 = l32_from_64 (digest[3]);
434 const u32x r3 = h32_from_64 (digest[3]);
436 #include VECT_COMPARE_M
440 extern "C" __global__ void __launch_bounds__ (256, 1) m01750_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)
444 extern "C" __global__ void __launch_bounds__ (256, 1) m01750_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)
448 extern "C" __global__ void __launch_bounds__ (256, 1) m01750_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)
454 const u32 lid = threadIdx.x;
460 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
462 if (gid >= gid_max) return;
466 pw_buf0[0] = pws[gid].i[ 0];
467 pw_buf0[1] = pws[gid].i[ 1];
468 pw_buf0[2] = pws[gid].i[ 2];
469 pw_buf0[3] = pws[gid].i[ 3];
473 pw_buf1[0] = pws[gid].i[ 4];
474 pw_buf1[1] = pws[gid].i[ 5];
475 pw_buf1[2] = pws[gid].i[ 6];
476 pw_buf1[3] = pws[gid].i[ 7];
478 const u32 pw_len = pws[gid].pw_len;
486 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
487 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
488 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
489 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
493 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
494 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
495 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
496 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
498 const u32 salt_len = salt_bufs[salt_pos].salt_len;
504 const u32 search[4] =
506 digests_buf[digests_offset].digest_buf[DGST_R0],
507 digests_buf[digests_offset].digest_buf[DGST_R1],
508 digests_buf[digests_offset].digest_buf[DGST_R2],
509 digests_buf[digests_offset].digest_buf[DGST_R3]
516 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
546 const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
554 w0_t[0] = swap_workaround (w0[0]);
555 w0_t[1] = swap_workaround (w0[1]);
556 w0_t[2] = swap_workaround (w0[2]);
557 w0_t[3] = swap_workaround (w0[3]);
561 w1_t[0] = swap_workaround (w1[0]);
562 w1_t[1] = swap_workaround (w1[1]);
563 w1_t[2] = swap_workaround (w1[2]);
564 w1_t[3] = swap_workaround (w1[3]);
583 hmac_sha512_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
585 w0_t[0] = swap_workaround (salt_buf0[0]);
586 w0_t[1] = swap_workaround (salt_buf0[1]);
587 w0_t[2] = swap_workaround (salt_buf0[2]);
588 w0_t[3] = swap_workaround (salt_buf0[3]);
589 w1_t[0] = swap_workaround (salt_buf1[0]);
590 w1_t[1] = swap_workaround (salt_buf1[1]);
591 w1_t[2] = swap_workaround (salt_buf1[2]);
592 w1_t[3] = swap_workaround (salt_buf1[3]);
600 w3_t[3] = (128 + salt_len) * 8;
604 hmac_sha512_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
607 const u32x r0 = l32_from_64 (digest[7]);
608 const u32x r1 = h32_from_64 (digest[7]);
609 const u32x r2 = l32_from_64 (digest[3]);
610 const u32x r3 = h32_from_64 (digest[3]);
612 #include VECT_COMPARE_S
616 extern "C" __global__ void __launch_bounds__ (256, 1) m01750_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)
620 extern "C" __global__ void __launch_bounds__ (256, 1) m01750_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)