2 * Authors.....: Jens Steube <jens.steube@gmail.com>
3 * Gabriele Gristina <matrix@hashcat.net>
12 #include "include/constants.h"
13 #include "include/kernel_vendor.h"
20 #include "include/kernel_functions.c"
21 #include "OpenCL/types_ocl.c"
22 #include "OpenCL/common.c"
23 #include "OpenCL/simd.c"
25 __constant u32 k_sha256[64] =
27 SHA256C00, SHA256C01, SHA256C02, SHA256C03,
28 SHA256C04, SHA256C05, SHA256C06, SHA256C07,
29 SHA256C08, SHA256C09, SHA256C0a, SHA256C0b,
30 SHA256C0c, SHA256C0d, SHA256C0e, SHA256C0f,
31 SHA256C10, SHA256C11, SHA256C12, SHA256C13,
32 SHA256C14, SHA256C15, SHA256C16, SHA256C17,
33 SHA256C18, SHA256C19, SHA256C1a, SHA256C1b,
34 SHA256C1c, SHA256C1d, SHA256C1e, SHA256C1f,
35 SHA256C20, SHA256C21, SHA256C22, SHA256C23,
36 SHA256C24, SHA256C25, SHA256C26, SHA256C27,
37 SHA256C28, SHA256C29, SHA256C2a, SHA256C2b,
38 SHA256C2c, SHA256C2d, SHA256C2e, SHA256C2f,
39 SHA256C30, SHA256C31, SHA256C32, SHA256C33,
40 SHA256C34, SHA256C35, SHA256C36, SHA256C37,
41 SHA256C38, SHA256C39, SHA256C3a, SHA256C3b,
42 SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f,
45 #define SHA256_S0_S(x) (rotl32_S ((x), 25u) ^ rotl32_S ((x), 14u) ^ SHIFT_RIGHT_32 ((x), 3u))
46 #define SHA256_S1_S(x) (rotl32_S ((x), 15u) ^ rotl32_S ((x), 13u) ^ SHIFT_RIGHT_32 ((x), 10u))
48 #define SHA256_EXPAND_S(x,y,z,w) (SHA256_S1_S (x) + y + SHA256_S0_S (z) + w)
50 static void sha256_transform (u32x digest[8], const u32x w[16])
78 #define ROUND_EXPAND() \
80 w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); \
81 w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); \
82 w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); \
83 w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); \
84 w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); \
85 w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); \
86 w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); \
87 w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); \
88 w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); \
89 w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); \
90 wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); \
91 wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); \
92 wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); \
93 wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); \
94 we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); \
95 wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); \
98 #define ROUND_STEP(i) \
100 SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha256[i + 0]); \
101 SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha256[i + 1]); \
102 SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha256[i + 2]); \
103 SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha256[i + 3]); \
104 SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha256[i + 4]); \
105 SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha256[i + 5]); \
106 SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha256[i + 6]); \
107 SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha256[i + 7]); \
108 SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha256[i + 8]); \
109 SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha256[i + 9]); \
110 SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha256[i + 10]); \
111 SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha256[i + 11]); \
112 SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha256[i + 12]); \
113 SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha256[i + 13]); \
114 SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, k_sha256[i + 14]); \
115 SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha256[i + 15]); \
121 for (int i = 16; i < 64; i += 16)
123 ROUND_EXPAND (); ROUND_STEP (i);
136 static void sha256_transform_z (u32x digest[8])
147 #define ROUND_STEP_Z(i) \
149 SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, 0, k_sha256[i + 0]); \
150 SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, 0, k_sha256[i + 1]); \
151 SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, 0, k_sha256[i + 2]); \
152 SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, 0, k_sha256[i + 3]); \
153 SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, 0, k_sha256[i + 4]); \
154 SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, 0, k_sha256[i + 5]); \
155 SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, 0, k_sha256[i + 6]); \
156 SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, 0, k_sha256[i + 7]); \
157 SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, 0, k_sha256[i + 8]); \
158 SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, 0, k_sha256[i + 9]); \
159 SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, 0, k_sha256[i + 10]); \
160 SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, 0, k_sha256[i + 11]); \
161 SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, 0, k_sha256[i + 12]); \
162 SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, 0, k_sha256[i + 13]); \
163 SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, 0, k_sha256[i + 14]); \
164 SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, 0, k_sha256[i + 15]); \
170 for (int i = 16; i < 64; i += 16)
185 static void sha256_transform_s (u32x digest[8], __local u32 *w)
196 #define ROUND_STEP_S(i) \
198 SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w[i + 0], k_sha256[i + 0]); \
199 SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w[i + 1], k_sha256[i + 1]); \
200 SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w[i + 2], k_sha256[i + 2]); \
201 SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w[i + 3], k_sha256[i + 3]); \
202 SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w[i + 4], k_sha256[i + 4]); \
203 SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w[i + 5], k_sha256[i + 5]); \
204 SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w[i + 6], k_sha256[i + 6]); \
205 SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w[i + 7], k_sha256[i + 7]); \
206 SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w[i + 8], k_sha256[i + 8]); \
207 SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w[i + 9], k_sha256[i + 9]); \
208 SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w[i + 10], k_sha256[i + 10]); \
209 SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w[i + 11], k_sha256[i + 11]); \
210 SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w[i + 12], k_sha256[i + 12]); \
211 SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w[i + 13], k_sha256[i + 13]); \
212 SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w[i + 14], k_sha256[i + 14]); \
213 SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w[i + 15], k_sha256[i + 15]); \
219 for (int i = 16; i < 64; i += 16)
234 __kernel void m08000_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)
240 const u32 gid = get_global_id (0);
241 const u32 lid = get_local_id (0);
242 const u32 lsz = get_local_size (0);
248 const u32 salt_buf0 = swap32_S (salt_bufs[salt_pos].salt_buf[ 0]);
249 const u32 salt_buf1 = swap32_S (salt_bufs[salt_pos].salt_buf[ 1]);
250 const u32 salt_buf2 = swap32_S (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
253 * precompute final msg blocks
256 __local u32 w_s1[64];
257 __local u32 w_s2[64];
259 for (u32 i = lid; i < 64; i += lsz)
265 barrier (CLK_LOCAL_MEM_FENCE);
269 w_s1[15] = 0 | salt_buf0 >> 16;
272 for (int i = 16; i < 64; i++)
274 w_s1[i] = SHA256_EXPAND_S (w_s1[i - 2], w_s1[i - 7], w_s1[i - 15], w_s1[i - 16]);
277 w_s2[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
278 w_s2[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
279 w_s2[ 2] = salt_buf2 << 16 | 0;
280 w_s2[15] = (510 + 8) * 8;
283 for (int i = 16; i < 64; i++)
285 w_s2[i] = SHA256_EXPAND_S (w_s2[i - 2], w_s2[i - 7], w_s2[i - 15], w_s2[i - 16]);
289 barrier (CLK_LOCAL_MEM_FENCE);
291 if (gid >= gid_max) return;
300 pw_buf0[0] = pws[gid].i[0];
301 pw_buf0[1] = pws[gid].i[1];
302 pw_buf0[2] = pws[gid].i[2];
303 pw_buf0[3] = pws[gid].i[3];
304 pw_buf1[0] = pws[gid].i[4];
305 pw_buf1[1] = pws[gid].i[5];
306 pw_buf1[2] = pws[gid].i[6];
307 pw_buf1[3] = pws[gid].i[7];
309 const u32 pw_l_len = pws[gid].pw_len;
315 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
317 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
319 const u32x pw_len = pw_l_len + pw_r_len;
322 * concat password candidate
325 u32x wordl0[4] = { 0 };
326 u32x wordl1[4] = { 0 };
327 u32x wordl2[4] = { 0 };
328 u32x wordl3[4] = { 0 };
330 wordl0[0] = pw_buf0[0];
331 wordl0[1] = pw_buf0[1];
332 wordl0[2] = pw_buf0[2];
333 wordl0[3] = pw_buf0[3];
334 wordl1[0] = pw_buf1[0];
335 wordl1[1] = pw_buf1[1];
336 wordl1[2] = pw_buf1[2];
337 wordl1[3] = pw_buf1[3];
339 u32x wordr0[4] = { 0 };
340 u32x wordr1[4] = { 0 };
341 u32x wordr2[4] = { 0 };
342 u32x wordr3[4] = { 0 };
344 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
345 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
346 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
347 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
348 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
349 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
350 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
351 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
353 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
355 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
359 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
365 w0[0] = wordl0[0] | wordr0[0];
366 w0[1] = wordl0[1] | wordr0[1];
367 w0[2] = wordl0[2] | wordr0[2];
368 w0[3] = wordl0[3] | wordr0[3];
369 w1[0] = wordl1[0] | wordr1[0];
370 w1[1] = wordl1[1] | wordr1[1];
371 w1[2] = wordl1[2] | wordr1[2];
372 w1[3] = wordl1[3] | wordr1[3];
383 make_unicode (w0, w0_t, w1_t);
384 make_unicode (w1, w2_t, w3_t);
388 w_t[ 0] = swap32 (w0_t[0]);
389 w_t[ 1] = swap32 (w0_t[1]);
390 w_t[ 2] = swap32 (w0_t[2]);
391 w_t[ 3] = swap32 (w0_t[3]);
392 w_t[ 4] = swap32 (w1_t[0]);
393 w_t[ 5] = swap32 (w1_t[1]);
394 w_t[ 6] = swap32 (w1_t[2]);
395 w_t[ 7] = swap32 (w1_t[3]);
396 w_t[ 8] = swap32 (w2_t[0]);
397 w_t[ 9] = swap32 (w2_t[1]);
398 w_t[10] = swap32 (w2_t[2]);
399 w_t[11] = swap32 (w2_t[3]);
400 w_t[12] = swap32 (w3_t[0]);
401 w_t[13] = swap32 (w3_t[1]);
402 w_t[14] = swap32 (w3_t[2]);
403 w_t[15] = swap32 (w3_t[3]);
405 w_t[ 0] = w_t[ 0] >> 8;
406 w_t[ 1] = w_t[ 1] >> 8;
407 w_t[ 2] = w_t[ 2] >> 8;
408 w_t[ 3] = w_t[ 3] >> 8;
409 w_t[ 4] = w_t[ 4] >> 8;
410 w_t[ 5] = w_t[ 5] >> 8;
411 w_t[ 6] = w_t[ 6] >> 8;
412 w_t[ 7] = w_t[ 7] >> 8;
413 w_t[ 8] = w_t[ 8] >> 8;
414 w_t[ 9] = w_t[ 9] >> 8;
415 w_t[10] = w_t[10] >> 8;
416 w_t[11] = w_t[11] >> 8;
417 w_t[12] = w_t[12] >> 8;
418 w_t[13] = w_t[13] >> 8;
419 w_t[14] = w_t[14] >> 8;
420 w_t[15] = w_t[15] >> 8;
424 digest[0] = SHA256M_A;
425 digest[1] = SHA256M_B;
426 digest[2] = SHA256M_C;
427 digest[3] = SHA256M_D;
428 digest[4] = SHA256M_E;
429 digest[5] = SHA256M_F;
430 digest[6] = SHA256M_G;
431 digest[7] = SHA256M_H;
433 sha256_transform (digest, w_t); // 0 - 64
434 sha256_transform_z (digest); // 64 - 128
435 sha256_transform_z (digest); // 128 - 192
436 sha256_transform_z (digest); // 192 - 256
437 sha256_transform_z (digest); // 256 - 320
438 sha256_transform_z (digest); // 320 - 384
439 sha256_transform_z (digest); // 384 - 448
440 sha256_transform_s (digest, w_s1); // 448 - 512
441 sha256_transform_s (digest, w_s2); // 512 - 576
443 COMPARE_M_SIMD (digest[3], digest[7], digest[2], digest[6]);
447 __kernel void m08000_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)
451 __kernel void m08000_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)
455 __kernel void m08000_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)
461 const u32 gid = get_global_id (0);
462 const u32 lid = get_local_id (0);
463 const u32 lsz = get_local_size (0);
469 const u32 salt_buf0 = swap32_S (salt_bufs[salt_pos].salt_buf[ 0]);
470 const u32 salt_buf1 = swap32_S (salt_bufs[salt_pos].salt_buf[ 1]);
471 const u32 salt_buf2 = swap32_S (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
474 * precompute final msg blocks
477 __local u32 w_s1[64];
478 __local u32 w_s2[64];
480 for (u32 i = lid; i < 64; i += lsz)
486 barrier (CLK_LOCAL_MEM_FENCE);
490 w_s1[15] = 0 | salt_buf0 >> 16;
493 for (int i = 16; i < 64; i++)
495 w_s1[i] = SHA256_EXPAND_S (w_s1[i - 2], w_s1[i - 7], w_s1[i - 15], w_s1[i - 16]);
498 w_s2[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
499 w_s2[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
500 w_s2[ 2] = salt_buf2 << 16 | 0;
501 w_s2[15] = (510 + 8) * 8;
504 for (int i = 16; i < 64; i++)
506 w_s2[i] = SHA256_EXPAND_S (w_s2[i - 2], w_s2[i - 7], w_s2[i - 15], w_s2[i - 16]);
510 barrier (CLK_LOCAL_MEM_FENCE);
512 if (gid >= gid_max) return;
521 pw_buf0[0] = pws[gid].i[0];
522 pw_buf0[1] = pws[gid].i[1];
523 pw_buf0[2] = pws[gid].i[2];
524 pw_buf0[3] = pws[gid].i[3];
525 pw_buf1[0] = pws[gid].i[4];
526 pw_buf1[1] = pws[gid].i[5];
527 pw_buf1[2] = pws[gid].i[6];
528 pw_buf1[3] = pws[gid].i[7];
530 const u32 pw_l_len = pws[gid].pw_len;
536 const u32 search[4] =
538 digests_buf[digests_offset].digest_buf[DGST_R0],
539 digests_buf[digests_offset].digest_buf[DGST_R1],
540 digests_buf[digests_offset].digest_buf[DGST_R2],
541 digests_buf[digests_offset].digest_buf[DGST_R3]
548 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
550 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
552 const u32x pw_len = pw_l_len + pw_r_len;
555 * concat password candidate
558 u32x wordl0[4] = { 0 };
559 u32x wordl1[4] = { 0 };
560 u32x wordl2[4] = { 0 };
561 u32x wordl3[4] = { 0 };
563 wordl0[0] = pw_buf0[0];
564 wordl0[1] = pw_buf0[1];
565 wordl0[2] = pw_buf0[2];
566 wordl0[3] = pw_buf0[3];
567 wordl1[0] = pw_buf1[0];
568 wordl1[1] = pw_buf1[1];
569 wordl1[2] = pw_buf1[2];
570 wordl1[3] = pw_buf1[3];
572 u32x wordr0[4] = { 0 };
573 u32x wordr1[4] = { 0 };
574 u32x wordr2[4] = { 0 };
575 u32x wordr3[4] = { 0 };
577 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
578 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
579 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
580 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
581 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
582 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
583 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
584 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
586 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
588 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
592 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
598 w0[0] = wordl0[0] | wordr0[0];
599 w0[1] = wordl0[1] | wordr0[1];
600 w0[2] = wordl0[2] | wordr0[2];
601 w0[3] = wordl0[3] | wordr0[3];
602 w1[0] = wordl1[0] | wordr1[0];
603 w1[1] = wordl1[1] | wordr1[1];
604 w1[2] = wordl1[2] | wordr1[2];
605 w1[3] = wordl1[3] | wordr1[3];
616 make_unicode (w0, w0_t, w1_t);
617 make_unicode (w1, w2_t, w3_t);
621 w_t[ 0] = swap32 (w0_t[0]);
622 w_t[ 1] = swap32 (w0_t[1]);
623 w_t[ 2] = swap32 (w0_t[2]);
624 w_t[ 3] = swap32 (w0_t[3]);
625 w_t[ 4] = swap32 (w1_t[0]);
626 w_t[ 5] = swap32 (w1_t[1]);
627 w_t[ 6] = swap32 (w1_t[2]);
628 w_t[ 7] = swap32 (w1_t[3]);
629 w_t[ 8] = swap32 (w2_t[0]);
630 w_t[ 9] = swap32 (w2_t[1]);
631 w_t[10] = swap32 (w2_t[2]);
632 w_t[11] = swap32 (w2_t[3]);
633 w_t[12] = swap32 (w3_t[0]);
634 w_t[13] = swap32 (w3_t[1]);
635 w_t[14] = swap32 (w3_t[2]);
636 w_t[15] = swap32 (w3_t[3]);
638 w_t[ 0] = w_t[ 0] >> 8;
639 w_t[ 1] = w_t[ 1] >> 8;
640 w_t[ 2] = w_t[ 2] >> 8;
641 w_t[ 3] = w_t[ 3] >> 8;
642 w_t[ 4] = w_t[ 4] >> 8;
643 w_t[ 5] = w_t[ 5] >> 8;
644 w_t[ 6] = w_t[ 6] >> 8;
645 w_t[ 7] = w_t[ 7] >> 8;
646 w_t[ 8] = w_t[ 8] >> 8;
647 w_t[ 9] = w_t[ 9] >> 8;
648 w_t[10] = w_t[10] >> 8;
649 w_t[11] = w_t[11] >> 8;
650 w_t[12] = w_t[12] >> 8;
651 w_t[13] = w_t[13] >> 8;
652 w_t[14] = w_t[14] >> 8;
653 w_t[15] = w_t[15] >> 8;
657 digest[0] = SHA256M_A;
658 digest[1] = SHA256M_B;
659 digest[2] = SHA256M_C;
660 digest[3] = SHA256M_D;
661 digest[4] = SHA256M_E;
662 digest[5] = SHA256M_F;
663 digest[6] = SHA256M_G;
664 digest[7] = SHA256M_H;
666 sha256_transform (digest, w_t); // 0 - 64
667 sha256_transform_z (digest); // 64 - 128
668 sha256_transform_z (digest); // 128 - 192
669 sha256_transform_z (digest); // 192 - 256
670 sha256_transform_z (digest); // 256 - 320
671 sha256_transform_z (digest); // 320 - 384
672 sha256_transform_z (digest); // 384 - 448
673 sha256_transform_s (digest, w_s1); // 448 - 512
674 sha256_transform_s (digest, w_s2); // 512 - 576
676 COMPARE_S_SIMD (digest[3], digest[7], digest[2], digest[6]);
680 __kernel void m08000_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)
684 __kernel void m08000_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)