2 * Author......: Jens Steube <jens.steube@gmail.com>
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
16 #include "include/kernel_functions.c"
17 #include "types_ocl.c"
19 #include "include/rp_gpu.h"
22 #define COMPARE_S "check_single_comp4.c"
23 #define COMPARE_M "check_multi_comp4.c"
25 __constant u64 keccakf_rndc[24] =
27 0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
28 0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
29 0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
30 0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
31 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
32 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
33 0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
34 0x8000000000008080, 0x0000000080000001, 0x8000000080008008
38 #define KECCAK_ROUNDS 24
41 #define Theta1(s) (st[0 + s] ^ st[5 + s] ^ st[10 + s] ^ st[15 + s] ^ st[20 + s])
54 u32 j = keccakf_piln[s]; \
55 u32 k = keccakf_rotc[s]; \
57 st[j] = rotl64 (t, k); \
68 st[0 + s] ^= ~bc1 & bc2; \
69 st[1 + s] ^= ~bc2 & bc3; \
70 st[2 + s] ^= ~bc3 & bc4; \
71 st[3 + s] ^= ~bc4 & bc0; \
72 st[4 + s] ^= ~bc0 & bc1; \
75 __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)
81 const u32 lid = get_local_id (0);
87 const u8 keccakf_rotc[24] =
89 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
90 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
93 const u8 keccakf_piln[24] =
95 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
96 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
103 const u32 gid = get_global_id (0);
105 if (gid >= gid_max) return;
109 pw_buf0[0] = pws[gid].i[ 0];
110 pw_buf0[1] = pws[gid].i[ 1];
111 pw_buf0[2] = pws[gid].i[ 2];
112 pw_buf0[3] = pws[gid].i[ 3];
116 pw_buf1[0] = pws[gid].i[ 4];
117 pw_buf1[1] = pws[gid].i[ 5];
118 pw_buf1[2] = pws[gid].i[ 6];
119 pw_buf1[3] = pws[gid].i[ 7];
121 const u32 pw_len = pws[gid].pw_len;
124 * 0x80 keccak, very special
127 const u32 mdlen = salt_bufs[salt_pos].keccak_mdlen;
129 const u32 rsiz = 200 - (2 * mdlen);
131 const u32 add80w = (rsiz - 1) / 8;
137 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
167 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
169 append_0x01_2x4 (w0, w1, out_len);
173 st[ 0] = (u64) (w0[0]) | (u64) (w0[1]) << 32;
174 st[ 1] = (u64) (w0[2]) | (u64) (w0[3]) << 32;
175 st[ 2] = (u64) (w1[0]) | (u64) (w1[1]) << 32;
176 st[ 3] = (u64) (w1[2]) | (u64) (w1[3]) << 32;
199 st[add80w] |= 0x8000000000000000;
203 for (round = 0; round < KECCAK_ROUNDS; round++)
207 u64 bc0 = Theta1 (0);
208 u64 bc1 = Theta1 (1);
209 u64 bc2 = Theta1 (2);
210 u64 bc3 = Theta1 (3);
211 u64 bc4 = Theta1 (4);
215 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
216 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
217 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
218 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
219 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
260 st[0] ^= keccakf_rndc[round];
263 const u32 r0 = l32_from_64 (st[1]);
264 const u32 r1 = h32_from_64 (st[1]);
265 const u32 r2 = l32_from_64 (st[2]);
266 const u32 r3 = h32_from_64 (st[2]);
272 __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)
276 __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)
280 __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)
286 const u32 lid = get_local_id (0);
292 const u8 keccakf_rotc[24] =
294 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
295 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
298 const u8 keccakf_piln[24] =
300 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
301 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
308 const u32 gid = get_global_id (0);
310 if (gid >= gid_max) return;
314 pw_buf0[0] = pws[gid].i[ 0];
315 pw_buf0[1] = pws[gid].i[ 1];
316 pw_buf0[2] = pws[gid].i[ 2];
317 pw_buf0[3] = pws[gid].i[ 3];
321 pw_buf1[0] = pws[gid].i[ 4];
322 pw_buf1[1] = pws[gid].i[ 5];
323 pw_buf1[2] = pws[gid].i[ 6];
324 pw_buf1[3] = pws[gid].i[ 7];
326 const u32 pw_len = pws[gid].pw_len;
332 const u32 search[4] =
334 digests_buf[digests_offset].digest_buf[DGST_R0],
335 digests_buf[digests_offset].digest_buf[DGST_R1],
336 digests_buf[digests_offset].digest_buf[DGST_R2],
337 digests_buf[digests_offset].digest_buf[DGST_R3]
341 * 0x80 keccak, very special
344 const u32 mdlen = salt_bufs[salt_pos].keccak_mdlen;
346 const u32 rsiz = 200 - (2 * mdlen);
348 const u32 add80w = (rsiz - 1) / 8;
354 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
384 const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
386 append_0x01_2x4 (w0, w1, out_len);
390 st[ 0] = (u64) (w0[0]) | (u64) (w0[1]) << 32;
391 st[ 1] = (u64) (w0[2]) | (u64) (w0[3]) << 32;
392 st[ 2] = (u64) (w1[0]) | (u64) (w1[1]) << 32;
393 st[ 3] = (u64) (w1[2]) | (u64) (w1[3]) << 32;
416 st[add80w] |= 0x8000000000000000;
420 for (round = 0; round < KECCAK_ROUNDS; round++)
424 u64 bc0 = Theta1 (0);
425 u64 bc1 = Theta1 (1);
426 u64 bc2 = Theta1 (2);
427 u64 bc3 = Theta1 (3);
428 u64 bc4 = Theta1 (4);
432 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
433 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
434 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
435 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
436 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
477 st[0] ^= keccakf_rndc[round];
480 const u32 r0 = l32_from_64 (st[1]);
481 const u32 r1 = h32_from_64 (st[1]);
482 const u32 r2 = l32_from_64 (st[2]);
483 const u32 r3 = h32_from_64 (st[2]);
489 __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)
493 __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)