2 * Author......: Jens Steube <jens.steube@gmail.com>
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
28 #include "include/kernel_functions.c"
29 #include "types_amd.c"
30 #include "common_amd.c"
31 #include "include/rp_gpu.h"
35 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
36 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
40 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
41 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
44 __constant u64 keccakf_rndc[24] =
46 0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
47 0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
48 0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
49 0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
50 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
51 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
52 0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
53 0x8000000000008080, 0x0000000080000001, 0x8000000080008008
56 __constant u32 keccakf_rotc[24] =
58 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
59 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
62 __constant u32 keccakf_piln[24] =
64 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
65 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
69 #define KECCAK_ROUNDS 24
72 #define Theta1(s) (st[0 + s] ^ st[5 + s] ^ st[10 + s] ^ st[15 + s] ^ st[20 + s])
85 u32 j = keccakf_piln[s]; \
86 u32 k = keccakf_rotc[s]; \
88 st[j] = rotl64 (t, k); \
99 st[0 + s] ^= ~bc1 & bc2; \
100 st[1 + s] ^= ~bc2 & bc3; \
101 st[2 + s] ^= ~bc3 & bc4; \
102 st[3 + s] ^= ~bc4 & bc0; \
103 st[4 + s] ^= ~bc0 & bc1; \
106 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05000_m04 (__global pw_t *pws, __global gpu_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
112 const u32 lid = get_local_id (0);
118 const u32 gid = get_global_id (0);
120 if (gid >= gid_max) return;
124 pw_buf0[0] = pws[gid].i[ 0];
125 pw_buf0[1] = pws[gid].i[ 1];
126 pw_buf0[2] = pws[gid].i[ 2];
127 pw_buf0[3] = pws[gid].i[ 3];
131 pw_buf1[0] = pws[gid].i[ 4];
132 pw_buf1[1] = pws[gid].i[ 5];
133 pw_buf1[2] = pws[gid].i[ 6];
134 pw_buf1[3] = pws[gid].i[ 7];
136 const u32 pw_len = pws[gid].pw_len;
139 * 0x80 keccak, very special
142 const u32 mdlen = salt_bufs[salt_pos].keccak_mdlen;
144 const u32 rsiz = 200 - (2 * mdlen);
146 const u32 add80w = (rsiz - 1) / 8;
152 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
182 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
184 append_0x01_2 (w0, w1, out_len);
189 st[ 0] = (u64x) (w0[0]) | (u64x) (w0[1]) << 32;
190 st[ 1] = (u64x) (w0[2]) | (u64x) (w0[3]) << 32;
191 st[ 2] = (u64x) (w1[0]) | (u64x) (w1[1]) << 32;
192 st[ 3] = (u64x) (w1[2]) | (u64x) (w1[3]) << 32;
196 st[ 0] = (u64x) (w0[0].s0, w0[0].s1) | (u64x) (w0[1].s0, w0[1].s1) << 32;
197 st[ 1] = (u64x) (w0[2].s0, w0[2].s1) | (u64x) (w0[3].s0, w0[3].s1) << 32;
198 st[ 2] = (u64x) (w1[0].s0, w1[0].s1) | (u64x) (w1[1].s0, w1[1].s1) << 32;
199 st[ 3] = (u64x) (w1[2].s0, w1[2].s1) | (u64x) (w1[3].s0, w1[3].s1) << 32;
224 st[add80w] |= 0x8000000000000000;
228 for (round = 0; round < KECCAK_ROUNDS; round++)
232 u64x bc0 = Theta1 (0);
233 u64x bc1 = Theta1 (1);
234 u64x bc2 = Theta1 (2);
235 u64x bc3 = Theta1 (3);
236 u64x bc4 = Theta1 (4);
240 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
241 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
242 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
243 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
244 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
285 st[0] ^= keccakf_rndc[round];
288 const u32x r0 = l32_from_64 (st[1]);
289 const u32x r1 = h32_from_64 (st[1]);
290 const u32x r2 = l32_from_64 (st[2]);
291 const u32x r3 = h32_from_64 (st[2]);
293 #include VECT_COMPARE_M
297 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05000_m08 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
301 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05000_m16 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
305 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05000_s04 (__global pw_t *pws, __global gpu_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
311 const u32 lid = get_local_id (0);
317 const u32 gid = get_global_id (0);
319 if (gid >= gid_max) return;
323 pw_buf0[0] = pws[gid].i[ 0];
324 pw_buf0[1] = pws[gid].i[ 1];
325 pw_buf0[2] = pws[gid].i[ 2];
326 pw_buf0[3] = pws[gid].i[ 3];
330 pw_buf1[0] = pws[gid].i[ 4];
331 pw_buf1[1] = pws[gid].i[ 5];
332 pw_buf1[2] = pws[gid].i[ 6];
333 pw_buf1[3] = pws[gid].i[ 7];
335 const u32 pw_len = pws[gid].pw_len;
341 const u32 search[4] =
343 digests_buf[digests_offset].digest_buf[DGST_R0],
344 digests_buf[digests_offset].digest_buf[DGST_R1],
345 digests_buf[digests_offset].digest_buf[DGST_R2],
346 digests_buf[digests_offset].digest_buf[DGST_R3]
350 * 0x80 keccak, very special
353 const u32 mdlen = salt_bufs[salt_pos].keccak_mdlen;
355 const u32 rsiz = 200 - (2 * mdlen);
357 const u32 add80w = (rsiz - 1) / 8;
363 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
393 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
395 append_0x01_2 (w0, w1, out_len);
400 st[ 0] = (u64x) (w0[0]) | (u64x) (w0[1]) << 32;
401 st[ 1] = (u64x) (w0[2]) | (u64x) (w0[3]) << 32;
402 st[ 2] = (u64x) (w1[0]) | (u64x) (w1[1]) << 32;
403 st[ 3] = (u64x) (w1[2]) | (u64x) (w1[3]) << 32;
407 st[ 0] = (u64x) (w0[0].s0, w0[0].s1) | (u64x) (w0[1].s0, w0[1].s1) << 32;
408 st[ 1] = (u64x) (w0[2].s0, w0[2].s1) | (u64x) (w0[3].s0, w0[3].s1) << 32;
409 st[ 2] = (u64x) (w1[0].s0, w1[0].s1) | (u64x) (w1[1].s0, w1[1].s1) << 32;
410 st[ 3] = (u64x) (w1[2].s0, w1[2].s1) | (u64x) (w1[3].s0, w1[3].s1) << 32;
435 st[add80w] |= 0x8000000000000000;
439 for (round = 0; round < KECCAK_ROUNDS; round++)
443 u64x bc0 = Theta1 (0);
444 u64x bc1 = Theta1 (1);
445 u64x bc2 = Theta1 (2);
446 u64x bc3 = Theta1 (3);
447 u64x bc4 = Theta1 (4);
451 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
452 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
453 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
454 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
455 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
496 st[0] ^= keccakf_rndc[round];
499 const u32x r0 = l32_from_64 (st[1]);
500 const u32x r1 = h32_from_64 (st[1]);
501 const u32x r2 = l32_from_64 (st[2]);
502 const u32x r3 = h32_from_64 (st[2]);
504 #include VECT_COMPARE_S
508 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05000_s08 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
512 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05000_s16 (__global pw_t *pws, __global gpu_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)