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"
33 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
34 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
38 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
39 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
42 __constant u64 keccakf_rndc[24] =
44 0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
45 0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
46 0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
47 0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
48 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
49 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
50 0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
51 0x8000000000008080, 0x0000000080000001, 0x8000000080008008
54 __constant u32 keccakf_rotc[24] =
56 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
57 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
60 __constant u32 keccakf_piln[24] =
62 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
63 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
67 #define KECCAK_ROUNDS 24
70 #define Theta1(s) (st[0 + s] ^ st[5 + s] ^ st[10 + s] ^ st[15 + s] ^ st[20 + s])
83 u32 j = keccakf_piln[s]; \
84 u32 k = keccakf_rotc[s]; \
86 st[j] = rotl64 (t, k); \
97 st[0 + s] ^= ~bc1 & bc2; \
98 st[1 + s] ^= ~bc2 & bc3; \
99 st[2 + s] ^= ~bc3 & bc4; \
100 st[3 + s] ^= ~bc4 & bc0; \
101 st[4 + s] ^= ~bc0 & bc1; \
104 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
110 const u32 lid = get_local_id (0);
116 const u32 gid = get_global_id (0);
118 if (gid >= gid_max) return;
122 wordl0[0] = pws[gid].i[ 0];
123 wordl0[1] = pws[gid].i[ 1];
124 wordl0[2] = pws[gid].i[ 2];
125 wordl0[3] = pws[gid].i[ 3];
129 wordl1[0] = pws[gid].i[ 4];
130 wordl1[1] = pws[gid].i[ 5];
131 wordl1[2] = pws[gid].i[ 6];
132 wordl1[3] = pws[gid].i[ 7];
148 const u32 pw_l_len = pws[gid].pw_len;
150 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
152 append_0x01_2 (wordl0, wordl1, pw_l_len);
154 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
158 * 0x80 keccak, very special
161 const u32 mdlen = salt_bufs[salt_pos].keccak_mdlen;
163 const u32 rsiz = 200 - (2 * mdlen);
165 const u32 add80w = (rsiz - 1) / 8;
171 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
173 const u32 pw_r_len = combs_buf[il_pos].pw_len;
175 const u32 pw_len = pw_l_len + pw_r_len;
179 wordr0[0] = combs_buf[il_pos].i[0];
180 wordr0[1] = combs_buf[il_pos].i[1];
181 wordr0[2] = combs_buf[il_pos].i[2];
182 wordr0[3] = combs_buf[il_pos].i[3];
186 wordr1[0] = combs_buf[il_pos].i[4];
187 wordr1[1] = combs_buf[il_pos].i[5];
188 wordr1[2] = combs_buf[il_pos].i[6];
189 wordr1[3] = combs_buf[il_pos].i[7];
205 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
207 append_0x01_2 (wordr0, wordr1, pw_r_len);
209 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
214 w0[0] = wordl0[0] | wordr0[0];
215 w0[1] = wordl0[1] | wordr0[1];
216 w0[2] = wordl0[2] | wordr0[2];
217 w0[3] = wordl0[3] | wordr0[3];
221 w1[0] = wordl1[0] | wordr1[0];
222 w1[1] = wordl1[1] | wordr1[1];
223 w1[2] = wordl1[2] | wordr1[2];
224 w1[3] = wordl1[3] | wordr1[3];
228 w2[0] = wordl2[0] | wordr2[0];
229 w2[1] = wordl2[1] | wordr2[1];
230 w2[2] = wordl2[2] | wordr2[2];
231 w2[3] = wordl2[3] | wordr2[3];
235 w3[0] = wordl3[0] | wordr3[0];
236 w3[1] = wordl3[1] | wordr3[1];
243 st[ 0] = (u64x) (w0[0]) | (u64x) (w0[1]) << 32;
244 st[ 1] = (u64x) (w0[2]) | (u64x) (w0[3]) << 32;
245 st[ 2] = (u64x) (w1[0]) | (u64x) (w1[1]) << 32;
246 st[ 3] = (u64x) (w1[2]) | (u64x) (w1[3]) << 32;
250 st[ 0] = (u64x) (w0[0].s0, w0[0].s1) | (u64x) (w0[1].s0, w0[1].s1) << 32;
251 st[ 1] = (u64x) (w0[2].s0, w0[2].s1) | (u64x) (w0[3].s0, w0[3].s1) << 32;
252 st[ 2] = (u64x) (w1[0].s0, w1[0].s1) | (u64x) (w1[1].s0, w1[1].s1) << 32;
253 st[ 3] = (u64x) (w1[2].s0, w1[2].s1) | (u64x) (w1[3].s0, w1[3].s1) << 32;
278 st[add80w] |= 0x8000000000000000;
282 for (round = 0; round < KECCAK_ROUNDS; round++)
286 u64x bc0 = Theta1 (0);
287 u64x bc1 = Theta1 (1);
288 u64x bc2 = Theta1 (2);
289 u64x bc3 = Theta1 (3);
290 u64x bc4 = Theta1 (4);
294 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
295 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
296 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
297 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
298 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
339 st[0] ^= keccakf_rndc[round];
342 const u32x r0 = l32_from_64 (st[1]);
343 const u32x r1 = h32_from_64 (st[1]);
344 const u32x r2 = l32_from_64 (st[2]);
345 const u32x r3 = h32_from_64 (st[2]);
347 #include VECT_COMPARE_M
351 __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)
355 __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)
359 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
365 const u32 lid = get_local_id (0);
371 const u32 gid = get_global_id (0);
373 if (gid >= gid_max) return;
377 wordl0[0] = pws[gid].i[ 0];
378 wordl0[1] = pws[gid].i[ 1];
379 wordl0[2] = pws[gid].i[ 2];
380 wordl0[3] = pws[gid].i[ 3];
384 wordl1[0] = pws[gid].i[ 4];
385 wordl1[1] = pws[gid].i[ 5];
386 wordl1[2] = pws[gid].i[ 6];
387 wordl1[3] = pws[gid].i[ 7];
403 const u32 pw_l_len = pws[gid].pw_len;
405 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
407 append_0x01_2 (wordl0, wordl1, pw_l_len);
409 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
416 const u32 search[4] =
418 digests_buf[digests_offset].digest_buf[DGST_R0],
419 digests_buf[digests_offset].digest_buf[DGST_R1],
420 digests_buf[digests_offset].digest_buf[DGST_R2],
421 digests_buf[digests_offset].digest_buf[DGST_R3]
425 * 0x80 keccak, very special
428 const u32 mdlen = salt_bufs[salt_pos].keccak_mdlen;
430 const u32 rsiz = 200 - (2 * mdlen);
432 const u32 add80w = (rsiz - 1) / 8;
438 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
440 const u32 pw_r_len = combs_buf[il_pos].pw_len;
442 const u32 pw_len = pw_l_len + pw_r_len;
446 wordr0[0] = combs_buf[il_pos].i[0];
447 wordr0[1] = combs_buf[il_pos].i[1];
448 wordr0[2] = combs_buf[il_pos].i[2];
449 wordr0[3] = combs_buf[il_pos].i[3];
453 wordr1[0] = combs_buf[il_pos].i[4];
454 wordr1[1] = combs_buf[il_pos].i[5];
455 wordr1[2] = combs_buf[il_pos].i[6];
456 wordr1[3] = combs_buf[il_pos].i[7];
472 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
474 append_0x01_2 (wordr0, wordr1, pw_r_len);
476 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
481 w0[0] = wordl0[0] | wordr0[0];
482 w0[1] = wordl0[1] | wordr0[1];
483 w0[2] = wordl0[2] | wordr0[2];
484 w0[3] = wordl0[3] | wordr0[3];
488 w1[0] = wordl1[0] | wordr1[0];
489 w1[1] = wordl1[1] | wordr1[1];
490 w1[2] = wordl1[2] | wordr1[2];
491 w1[3] = wordl1[3] | wordr1[3];
495 w2[0] = wordl2[0] | wordr2[0];
496 w2[1] = wordl2[1] | wordr2[1];
497 w2[2] = wordl2[2] | wordr2[2];
498 w2[3] = wordl2[3] | wordr2[3];
502 w3[0] = wordl3[0] | wordr3[0];
503 w3[1] = wordl3[1] | wordr3[1];
510 st[ 0] = (u64x) (w0[0]) | (u64x) (w0[1]) << 32;
511 st[ 1] = (u64x) (w0[2]) | (u64x) (w0[3]) << 32;
512 st[ 2] = (u64x) (w1[0]) | (u64x) (w1[1]) << 32;
513 st[ 3] = (u64x) (w1[2]) | (u64x) (w1[3]) << 32;
517 st[ 0] = (u64x) (w0[0].s0, w0[0].s1) | (u64x) (w0[1].s0, w0[1].s1) << 32;
518 st[ 1] = (u64x) (w0[2].s0, w0[2].s1) | (u64x) (w0[3].s0, w0[3].s1) << 32;
519 st[ 2] = (u64x) (w1[0].s0, w1[0].s1) | (u64x) (w1[1].s0, w1[1].s1) << 32;
520 st[ 3] = (u64x) (w1[2].s0, w1[2].s1) | (u64x) (w1[3].s0, w1[3].s1) << 32;
545 st[add80w] |= 0x8000000000000000;
549 for (round = 0; round < KECCAK_ROUNDS; round++)
553 u64x bc0 = Theta1 (0);
554 u64x bc1 = Theta1 (1);
555 u64x bc2 = Theta1 (2);
556 u64x bc3 = Theta1 (3);
557 u64x bc4 = Theta1 (4);
561 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
562 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
563 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
564 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
565 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
606 st[0] ^= keccakf_rndc[round];
609 const u32x r0 = l32_from_64 (st[1]);
610 const u32x r1 = h32_from_64 (st[1]);
611 const u32x r2 = l32_from_64 (st[2]);
612 const u32x r3 = h32_from_64 (st[2]);
614 #include VECT_COMPARE_S
618 __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)
622 __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)