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_M "check_multi_vect1_comp4.c"
33 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
36 __device__ __constant__ u64 k[80] =
38 SHA512C00, SHA512C01, SHA512C02, SHA512C03,
39 SHA512C04, SHA512C05, SHA512C06, SHA512C07,
40 SHA512C08, SHA512C09, SHA512C0a, SHA512C0b,
41 SHA512C0c, SHA512C0d, SHA512C0e, SHA512C0f,
42 SHA512C10, SHA512C11, SHA512C12, SHA512C13,
43 SHA512C14, SHA512C15, SHA512C16, SHA512C17,
44 SHA512C18, SHA512C19, SHA512C1a, SHA512C1b,
45 SHA512C1c, SHA512C1d, SHA512C1e, SHA512C1f,
46 SHA512C20, SHA512C21, SHA512C22, SHA512C23,
47 SHA512C24, SHA512C25, SHA512C26, SHA512C27,
48 SHA512C28, SHA512C29, SHA512C2a, SHA512C2b,
49 SHA512C2c, SHA512C2d, SHA512C2e, SHA512C2f,
50 SHA512C30, SHA512C31, SHA512C32, SHA512C33,
51 SHA512C34, SHA512C35, SHA512C36, SHA512C37,
52 SHA512C38, SHA512C39, SHA512C3a, SHA512C3b,
53 SHA512C3c, SHA512C3d, SHA512C3e, SHA512C3f,
54 SHA512C40, SHA512C41, SHA512C42, SHA512C43,
55 SHA512C44, SHA512C45, SHA512C46, SHA512C47,
56 SHA512C48, SHA512C49, SHA512C4a, SHA512C4b,
57 SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f,
60 #define ROUND_EXPAND() \
62 w0_t = SHA512_EXPAND (we_t, w9_t, w1_t, w0_t); \
63 w1_t = SHA512_EXPAND (wf_t, wa_t, w2_t, w1_t); \
64 w2_t = SHA512_EXPAND (w0_t, wb_t, w3_t, w2_t); \
65 w3_t = SHA512_EXPAND (w1_t, wc_t, w4_t, w3_t); \
66 w4_t = SHA512_EXPAND (w2_t, wd_t, w5_t, w4_t); \
67 w5_t = SHA512_EXPAND (w3_t, we_t, w6_t, w5_t); \
68 w6_t = SHA512_EXPAND (w4_t, wf_t, w7_t, w6_t); \
69 w7_t = SHA512_EXPAND (w5_t, w0_t, w8_t, w7_t); \
70 w8_t = SHA512_EXPAND (w6_t, w1_t, w9_t, w8_t); \
71 w9_t = SHA512_EXPAND (w7_t, w2_t, wa_t, w9_t); \
72 wa_t = SHA512_EXPAND (w8_t, w3_t, wb_t, wa_t); \
73 wb_t = SHA512_EXPAND (w9_t, w4_t, wc_t, wb_t); \
74 wc_t = SHA512_EXPAND (wa_t, w5_t, wd_t, wc_t); \
75 wd_t = SHA512_EXPAND (wb_t, w6_t, we_t, wd_t); \
76 we_t = SHA512_EXPAND (wc_t, w7_t, wf_t, we_t); \
77 wf_t = SHA512_EXPAND (wd_t, w8_t, w0_t, wf_t); \
80 #define ROUND_STEP(i) \
82 SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w0_t, k[i + 0]); \
83 SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w1_t, k[i + 1]); \
84 SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, w2_t, k[i + 2]); \
85 SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, w3_t, k[i + 3]); \
86 SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, w4_t, k[i + 4]); \
87 SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, w5_t, k[i + 5]); \
88 SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, w6_t, k[i + 6]); \
89 SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, w7_t, k[i + 7]); \
90 SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w8_t, k[i + 8]); \
91 SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w9_t, k[i + 9]); \
92 SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, wa_t, k[i + 10]); \
93 SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, wb_t, k[i + 11]); \
94 SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, wc_t, k[i + 12]); \
95 SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, wd_t, k[i + 13]); \
96 SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, we_t, k[i + 14]); \
97 SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, wf_t, k[i + 15]); \
100 __device__ static void sha512_transform (const u64x w0[4], const u64x w1[4], const u64x w2[4], const u64x w3[4], u64x digest[8])
130 for (int i = 16; i < 80; i += 16)
132 ROUND_EXPAND (); ROUND_STEP (i);
145 __device__ static void hmac_sha512_pad (u64x w0[4], u64x w1[4], u64x w2[4], u64x w3[4], u64x ipad[8], u64x opad[8])
147 w0[0] = w0[0] ^ 0x3636363636363636;
148 w0[1] = w0[1] ^ 0x3636363636363636;
149 w0[2] = w0[2] ^ 0x3636363636363636;
150 w0[3] = w0[3] ^ 0x3636363636363636;
151 w1[0] = w1[0] ^ 0x3636363636363636;
152 w1[1] = w1[1] ^ 0x3636363636363636;
153 w1[2] = w1[2] ^ 0x3636363636363636;
154 w1[3] = w1[3] ^ 0x3636363636363636;
155 w2[0] = w2[0] ^ 0x3636363636363636;
156 w2[1] = w2[1] ^ 0x3636363636363636;
157 w2[2] = w2[2] ^ 0x3636363636363636;
158 w2[3] = w2[3] ^ 0x3636363636363636;
159 w3[0] = w3[0] ^ 0x3636363636363636;
160 w3[1] = w3[1] ^ 0x3636363636363636;
161 w3[2] = w3[2] ^ 0x3636363636363636;
162 w3[3] = w3[3] ^ 0x3636363636363636;
173 sha512_transform (w0, w1, w2, w3, ipad);
175 w0[0] = w0[0] ^ 0x6a6a6a6a6a6a6a6a;
176 w0[1] = w0[1] ^ 0x6a6a6a6a6a6a6a6a;
177 w0[2] = w0[2] ^ 0x6a6a6a6a6a6a6a6a;
178 w0[3] = w0[3] ^ 0x6a6a6a6a6a6a6a6a;
179 w1[0] = w1[0] ^ 0x6a6a6a6a6a6a6a6a;
180 w1[1] = w1[1] ^ 0x6a6a6a6a6a6a6a6a;
181 w1[2] = w1[2] ^ 0x6a6a6a6a6a6a6a6a;
182 w1[3] = w1[3] ^ 0x6a6a6a6a6a6a6a6a;
183 w2[0] = w2[0] ^ 0x6a6a6a6a6a6a6a6a;
184 w2[1] = w2[1] ^ 0x6a6a6a6a6a6a6a6a;
185 w2[2] = w2[2] ^ 0x6a6a6a6a6a6a6a6a;
186 w2[3] = w2[3] ^ 0x6a6a6a6a6a6a6a6a;
187 w3[0] = w3[0] ^ 0x6a6a6a6a6a6a6a6a;
188 w3[1] = w3[1] ^ 0x6a6a6a6a6a6a6a6a;
189 w3[2] = w3[2] ^ 0x6a6a6a6a6a6a6a6a;
190 w3[3] = w3[3] ^ 0x6a6a6a6a6a6a6a6a;
201 sha512_transform (w0, w1, w2, w3, opad);
204 __device__ static void hmac_sha512_run (u64x w0[4], u64x w1[4], u64x w2[4], u64x w3[4], u64x ipad[8], u64x opad[8], u64x digest[8])
215 sha512_transform (w0, w1, w2, w3, digest);
225 w2[0] = 0x8000000000000000;
232 w3[3] = (128 + 64) * 8;
243 sha512_transform (w0, w1, w2, w3, digest);
246 extern "C" __global__ void __launch_bounds__ (256, 1) m06500_init (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, sha512aix_tmp_t *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)
252 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
254 if (gid >= gid_max) return;
258 w0[0] = pws[gid].i[ 0];
259 w0[1] = pws[gid].i[ 1];
260 w0[2] = pws[gid].i[ 2];
261 w0[3] = pws[gid].i[ 3];
265 w1[0] = pws[gid].i[ 4];
266 w1[1] = pws[gid].i[ 5];
267 w1[2] = pws[gid].i[ 6];
268 w1[3] = pws[gid].i[ 7];
272 w2[0] = pws[gid].i[ 8];
273 w2[1] = pws[gid].i[ 9];
274 w2[2] = pws[gid].i[10];
275 w2[3] = pws[gid].i[11];
279 w3[0] = pws[gid].i[12];
280 w3[1] = pws[gid].i[13];
281 w3[2] = pws[gid].i[14];
282 w3[3] = pws[gid].i[15];
288 u32 salt_len = salt_bufs[salt_pos].salt_len;
292 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
293 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
294 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
295 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
299 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
300 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
301 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
302 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
306 salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
307 salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
308 salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
309 salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
318 append_0x01_4 (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_len + 3);
320 append_0x80_4 (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_len + 4);
326 w0[0] = swap_workaround (w0[0]);
327 w0[1] = swap_workaround (w0[1]);
328 w0[2] = swap_workaround (w0[2]);
329 w0[3] = swap_workaround (w0[3]);
330 w1[0] = swap_workaround (w1[0]);
331 w1[1] = swap_workaround (w1[1]);
332 w1[2] = swap_workaround (w1[2]);
333 w1[3] = swap_workaround (w1[3]);
334 w2[0] = swap_workaround (w2[0]);
335 w2[1] = swap_workaround (w2[1]);
336 w2[2] = swap_workaround (w2[2]);
337 w2[3] = swap_workaround (w2[3]);
338 w3[0] = swap_workaround (w3[0]);
339 w3[1] = swap_workaround (w3[1]);
340 w3[2] = swap_workaround (w3[2]);
341 w3[3] = swap_workaround (w3[3]);
348 w0l[0] = (u64x) (w0[0]) << 32 | (u64x) (w0[1]);
349 w0l[1] = (u64x) (w0[2]) << 32 | (u64x) (w0[3]);
350 w0l[2] = (u64x) (w1[0]) << 32 | (u64x) (w1[1]);
351 w0l[3] = (u64x) (w1[2]) << 32 | (u64x) (w1[3]);
352 w1l[0] = (u64x) (w2[0]) << 32 | (u64x) (w2[1]);
353 w1l[1] = (u64x) (w2[2]) << 32 | (u64x) (w2[3]);
354 w1l[2] = (u64x) (w3[0]) << 32 | (u64x) (w3[1]);
355 w1l[3] = (u64x) (w3[2]) << 32 | (u64x) (w3[3]);
368 hmac_sha512_pad (w0l, w1l, w2l, w3l, ipad, opad);
370 tmps[gid].ipad[0] = ipad[0];
371 tmps[gid].ipad[1] = ipad[1];
372 tmps[gid].ipad[2] = ipad[2];
373 tmps[gid].ipad[3] = ipad[3];
374 tmps[gid].ipad[4] = ipad[4];
375 tmps[gid].ipad[5] = ipad[5];
376 tmps[gid].ipad[6] = ipad[6];
377 tmps[gid].ipad[7] = ipad[7];
379 tmps[gid].opad[0] = opad[0];
380 tmps[gid].opad[1] = opad[1];
381 tmps[gid].opad[2] = opad[2];
382 tmps[gid].opad[3] = opad[3];
383 tmps[gid].opad[4] = opad[4];
384 tmps[gid].opad[5] = opad[5];
385 tmps[gid].opad[6] = opad[6];
386 tmps[gid].opad[7] = opad[7];
388 w0l[0] = (u64x) salt_buf0[1] << 32 | (u64x) salt_buf0[0];
389 w0l[1] = (u64x) salt_buf0[3] << 32 | (u64x) salt_buf0[2];
390 w0l[2] = (u64x) salt_buf1[1] << 32 | (u64x) salt_buf1[0];
391 w0l[3] = (u64x) salt_buf1[3] << 32 | (u64x) salt_buf1[2];
392 w1l[0] = (u64x) salt_buf2[1] << 32 | (u64x) salt_buf2[0];
393 w1l[1] = (u64x) salt_buf2[3] << 32 | (u64x) salt_buf2[2];
394 w1l[2] = (u64x) salt_buf3[1] << 32 | (u64x) salt_buf3[0];
395 w1l[3] = (u64x) salt_buf3[3] << 32 | (u64x) salt_buf3[2];
405 w0l[0] = swap_workaround (w0l[0]);
406 w0l[1] = swap_workaround (w0l[1]);
407 w0l[2] = swap_workaround (w0l[2]);
408 w0l[3] = swap_workaround (w0l[3]);
409 w1l[0] = swap_workaround (w1l[0]);
410 w1l[1] = swap_workaround (w1l[1]);
411 w1l[2] = swap_workaround (w1l[2]);
412 w1l[3] = swap_workaround (w1l[3]);
420 w3l[3] = (128 + salt_len + 4) * 8;
424 hmac_sha512_run (w0l, w1l, w2l, w3l, ipad, opad, dgst);
426 tmps[gid].dgst[0] = dgst[0];
427 tmps[gid].dgst[1] = dgst[1];
428 tmps[gid].dgst[2] = dgst[2];
429 tmps[gid].dgst[3] = dgst[3];
430 tmps[gid].dgst[4] = dgst[4];
431 tmps[gid].dgst[5] = dgst[5];
432 tmps[gid].dgst[6] = dgst[6];
433 tmps[gid].dgst[7] = dgst[7];
435 tmps[gid].out[0] = dgst[0];
436 tmps[gid].out[1] = dgst[1];
437 tmps[gid].out[2] = dgst[2];
438 tmps[gid].out[3] = dgst[3];
439 tmps[gid].out[4] = dgst[4];
440 tmps[gid].out[5] = dgst[5];
441 tmps[gid].out[6] = dgst[6];
442 tmps[gid].out[7] = dgst[7];
445 extern "C" __global__ void __launch_bounds__ (256, 1) m06500_loop (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, sha512aix_tmp_t *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)
447 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
449 if (gid >= gid_max) return;
454 ipad[0] = tmps[gid].ipad[0];
455 ipad[1] = tmps[gid].ipad[1];
456 ipad[2] = tmps[gid].ipad[2];
457 ipad[3] = tmps[gid].ipad[3];
458 ipad[4] = tmps[gid].ipad[4];
459 ipad[5] = tmps[gid].ipad[5];
460 ipad[6] = tmps[gid].ipad[6];
461 ipad[7] = tmps[gid].ipad[7];
463 opad[0] = tmps[gid].opad[0];
464 opad[1] = tmps[gid].opad[1];
465 opad[2] = tmps[gid].opad[2];
466 opad[3] = tmps[gid].opad[3];
467 opad[4] = tmps[gid].opad[4];
468 opad[5] = tmps[gid].opad[5];
469 opad[6] = tmps[gid].opad[6];
470 opad[7] = tmps[gid].opad[7];
475 dgst[0] = tmps[gid].dgst[0];
476 dgst[1] = tmps[gid].dgst[1];
477 dgst[2] = tmps[gid].dgst[2];
478 dgst[3] = tmps[gid].dgst[3];
479 dgst[4] = tmps[gid].dgst[4];
480 dgst[5] = tmps[gid].dgst[5];
481 dgst[6] = tmps[gid].dgst[6];
482 dgst[7] = tmps[gid].dgst[7];
484 out[0] = tmps[gid].out[0];
485 out[1] = tmps[gid].out[1];
486 out[2] = tmps[gid].out[2];
487 out[3] = tmps[gid].out[3];
488 out[4] = tmps[gid].out[4];
489 out[5] = tmps[gid].out[5];
490 out[6] = tmps[gid].out[6];
491 out[7] = tmps[gid].out[7];
493 for (u32 j = 0; j < loop_cnt; j++)
508 w2[0] = 0x8000000000000000;
515 w3[3] = (128 + 64) * 8;
517 hmac_sha512_run (w0, w1, w2, w3, ipad, opad, dgst);
529 tmps[gid].dgst[0] = dgst[0];
530 tmps[gid].dgst[1] = dgst[1];
531 tmps[gid].dgst[2] = dgst[2];
532 tmps[gid].dgst[3] = dgst[3];
533 tmps[gid].dgst[4] = dgst[4];
534 tmps[gid].dgst[5] = dgst[5];
535 tmps[gid].dgst[6] = dgst[6];
536 tmps[gid].dgst[7] = dgst[7];
538 tmps[gid].out[0] = out[0];
539 tmps[gid].out[1] = out[1];
540 tmps[gid].out[2] = out[2];
541 tmps[gid].out[3] = out[3];
542 tmps[gid].out[4] = out[4];
543 tmps[gid].out[5] = out[5];
544 tmps[gid].out[6] = out[6];
545 tmps[gid].out[7] = out[7];
548 extern "C" __global__ void __launch_bounds__ (256, 1) m06500_comp (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, sha512aix_tmp_t *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)
554 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
556 if (gid >= gid_max) return;
558 const u32 lid = threadIdx.x;
565 u64x a = tmps[gid].out[0];
566 u64x b = tmps[gid].out[1];
567 u64x c = tmps[gid].out[2];
568 u64x d = tmps[gid].out[3];
569 u64x e = tmps[gid].out[4];
570 u64x f = tmps[gid].out[5];
571 u64x g = tmps[gid].out[6];
572 u64x h = tmps[gid].out[7] & 0xffffffffffffff00;
575 const u32x r0 = l32_from_64 (tmps[gid].out[0]);
576 const u32x r1 = h32_from_64 (tmps[gid].out[0]);
577 const u32x r2 = l32_from_64 (tmps[gid].out[1]);
578 const u32x r3 = h32_from_64 (tmps[gid].out[1]);
582 #include VECT_COMPARE_M