2 * Author......: Jens Steube <jens.steube@gmail.com>
10 #include "include/constants.h"
11 #include "include/kernel_vendor.h"
18 #include "include/kernel_functions.c"
19 #include "OpenCL/types_ocl.c"
20 #include "OpenCL/common.c"
21 #include "include/rp_kernel.h"
22 #include "OpenCL/rp.c"
23 #include "OpenCL/simd.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 m05000_m04 (__global pw_t *pws, __global kernel_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 il_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 < il_cnt; il_pos += VECT_SIZE)
144 const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
146 append_0x01_2x4_VV (w0, w1, out_len);
150 st[ 0] = hl32_to_64 (w0[1], w0[0]);
151 st[ 1] = hl32_to_64 (w0[3], w0[2]);
152 st[ 2] = hl32_to_64 (w1[1], w1[0]);
153 st[ 3] = hl32_to_64 (w1[3], w1[2]);
176 st[add80w] |= 0x8000000000000000;
180 for (round = 0; round < KECCAK_ROUNDS; round++)
184 u64x bc0 = Theta1 (0);
185 u64x bc1 = Theta1 (1);
186 u64x bc2 = Theta1 (2);
187 u64x bc3 = Theta1 (3);
188 u64x bc4 = Theta1 (4);
192 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
193 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
194 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
195 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
196 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
237 st[0] ^= keccakf_rndc[round];
240 const u32x r0 = l32_from_64 (st[1]);
241 const u32x r1 = h32_from_64 (st[1]);
242 const u32x r2 = l32_from_64 (st[2]);
243 const u32x r3 = h32_from_64 (st[2]);
245 COMPARE_M_SIMD (r0, r1, r2, r3);
249 __kernel void m05000_m08 (__global pw_t *pws, __global kernel_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
253 __kernel void m05000_m16 (__global pw_t *pws, __global kernel_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
257 __kernel void m05000_s04 (__global pw_t *pws, __global kernel_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
263 const u32 lid = get_local_id (0);
269 const u8 keccakf_rotc[24] =
271 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
272 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
275 const u8 keccakf_piln[24] =
277 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
278 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
285 const u32 gid = get_global_id (0);
287 if (gid >= gid_max) return;
291 pw_buf0[0] = pws[gid].i[ 0];
292 pw_buf0[1] = pws[gid].i[ 1];
293 pw_buf0[2] = pws[gid].i[ 2];
294 pw_buf0[3] = pws[gid].i[ 3];
298 pw_buf1[0] = pws[gid].i[ 4];
299 pw_buf1[1] = pws[gid].i[ 5];
300 pw_buf1[2] = pws[gid].i[ 6];
301 pw_buf1[3] = pws[gid].i[ 7];
303 const u32 pw_len = pws[gid].pw_len;
309 const u32 search[4] =
311 digests_buf[digests_offset].digest_buf[DGST_R0],
312 digests_buf[digests_offset].digest_buf[DGST_R1],
313 digests_buf[digests_offset].digest_buf[DGST_R2],
314 digests_buf[digests_offset].digest_buf[DGST_R3]
318 * 0x80 keccak, very special
321 const u32 mdlen = salt_bufs[salt_pos].keccak_mdlen;
323 const u32 rsiz = 200 - (2 * mdlen);
325 const u32 add80w = (rsiz - 1) / 8;
331 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
338 const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
340 append_0x01_2x4_VV (w0, w1, out_len);
344 st[ 0] = hl32_to_64 (w0[1], w0[0]);
345 st[ 1] = hl32_to_64 (w0[3], w0[2]);
346 st[ 2] = hl32_to_64 (w1[1], w1[0]);
347 st[ 3] = hl32_to_64 (w1[3], w1[2]);
370 st[add80w] |= 0x8000000000000000;
374 for (round = 0; round < KECCAK_ROUNDS; round++)
378 u64x bc0 = Theta1 (0);
379 u64x bc1 = Theta1 (1);
380 u64x bc2 = Theta1 (2);
381 u64x bc3 = Theta1 (3);
382 u64x bc4 = Theta1 (4);
386 t = bc4 ^ rotl64 (bc1, 1); Theta2 (0);
387 t = bc0 ^ rotl64 (bc2, 1); Theta2 (1);
388 t = bc1 ^ rotl64 (bc3, 1); Theta2 (2);
389 t = bc2 ^ rotl64 (bc4, 1); Theta2 (3);
390 t = bc3 ^ rotl64 (bc0, 1); Theta2 (4);
431 st[0] ^= keccakf_rndc[round];
434 const u32x r0 = l32_from_64 (st[1]);
435 const u32x r1 = h32_from_64 (st[1]);
436 const u32x r2 = l32_from_64 (st[2]);
437 const u32x r3 = h32_from_64 (st[2]);
439 COMPARE_S_SIMD (r0, r1, r2, r3);
443 __kernel void m05000_s08 (__global pw_t *pws, __global kernel_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
447 __kernel void m05000_s16 (__global pw_t *pws, __global kernel_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)