2 * Author......: Jens Steube <jens.steube@gmail.com>
10 #include "inc_vendor.cl"
11 #include "inc_hash_constants.h"
12 #include "inc_hash_functions.cl"
13 #include "inc_types.cl"
14 #include "inc_common.cl"
15 #include "inc_simd.cl"
17 __constant u64 k_sha384[80] =
19 SHA384C00, SHA384C01, SHA384C02, SHA384C03,
20 SHA384C04, SHA384C05, SHA384C06, SHA384C07,
21 SHA384C08, SHA384C09, SHA384C0a, SHA384C0b,
22 SHA384C0c, SHA384C0d, SHA384C0e, SHA384C0f,
23 SHA384C10, SHA384C11, SHA384C12, SHA384C13,
24 SHA384C14, SHA384C15, SHA384C16, SHA384C17,
25 SHA384C18, SHA384C19, SHA384C1a, SHA384C1b,
26 SHA384C1c, SHA384C1d, SHA384C1e, SHA384C1f,
27 SHA384C20, SHA384C21, SHA384C22, SHA384C23,
28 SHA384C24, SHA384C25, SHA384C26, SHA384C27,
29 SHA384C28, SHA384C29, SHA384C2a, SHA384C2b,
30 SHA384C2c, SHA384C2d, SHA384C2e, SHA384C2f,
31 SHA384C30, SHA384C31, SHA384C32, SHA384C33,
32 SHA384C34, SHA384C35, SHA384C36, SHA384C37,
33 SHA384C38, SHA384C39, SHA384C3a, SHA384C3b,
34 SHA384C3c, SHA384C3d, SHA384C3e, SHA384C3f,
35 SHA384C40, SHA384C41, SHA384C42, SHA384C43,
36 SHA384C44, SHA384C45, SHA384C46, SHA384C47,
37 SHA384C48, SHA384C49, SHA384C4a, SHA384C4b,
38 SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f,
41 void sha384_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u64x digest[8])
43 u64x w0_t = hl32_to_64 (w0[0], w0[1]);
44 u64x w1_t = hl32_to_64 (w0[2], w0[3]);
45 u64x w2_t = hl32_to_64 (w1[0], w1[1]);
46 u64x w3_t = hl32_to_64 (w1[2], w1[3]);
47 u64x w4_t = hl32_to_64 (w2[0], w2[1]);
48 u64x w5_t = hl32_to_64 (w2[2], w2[3]);
49 u64x w6_t = hl32_to_64 (w3[0], w3[1]);
58 u64x wf_t = hl32_to_64 (w3[2], w3[3]);
69 #define ROUND_EXPAND() \
71 w0_t = SHA384_EXPAND (we_t, w9_t, w1_t, w0_t); \
72 w1_t = SHA384_EXPAND (wf_t, wa_t, w2_t, w1_t); \
73 w2_t = SHA384_EXPAND (w0_t, wb_t, w3_t, w2_t); \
74 w3_t = SHA384_EXPAND (w1_t, wc_t, w4_t, w3_t); \
75 w4_t = SHA384_EXPAND (w2_t, wd_t, w5_t, w4_t); \
76 w5_t = SHA384_EXPAND (w3_t, we_t, w6_t, w5_t); \
77 w6_t = SHA384_EXPAND (w4_t, wf_t, w7_t, w6_t); \
78 w7_t = SHA384_EXPAND (w5_t, w0_t, w8_t, w7_t); \
79 w8_t = SHA384_EXPAND (w6_t, w1_t, w9_t, w8_t); \
80 w9_t = SHA384_EXPAND (w7_t, w2_t, wa_t, w9_t); \
81 wa_t = SHA384_EXPAND (w8_t, w3_t, wb_t, wa_t); \
82 wb_t = SHA384_EXPAND (w9_t, w4_t, wc_t, wb_t); \
83 wc_t = SHA384_EXPAND (wa_t, w5_t, wd_t, wc_t); \
84 wd_t = SHA384_EXPAND (wb_t, w6_t, we_t, wd_t); \
85 we_t = SHA384_EXPAND (wc_t, w7_t, wf_t, we_t); \
86 wf_t = SHA384_EXPAND (wd_t, w8_t, w0_t, wf_t); \
89 #define ROUND_STEP(i) \
91 SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha384[i + 0]); \
92 SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha384[i + 1]); \
93 SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha384[i + 2]); \
94 SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha384[i + 3]); \
95 SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha384[i + 4]); \
96 SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha384[i + 5]); \
97 SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha384[i + 6]); \
98 SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha384[i + 7]); \
99 SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha384[i + 8]); \
100 SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha384[i + 9]); \
101 SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha384[i + 10]); \
102 SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha384[i + 11]); \
103 SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha384[i + 12]); \
104 SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha384[i + 13]); \
105 SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, we_t, k_sha384[i + 14]); \
106 SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha384[i + 15]); \
114 for (int i = 16; i < 80; i += 16)
116 ROUND_EXPAND (); ROUND_STEP (i);
140 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
146 const u32 lid = get_local_id (0);
152 const u32 gid = get_global_id (0);
154 if (gid >= gid_max) return;
159 pw_buf0[0] = pws[gid].i[0];
160 pw_buf0[1] = pws[gid].i[1];
161 pw_buf0[2] = pws[gid].i[2];
162 pw_buf0[3] = pws[gid].i[3];
163 pw_buf1[0] = pws[gid].i[4];
164 pw_buf1[1] = pws[gid].i[5];
165 pw_buf1[2] = pws[gid].i[6];
166 pw_buf1[3] = pws[gid].i[7];
168 const u32 pw_l_len = pws[gid].pw_len;
174 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
176 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
178 const u32x pw_len = pw_l_len + pw_r_len;
181 * concat password candidate
184 u32x wordl0[4] = { 0 };
185 u32x wordl1[4] = { 0 };
186 u32x wordl2[4] = { 0 };
187 u32x wordl3[4] = { 0 };
189 wordl0[0] = pw_buf0[0];
190 wordl0[1] = pw_buf0[1];
191 wordl0[2] = pw_buf0[2];
192 wordl0[3] = pw_buf0[3];
193 wordl1[0] = pw_buf1[0];
194 wordl1[1] = pw_buf1[1];
195 wordl1[2] = pw_buf1[2];
196 wordl1[3] = pw_buf1[3];
198 u32x wordr0[4] = { 0 };
199 u32x wordr1[4] = { 0 };
200 u32x wordr2[4] = { 0 };
201 u32x wordr3[4] = { 0 };
203 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
204 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
205 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
206 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
207 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
208 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
209 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
210 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
212 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
214 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
218 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
226 w0[0] = wordl0[0] | wordr0[0];
227 w0[1] = wordl0[1] | wordr0[1];
228 w0[2] = wordl0[2] | wordr0[2];
229 w0[3] = wordl0[3] | wordr0[3];
230 w1[0] = wordl1[0] | wordr1[0];
231 w1[1] = wordl1[1] | wordr1[1];
232 w1[2] = wordl1[2] | wordr1[2];
233 w1[3] = wordl1[3] | wordr1[3];
234 w2[0] = wordl2[0] | wordr2[0];
235 w2[1] = wordl2[1] | wordr2[1];
236 w2[2] = wordl2[2] | wordr2[2];
237 w2[3] = wordl2[3] | wordr2[3];
238 w3[0] = wordl3[0] | wordr3[0];
239 w3[1] = wordl3[1] | wordr3[1];
240 w3[2] = wordl3[2] | wordr3[2];
241 w3[3] = wordl3[3] | wordr3[3];
252 w0_t[0] = swap32 (w0[0]);
253 w0_t[1] = swap32 (w0[1]);
254 w0_t[2] = swap32 (w0[2]);
255 w0_t[3] = swap32 (w0[3]);
256 w1_t[0] = swap32 (w1[0]);
257 w1_t[1] = swap32 (w1[1]);
258 w1_t[2] = swap32 (w1[2]);
259 w1_t[3] = swap32 (w1[3]);
260 w2_t[0] = swap32 (w2[0]);
261 w2_t[1] = swap32 (w2[1]);
262 w2_t[2] = swap32 (w2[2]);
263 w2_t[3] = swap32 (w2[3]);
264 w3_t[0] = swap32 (w3[0]);
265 w3_t[1] = swap32 (w3[1]);
267 w3_t[3] = pw_len * 8;
271 digest[0] = SHA384M_A;
272 digest[1] = SHA384M_B;
273 digest[2] = SHA384M_C;
274 digest[3] = SHA384M_D;
275 digest[4] = SHA384M_E;
276 digest[5] = SHA384M_F;
277 digest[6] = SHA384M_G;
278 digest[7] = SHA384M_H;
280 sha384_transform (w0_t, w1_t, w2_t, w3_t, digest);
282 const u32x r0 = l32_from_64 (digest[3]);
283 const u32x r1 = h32_from_64 (digest[3]);
284 const u32x r2 = l32_from_64 (digest[2]);
285 const u32x r3 = h32_from_64 (digest[2]);
287 COMPARE_M_SIMD (r0, r1, r2, r3);
291 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
295 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
299 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
305 const u32 lid = get_local_id (0);
311 const u32 gid = get_global_id (0);
313 if (gid >= gid_max) return;
318 pw_buf0[0] = pws[gid].i[0];
319 pw_buf0[1] = pws[gid].i[1];
320 pw_buf0[2] = pws[gid].i[2];
321 pw_buf0[3] = pws[gid].i[3];
322 pw_buf1[0] = pws[gid].i[4];
323 pw_buf1[1] = pws[gid].i[5];
324 pw_buf1[2] = pws[gid].i[6];
325 pw_buf1[3] = pws[gid].i[7];
327 const u32 pw_l_len = pws[gid].pw_len;
333 const u32 search[4] =
335 digests_buf[digests_offset].digest_buf[DGST_R0],
336 digests_buf[digests_offset].digest_buf[DGST_R1],
337 digests_buf[digests_offset].digest_buf[DGST_R2],
338 digests_buf[digests_offset].digest_buf[DGST_R3]
345 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
347 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
349 const u32x pw_len = pw_l_len + pw_r_len;
352 * concat password candidate
355 u32x wordl0[4] = { 0 };
356 u32x wordl1[4] = { 0 };
357 u32x wordl2[4] = { 0 };
358 u32x wordl3[4] = { 0 };
360 wordl0[0] = pw_buf0[0];
361 wordl0[1] = pw_buf0[1];
362 wordl0[2] = pw_buf0[2];
363 wordl0[3] = pw_buf0[3];
364 wordl1[0] = pw_buf1[0];
365 wordl1[1] = pw_buf1[1];
366 wordl1[2] = pw_buf1[2];
367 wordl1[3] = pw_buf1[3];
369 u32x wordr0[4] = { 0 };
370 u32x wordr1[4] = { 0 };
371 u32x wordr2[4] = { 0 };
372 u32x wordr3[4] = { 0 };
374 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
375 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
376 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
377 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
378 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
379 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
380 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
381 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
383 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
385 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
389 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
397 w0[0] = wordl0[0] | wordr0[0];
398 w0[1] = wordl0[1] | wordr0[1];
399 w0[2] = wordl0[2] | wordr0[2];
400 w0[3] = wordl0[3] | wordr0[3];
401 w1[0] = wordl1[0] | wordr1[0];
402 w1[1] = wordl1[1] | wordr1[1];
403 w1[2] = wordl1[2] | wordr1[2];
404 w1[3] = wordl1[3] | wordr1[3];
405 w2[0] = wordl2[0] | wordr2[0];
406 w2[1] = wordl2[1] | wordr2[1];
407 w2[2] = wordl2[2] | wordr2[2];
408 w2[3] = wordl2[3] | wordr2[3];
409 w3[0] = wordl3[0] | wordr3[0];
410 w3[1] = wordl3[1] | wordr3[1];
411 w3[2] = wordl3[2] | wordr3[2];
412 w3[3] = wordl3[3] | wordr3[3];
423 w0_t[0] = swap32 (w0[0]);
424 w0_t[1] = swap32 (w0[1]);
425 w0_t[2] = swap32 (w0[2]);
426 w0_t[3] = swap32 (w0[3]);
427 w1_t[0] = swap32 (w1[0]);
428 w1_t[1] = swap32 (w1[1]);
429 w1_t[2] = swap32 (w1[2]);
430 w1_t[3] = swap32 (w1[3]);
431 w2_t[0] = swap32 (w2[0]);
432 w2_t[1] = swap32 (w2[1]);
433 w2_t[2] = swap32 (w2[2]);
434 w2_t[3] = swap32 (w2[3]);
435 w3_t[0] = swap32 (w3[0]);
436 w3_t[1] = swap32 (w3[1]);
438 w3_t[3] = pw_len * 8;
442 digest[0] = SHA384M_A;
443 digest[1] = SHA384M_B;
444 digest[2] = SHA384M_C;
445 digest[3] = SHA384M_D;
446 digest[4] = SHA384M_E;
447 digest[5] = SHA384M_F;
448 digest[6] = SHA384M_G;
449 digest[7] = SHA384M_H;
451 sha384_transform (w0_t, w1_t, w2_t, w3_t, digest);
453 const u32x r0 = l32_from_64 (digest[3]);
454 const u32x r1 = h32_from_64 (digest[3]);
455 const u32x r2 = l32_from_64 (digest[2]);
456 const u32x r3 = h32_from_64 (digest[2]);
458 COMPARE_S_SIMD (r0, r1, r2, r3);
462 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
466 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)