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 "OpenCL/simd.c"
23 __constant u64 k_sha384[80] =
25 SHA384C00, SHA384C01, SHA384C02, SHA384C03,
26 SHA384C04, SHA384C05, SHA384C06, SHA384C07,
27 SHA384C08, SHA384C09, SHA384C0a, SHA384C0b,
28 SHA384C0c, SHA384C0d, SHA384C0e, SHA384C0f,
29 SHA384C10, SHA384C11, SHA384C12, SHA384C13,
30 SHA384C14, SHA384C15, SHA384C16, SHA384C17,
31 SHA384C18, SHA384C19, SHA384C1a, SHA384C1b,
32 SHA384C1c, SHA384C1d, SHA384C1e, SHA384C1f,
33 SHA384C20, SHA384C21, SHA384C22, SHA384C23,
34 SHA384C24, SHA384C25, SHA384C26, SHA384C27,
35 SHA384C28, SHA384C29, SHA384C2a, SHA384C2b,
36 SHA384C2c, SHA384C2d, SHA384C2e, SHA384C2f,
37 SHA384C30, SHA384C31, SHA384C32, SHA384C33,
38 SHA384C34, SHA384C35, SHA384C36, SHA384C37,
39 SHA384C38, SHA384C39, SHA384C3a, SHA384C3b,
40 SHA384C3c, SHA384C3d, SHA384C3e, SHA384C3f,
41 SHA384C40, SHA384C41, SHA384C42, SHA384C43,
42 SHA384C44, SHA384C45, SHA384C46, SHA384C47,
43 SHA384C48, SHA384C49, SHA384C4a, SHA384C4b,
44 SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f,
47 static void sha384_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u64 digest[8])
49 u64 w0_t = hl32_to_64 (w0[0], w0[1]);
50 u64 w1_t = hl32_to_64 (w0[2], w0[3]);
51 u64 w2_t = hl32_to_64 (w1[0], w1[1]);
52 u64 w3_t = hl32_to_64 (w1[2], w1[3]);
53 u64 w4_t = hl32_to_64 (w2[0], w2[1]);
54 u64 w5_t = hl32_to_64 (w2[2], w2[3]);
55 u64 w6_t = hl32_to_64 (w3[0], w3[1]);
64 u64 wf_t = hl32_to_64 (w3[2], w3[3]);
75 #define ROUND_EXPAND() \
77 w0_t = SHA384_EXPAND (we_t, w9_t, w1_t, w0_t); \
78 w1_t = SHA384_EXPAND (wf_t, wa_t, w2_t, w1_t); \
79 w2_t = SHA384_EXPAND (w0_t, wb_t, w3_t, w2_t); \
80 w3_t = SHA384_EXPAND (w1_t, wc_t, w4_t, w3_t); \
81 w4_t = SHA384_EXPAND (w2_t, wd_t, w5_t, w4_t); \
82 w5_t = SHA384_EXPAND (w3_t, we_t, w6_t, w5_t); \
83 w6_t = SHA384_EXPAND (w4_t, wf_t, w7_t, w6_t); \
84 w7_t = SHA384_EXPAND (w5_t, w0_t, w8_t, w7_t); \
85 w8_t = SHA384_EXPAND (w6_t, w1_t, w9_t, w8_t); \
86 w9_t = SHA384_EXPAND (w7_t, w2_t, wa_t, w9_t); \
87 wa_t = SHA384_EXPAND (w8_t, w3_t, wb_t, wa_t); \
88 wb_t = SHA384_EXPAND (w9_t, w4_t, wc_t, wb_t); \
89 wc_t = SHA384_EXPAND (wa_t, w5_t, wd_t, wc_t); \
90 wd_t = SHA384_EXPAND (wb_t, w6_t, we_t, wd_t); \
91 we_t = SHA384_EXPAND (wc_t, w7_t, wf_t, we_t); \
92 wf_t = SHA384_EXPAND (wd_t, w8_t, w0_t, wf_t); \
95 #define ROUND_STEP(i) \
97 SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha384[i + 0]); \
98 SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha384[i + 1]); \
99 SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha384[i + 2]); \
100 SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha384[i + 3]); \
101 SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha384[i + 4]); \
102 SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha384[i + 5]); \
103 SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha384[i + 6]); \
104 SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha384[i + 7]); \
105 SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha384[i + 8]); \
106 SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha384[i + 9]); \
107 SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha384[i + 10]); \
108 SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha384[i + 11]); \
109 SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha384[i + 12]); \
110 SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha384[i + 13]); \
111 SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, we_t, k_sha384[i + 14]); \
112 SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha384[i + 15]); \
117 ROUND_EXPAND (); ROUND_STEP (16);
118 ROUND_EXPAND (); ROUND_STEP (32);
119 ROUND_EXPAND (); ROUND_STEP (48);
120 ROUND_EXPAND (); ROUND_STEP (64);
143 __kernel void m10800_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
149 const u32 lid = get_local_id (0);
155 const u32 gid = get_global_id (0);
157 if (gid >= gid_max) return;
162 pws0[0] = pws[gid].i[0];
163 pws0[1] = pws[gid].i[1];
164 pws0[2] = pws[gid].i[2];
165 pws0[3] = pws[gid].i[3];
166 pws1[0] = pws[gid].i[4];
167 pws1[1] = pws[gid].i[5];
168 pws1[2] = pws[gid].i[6];
169 pws1[3] = pws[gid].i[7];
171 const u32 pw_l_len = pws[gid].pw_len;
177 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
179 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
181 const u32x pw_len = pw_l_len + pw_r_len;
183 u32x wordr0[4] = { 0 };
184 u32x wordr1[4] = { 0 };
185 u32x wordr2[4] = { 0 };
186 u32x wordr3[4] = { 0 };
188 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
189 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
190 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
191 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
192 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
193 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
194 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
195 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
197 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
199 append_0x80_2x4 (wordr0, wordr1, pw_r_len);
201 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
209 w0[0] = wordl0[0] | wordr0[0];
210 w0[1] = wordl0[1] | wordr0[1];
211 w0[2] = wordl0[2] | wordr0[2];
212 w0[3] = wordl0[3] | wordr0[3];
213 w1[0] = wordl1[0] | wordr1[0];
214 w1[1] = wordl1[1] | wordr1[1];
215 w1[2] = wordl1[2] | wordr1[2];
216 w1[3] = wordl1[3] | wordr1[3];
217 w2[0] = wordl2[0] | wordr2[0];
218 w2[1] = wordl2[1] | wordr2[1];
219 w2[2] = wordl2[2] | wordr2[2];
220 w2[3] = wordl2[3] | wordr2[3];
221 w3[0] = wordl3[0] | wordr3[0];
222 w3[1] = wordl3[1] | wordr3[1];
223 w3[2] = wordl3[2] | wordr3[2];
224 w3[3] = wordl3[3] | wordr3[3];
235 w0_t[0] = swap32 (w0[0]);
236 w0_t[1] = swap32 (w0[1]);
237 w0_t[2] = swap32 (w0[2]);
238 w0_t[3] = swap32 (w0[3]);
239 w1_t[0] = swap32 (w1[0]);
240 w1_t[1] = swap32 (w1[1]);
241 w1_t[2] = swap32 (w1[2]);
242 w1_t[3] = swap32 (w1[3]);
243 w2_t[0] = swap32 (w2[0]);
244 w2_t[1] = swap32 (w2[1]);
245 w2_t[2] = swap32 (w2[2]);
246 w2_t[3] = swap32 (w2[3]);
247 w3_t[0] = swap32 (w3[0]);
248 w3_t[1] = swap32 (w3[1]);
250 w3_t[3] = pw_len * 8;
254 digest[0] = SHA384M_A;
255 digest[1] = SHA384M_B;
256 digest[2] = SHA384M_C;
257 digest[3] = SHA384M_D;
258 digest[4] = SHA384M_E;
259 digest[5] = SHA384M_F;
260 digest[6] = SHA384M_G;
261 digest[7] = SHA384M_H;
263 sha384_transform (w0_t, w1_t, w2_t, w3_t, digest);
265 const u32 r0 = l32_from_64 (digest[3]);
266 const u32 r1 = h32_from_64 (digest[3]);
267 const u32 r2 = l32_from_64 (digest[2]);
268 const u32 r3 = h32_from_64 (digest[2]);
274 __kernel void m10800_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
278 __kernel void m10800_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
282 __kernel void m10800_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
288 const u32 lid = get_local_id (0);
294 const u32 gid = get_global_id (0);
296 if (gid >= gid_max) return;
301 pws0[0] = pws[gid].i[0];
302 pws0[1] = pws[gid].i[1];
303 pws0[2] = pws[gid].i[2];
304 pws0[3] = pws[gid].i[3];
305 pws1[0] = pws[gid].i[4];
306 pws1[1] = pws[gid].i[5];
307 pws1[2] = pws[gid].i[6];
308 pws1[3] = pws[gid].i[7];
310 const u32 pw_l_len = pws[gid].pw_len;
316 const u32 search[4] =
318 digests_buf[digests_offset].digest_buf[DGST_R0],
319 digests_buf[digests_offset].digest_buf[DGST_R1],
320 digests_buf[digests_offset].digest_buf[DGST_R2],
321 digests_buf[digests_offset].digest_buf[DGST_R3]
328 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
330 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
332 const u32x pw_len = pw_l_len + pw_r_len;
334 u32x wordr0[4] = { 0 };
335 u32x wordr1[4] = { 0 };
336 u32x wordr2[4] = { 0 };
337 u32x wordr3[4] = { 0 };
339 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
340 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
341 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
342 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
343 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
344 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
345 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
346 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
348 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
350 append_0x80_2x4 (wordr0, wordr1, pw_r_len);
352 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
360 w0[0] = wordl0[0] | wordr0[0];
361 w0[1] = wordl0[1] | wordr0[1];
362 w0[2] = wordl0[2] | wordr0[2];
363 w0[3] = wordl0[3] | wordr0[3];
364 w1[0] = wordl1[0] | wordr1[0];
365 w1[1] = wordl1[1] | wordr1[1];
366 w1[2] = wordl1[2] | wordr1[2];
367 w1[3] = wordl1[3] | wordr1[3];
368 w2[0] = wordl2[0] | wordr2[0];
369 w2[1] = wordl2[1] | wordr2[1];
370 w2[2] = wordl2[2] | wordr2[2];
371 w2[3] = wordl2[3] | wordr2[3];
372 w3[0] = wordl3[0] | wordr3[0];
373 w3[1] = wordl3[1] | wordr3[1];
374 w3[2] = wordl3[2] | wordr3[2];
375 w3[3] = wordl3[3] | wordr3[3];
386 w0_t[0] = swap32 (w0[0]);
387 w0_t[1] = swap32 (w0[1]);
388 w0_t[2] = swap32 (w0[2]);
389 w0_t[3] = swap32 (w0[3]);
390 w1_t[0] = swap32 (w1[0]);
391 w1_t[1] = swap32 (w1[1]);
392 w1_t[2] = swap32 (w1[2]);
393 w1_t[3] = swap32 (w1[3]);
394 w2_t[0] = swap32 (w2[0]);
395 w2_t[1] = swap32 (w2[1]);
396 w2_t[2] = swap32 (w2[2]);
397 w2_t[3] = swap32 (w2[3]);
398 w3_t[0] = swap32 (w3[0]);
399 w3_t[1] = swap32 (w3[1]);
401 w3_t[3] = pw_len * 8;
405 digest[0] = SHA384M_A;
406 digest[1] = SHA384M_B;
407 digest[2] = SHA384M_C;
408 digest[3] = SHA384M_D;
409 digest[4] = SHA384M_E;
410 digest[5] = SHA384M_F;
411 digest[6] = SHA384M_G;
412 digest[7] = SHA384M_H;
414 sha384_transform (w0_t, w1_t, w2_t, w3_t, digest);
416 const u32 r0 = l32_from_64 (digest[3]);
417 const u32 r1 = h32_from_64 (digest[3]);
418 const u32 r2 = l32_from_64 (digest[2]);
419 const u32 r3 = h32_from_64 (digest[2]);
425 __kernel void m10800_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
429 __kernel void m10800_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)