Added hash-mode 10840 - sha384(salt.utf16le(pass))

pull/2655/head
Gabriele Gristina 3 years ago
parent 15bf8b7302
commit c6f98ec4da

@ -0,0 +1,453 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_rp_optimized.h"
#include "inc_rp_optimized.cl"
#include "inc_simd.cl"
#include "inc_hash_sha384.cl"
#endif
DECLSPEC void sha384_transform_intern (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u64x *digest)
{
u64x w0_t = hl32_to_64 (w0[0], w0[1]);
u64x w1_t = hl32_to_64 (w0[2], w0[3]);
u64x w2_t = hl32_to_64 (w1[0], w1[1]);
u64x w3_t = hl32_to_64 (w1[2], w1[3]);
u64x w4_t = hl32_to_64 (w2[0], w2[1]);
u64x w5_t = hl32_to_64 (w2[2], w2[3]);
u64x w6_t = hl32_to_64 (w3[0], w3[1]);
u64x w7_t = 0;
u64x w8_t = 0;
u64x w9_t = 0;
u64x wa_t = 0;
u64x wb_t = 0;
u64x wc_t = 0;
u64x wd_t = 0;
u64x we_t = 0;
u64x wf_t = hl32_to_64 (w3[2], w3[3]);
u64x a = digest[0];
u64x b = digest[1];
u64x c = digest[2];
u64x d = digest[3];
u64x e = digest[4];
u64x f = digest[5];
u64x g = digest[6];
u64x h = digest[7];
#define ROUND_EXPAND() \
{ \
w0_t = SHA384_EXPAND (we_t, w9_t, w1_t, w0_t); \
w1_t = SHA384_EXPAND (wf_t, wa_t, w2_t, w1_t); \
w2_t = SHA384_EXPAND (w0_t, wb_t, w3_t, w2_t); \
w3_t = SHA384_EXPAND (w1_t, wc_t, w4_t, w3_t); \
w4_t = SHA384_EXPAND (w2_t, wd_t, w5_t, w4_t); \
w5_t = SHA384_EXPAND (w3_t, we_t, w6_t, w5_t); \
w6_t = SHA384_EXPAND (w4_t, wf_t, w7_t, w6_t); \
w7_t = SHA384_EXPAND (w5_t, w0_t, w8_t, w7_t); \
w8_t = SHA384_EXPAND (w6_t, w1_t, w9_t, w8_t); \
w9_t = SHA384_EXPAND (w7_t, w2_t, wa_t, w9_t); \
wa_t = SHA384_EXPAND (w8_t, w3_t, wb_t, wa_t); \
wb_t = SHA384_EXPAND (w9_t, w4_t, wc_t, wb_t); \
wc_t = SHA384_EXPAND (wa_t, w5_t, wd_t, wc_t); \
wd_t = SHA384_EXPAND (wb_t, w6_t, we_t, wd_t); \
we_t = SHA384_EXPAND (wc_t, w7_t, wf_t, we_t); \
wf_t = SHA384_EXPAND (wd_t, w8_t, w0_t, wf_t); \
}
#define ROUND_STEP(i) \
{ \
SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha384[i + 0]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha384[i + 1]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha384[i + 2]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha384[i + 3]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha384[i + 4]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha384[i + 5]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha384[i + 6]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha384[i + 7]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha384[i + 8]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha384[i + 9]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha384[i + 10]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha384[i + 11]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha384[i + 12]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha384[i + 13]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, we_t, k_sha384[i + 14]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha384[i + 15]); \
}
ROUND_STEP (0);
#ifdef IS_CUDA
ROUND_EXPAND (); ROUND_STEP (16);
ROUND_EXPAND (); ROUND_STEP (32);
ROUND_EXPAND (); ROUND_STEP (48);
ROUND_EXPAND (); ROUND_STEP (64);
#else
#ifdef _unroll
#pragma unroll
#endif
for (int i = 16; i < 80; i += 16)
{
ROUND_EXPAND (); ROUND_STEP (i);
}
#endif
/* rev
digest[0] += a;
digest[1] += b;
digest[2] += c;
digest[3] += d;
digest[4] += e;
digest[5] += f;
digest[6] += g;
digest[7] += h;
*/
digest[0] = a;
digest[1] = b;
digest[2] = c;
digest[3] = d;
digest[4] = e;
digest[5] = f;
digest[6] = 0;
digest[7] = 0;
}
KERNEL_FQ void m10840_m04 (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 pw_buf0[4];
u32 pw_buf1[4];
pw_buf0[0] = pws[gid].i[0];
pw_buf0[1] = pws[gid].i[1];
pw_buf0[2] = pws[gid].i[2];
pw_buf0[3] = pws[gid].i[3];
pw_buf1[0] = pws[gid].i[4];
pw_buf1[1] = pws[gid].i[5];
pw_buf1[2] = pws[gid].i[6];
pw_buf1[3] = pws[gid].i[7];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* salt
*/
u32 salt_buf0[4];
u32 salt_buf1[4];
u32 salt_buf2[4];
u32 salt_buf3[4];
salt_buf0[0] = salt_bufs[SALT_POS].salt_buf[ 0];
salt_buf0[1] = salt_bufs[SALT_POS].salt_buf[ 1];
salt_buf0[2] = salt_bufs[SALT_POS].salt_buf[ 2];
salt_buf0[3] = salt_bufs[SALT_POS].salt_buf[ 3];
salt_buf1[0] = salt_bufs[SALT_POS].salt_buf[ 4];
salt_buf1[1] = salt_bufs[SALT_POS].salt_buf[ 5];
salt_buf1[2] = salt_bufs[SALT_POS].salt_buf[ 6];
salt_buf1[3] = salt_bufs[SALT_POS].salt_buf[ 7];
salt_buf2[0] = salt_bufs[SALT_POS].salt_buf[ 8];
salt_buf2[1] = salt_bufs[SALT_POS].salt_buf[ 9];
salt_buf2[2] = salt_bufs[SALT_POS].salt_buf[10];
salt_buf2[3] = salt_bufs[SALT_POS].salt_buf[11];
salt_buf3[0] = salt_bufs[SALT_POS].salt_buf[12];
salt_buf3[1] = salt_bufs[SALT_POS].salt_buf[13];
salt_buf3[2] = salt_bufs[SALT_POS].salt_buf[14];
salt_buf3[3] = salt_bufs[SALT_POS].salt_buf[15];
const u32 salt_len = salt_bufs[SALT_POS].salt_len;
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
u32x w0[4] = { 0 };
u32x w1[4] = { 0 };
u32x w2[4] = { 0 };
u32x w3[4] = { 0 };
const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
make_utf16le (w1, w2, w3);
make_utf16le (w0, w0, w1);
const u32x out_len2 = out_len * 2;
/**
* prepend salt
*/
const u32x out_salt_len = out_len2 + salt_len;
switch_buffer_by_offset_le_VV (w0, w1, w2, w3, salt_len);
w0[0] |= salt_buf0[0];
w0[1] |= salt_buf0[1];
w0[2] |= salt_buf0[2];
w0[3] |= salt_buf0[3];
w1[0] |= salt_buf1[0];
w1[1] |= salt_buf1[1];
w1[2] |= salt_buf1[2];
w1[3] |= salt_buf1[3];
w2[0] |= salt_buf2[0];
w2[1] |= salt_buf2[1];
w2[2] |= salt_buf2[2];
w2[3] |= salt_buf2[3];
w3[0] |= salt_buf3[0];
w3[1] |= salt_buf3[1];
w3[2] |= salt_buf3[2];
w3[3] |= salt_buf3[3];
append_0x80_4x4_VV (w0, w1, w2, w3, out_salt_len);
/**
* sha512
*/
u32x w0_t[4];
u32x w1_t[4];
u32x w2_t[4];
u32x w3_t[4];
w0_t[0] = hc_swap32 (w0[0]);
w0_t[1] = hc_swap32 (w0[1]);
w0_t[2] = hc_swap32 (w0[2]);
w0_t[3] = hc_swap32 (w0[3]);
w1_t[0] = hc_swap32 (w1[0]);
w1_t[1] = hc_swap32 (w1[1]);
w1_t[2] = hc_swap32 (w1[2]);
w1_t[3] = hc_swap32 (w1[3]);
w2_t[0] = hc_swap32 (w2[0]);
w2_t[1] = hc_swap32 (w2[1]);
w2_t[2] = hc_swap32 (w2[2]);
w2_t[3] = hc_swap32 (w2[3]);
w3_t[0] = hc_swap32 (w3[0]);
w3_t[1] = hc_swap32 (w3[1]);
w3_t[2] = 0;
w3_t[3] = out_salt_len * 8;
u64x digest[8];
digest[0] = SHA384M_A;
digest[1] = SHA384M_B;
digest[2] = SHA384M_C;
digest[3] = SHA384M_D;
digest[4] = SHA384M_E;
digest[5] = SHA384M_F;
digest[6] = SHA384M_G;
digest[7] = SHA384M_H;
sha384_transform_intern (w0_t, w1_t, w2_t, w3_t, digest);
const u32x r0 = l32_from_64 (digest[3]);
const u32x r1 = h32_from_64 (digest[3]);
const u32x r2 = l32_from_64 (digest[2]);
const u32x r3 = h32_from_64 (digest[2]);
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_m08 (KERN_ATTR_RULES ())
{
}
KERNEL_FQ void m10840_m16 (KERN_ATTR_RULES ())
{
}
KERNEL_FQ void m10840_s04 (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 pw_buf0[4];
u32 pw_buf1[4];
pw_buf0[0] = pws[gid].i[0];
pw_buf0[1] = pws[gid].i[1];
pw_buf0[2] = pws[gid].i[2];
pw_buf0[3] = pws[gid].i[3];
pw_buf1[0] = pws[gid].i[4];
pw_buf1[1] = pws[gid].i[5];
pw_buf1[2] = pws[gid].i[6];
pw_buf1[3] = pws[gid].i[7];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* salt
*/
u32 salt_buf0[4];
u32 salt_buf1[4];
u32 salt_buf2[4];
u32 salt_buf3[4];
salt_buf0[0] = salt_bufs[SALT_POS].salt_buf[ 0];
salt_buf0[1] = salt_bufs[SALT_POS].salt_buf[ 1];
salt_buf0[2] = salt_bufs[SALT_POS].salt_buf[ 2];
salt_buf0[3] = salt_bufs[SALT_POS].salt_buf[ 3];
salt_buf1[0] = salt_bufs[SALT_POS].salt_buf[ 4];
salt_buf1[1] = salt_bufs[SALT_POS].salt_buf[ 5];
salt_buf1[2] = salt_bufs[SALT_POS].salt_buf[ 6];
salt_buf1[3] = salt_bufs[SALT_POS].salt_buf[ 7];
salt_buf2[0] = salt_bufs[SALT_POS].salt_buf[ 8];
salt_buf2[1] = salt_bufs[SALT_POS].salt_buf[ 9];
salt_buf2[2] = salt_bufs[SALT_POS].salt_buf[10];
salt_buf2[3] = salt_bufs[SALT_POS].salt_buf[11];
salt_buf3[0] = salt_bufs[SALT_POS].salt_buf[12];
salt_buf3[1] = salt_bufs[SALT_POS].salt_buf[13];
salt_buf3[2] = salt_bufs[SALT_POS].salt_buf[14];
salt_buf3[3] = salt_bufs[SALT_POS].salt_buf[15];
const u32 salt_len = salt_bufs[SALT_POS].salt_len;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
u32x w0[4] = { 0 };
u32x w1[4] = { 0 };
u32x w2[4] = { 0 };
u32x w3[4] = { 0 };
const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
make_utf16le (w1, w2, w3);
make_utf16le (w0, w0, w1);
const u32x out_len2 = out_len * 2;
/**
* prepend salt
*/
const u32x out_salt_len = out_len2 + salt_len;
switch_buffer_by_offset_le_VV (w0, w1, w2, w3, salt_len);
w0[0] |= salt_buf0[0];
w0[1] |= salt_buf0[1];
w0[2] |= salt_buf0[2];
w0[3] |= salt_buf0[3];
w1[0] |= salt_buf1[0];
w1[1] |= salt_buf1[1];
w1[2] |= salt_buf1[2];
w1[3] |= salt_buf1[3];
w2[0] |= salt_buf2[0];
w2[1] |= salt_buf2[1];
w2[2] |= salt_buf2[2];
w2[3] |= salt_buf2[3];
w3[0] |= salt_buf3[0];
w3[1] |= salt_buf3[1];
w3[2] |= salt_buf3[2];
w3[3] |= salt_buf3[3];
append_0x80_4x4_VV (w0, w1, w2, w3, out_salt_len);
/**
* sha512
*/
u32x w0_t[4];
u32x w1_t[4];
u32x w2_t[4];
u32x w3_t[4];
w0_t[0] = hc_swap32 (w0[0]);
w0_t[1] = hc_swap32 (w0[1]);
w0_t[2] = hc_swap32 (w0[2]);
w0_t[3] = hc_swap32 (w0[3]);
w1_t[0] = hc_swap32 (w1[0]);
w1_t[1] = hc_swap32 (w1[1]);
w1_t[2] = hc_swap32 (w1[2]);
w1_t[3] = hc_swap32 (w1[3]);
w2_t[0] = hc_swap32 (w2[0]);
w2_t[1] = hc_swap32 (w2[1]);
w2_t[2] = hc_swap32 (w2[2]);
w2_t[3] = hc_swap32 (w2[3]);
w3_t[0] = hc_swap32 (w3[0]);
w3_t[1] = hc_swap32 (w3[1]);
w3_t[2] = 0;
w3_t[3] = out_salt_len * 8;
u64x digest[8];
digest[0] = SHA384M_A;
digest[1] = SHA384M_B;
digest[2] = SHA384M_C;
digest[3] = SHA384M_D;
digest[4] = SHA384M_E;
digest[5] = SHA384M_F;
digest[6] = SHA384M_G;
digest[7] = SHA384M_H;
sha384_transform_intern (w0_t, w1_t, w2_t, w3_t, digest);
const u32x r0 = l32_from_64 (digest[3]);
const u32x r1 = h32_from_64 (digest[3]);
const u32x r2 = l32_from_64 (digest[2]);
const u32x r3 = h32_from_64 (digest[2]);
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_s08 (KERN_ATTR_RULES ())
{
}
KERNEL_FQ void m10840_s16 (KERN_ATTR_RULES ())
{
}

@ -0,0 +1,125 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_rp.h"
#include "inc_rp.cl"
#include "inc_scalar.cl"
#include "inc_hash_sha384.cl"
#endif
KERNEL_FQ void m10840_mxx (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
/**
* base
*/
COPY_PW (pws[gid]);
sha384_ctx_t ctx0;
sha384_init (&ctx0);
sha384_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
pw_t tmp = PASTE_PW;
tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len);
sha384_ctx_t ctx = ctx0;
sha384_update_utf16le_swap (&ctx, tmp.i, tmp.pw_len);
sha384_final (&ctx);
const u32 r0 = l32_from_64_S (ctx.h[3]);
const u32 r1 = h32_from_64_S (ctx.h[3]);
const u32 r2 = l32_from_64_S (ctx.h[2]);
const u32 r3 = h32_from_64_S (ctx.h[2]);
COMPARE_M_SCALAR (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_sxx (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
* base
*/
COPY_PW (pws[gid]);
sha384_ctx_t ctx0;
sha384_init (&ctx0);
sha384_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
pw_t tmp = PASTE_PW;
tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len);
sha384_ctx_t ctx = ctx0;
sha384_update_utf16le_swap (&ctx, tmp.i, tmp.pw_len);
sha384_final (&ctx);
const u32 r0 = l32_from_64_S (ctx.h[3]);
const u32 r1 = h32_from_64_S (ctx.h[3]);
const u32 r2 = l32_from_64_S (ctx.h[2]);
const u32 r3 = h32_from_64_S (ctx.h[2]);
COMPARE_S_SCALAR (r0, r1, r2, r3);
}
}

@ -0,0 +1,567 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_simd.cl"
#include "inc_hash_sha384.cl"
#endif
DECLSPEC void sha384_transform_intern (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u64x *digest)
{
u64x w0_t = hl32_to_64 (w0[0], w0[1]);
u64x w1_t = hl32_to_64 (w0[2], w0[3]);
u64x w2_t = hl32_to_64 (w1[0], w1[1]);
u64x w3_t = hl32_to_64 (w1[2], w1[3]);
u64x w4_t = hl32_to_64 (w2[0], w2[1]);
u64x w5_t = hl32_to_64 (w2[2], w2[3]);
u64x w6_t = hl32_to_64 (w3[0], w3[1]);
u64x w7_t = 0;
u64x w8_t = 0;
u64x w9_t = 0;
u64x wa_t = 0;
u64x wb_t = 0;
u64x wc_t = 0;
u64x wd_t = 0;
u64x we_t = 0;
u64x wf_t = hl32_to_64 (w3[2], w3[3]);
u64x a = digest[0];
u64x b = digest[1];
u64x c = digest[2];
u64x d = digest[3];
u64x e = digest[4];
u64x f = digest[5];
u64x g = digest[6];
u64x h = digest[7];
#define ROUND_EXPAND() \
{ \
w0_t = SHA384_EXPAND (we_t, w9_t, w1_t, w0_t); \
w1_t = SHA384_EXPAND (wf_t, wa_t, w2_t, w1_t); \
w2_t = SHA384_EXPAND (w0_t, wb_t, w3_t, w2_t); \
w3_t = SHA384_EXPAND (w1_t, wc_t, w4_t, w3_t); \
w4_t = SHA384_EXPAND (w2_t, wd_t, w5_t, w4_t); \
w5_t = SHA384_EXPAND (w3_t, we_t, w6_t, w5_t); \
w6_t = SHA384_EXPAND (w4_t, wf_t, w7_t, w6_t); \
w7_t = SHA384_EXPAND (w5_t, w0_t, w8_t, w7_t); \
w8_t = SHA384_EXPAND (w6_t, w1_t, w9_t, w8_t); \
w9_t = SHA384_EXPAND (w7_t, w2_t, wa_t, w9_t); \
wa_t = SHA384_EXPAND (w8_t, w3_t, wb_t, wa_t); \
wb_t = SHA384_EXPAND (w9_t, w4_t, wc_t, wb_t); \
wc_t = SHA384_EXPAND (wa_t, w5_t, wd_t, wc_t); \
wd_t = SHA384_EXPAND (wb_t, w6_t, we_t, wd_t); \
we_t = SHA384_EXPAND (wc_t, w7_t, wf_t, we_t); \
wf_t = SHA384_EXPAND (wd_t, w8_t, w0_t, wf_t); \
}
#define ROUND_STEP(i) \
{ \
SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha384[i + 0]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha384[i + 1]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha384[i + 2]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha384[i + 3]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha384[i + 4]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha384[i + 5]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha384[i + 6]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha384[i + 7]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha384[i + 8]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha384[i + 9]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha384[i + 10]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha384[i + 11]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha384[i + 12]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha384[i + 13]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, we_t, k_sha384[i + 14]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha384[i + 15]); \
}
ROUND_STEP (0);
#ifdef IS_CUDA
ROUND_EXPAND (); ROUND_STEP (16);
ROUND_EXPAND (); ROUND_STEP (32);
ROUND_EXPAND (); ROUND_STEP (48);
ROUND_EXPAND (); ROUND_STEP (64);
#else
#ifdef _unroll
#pragma unroll
#endif
for (int i = 16; i < 80; i += 16)
{
ROUND_EXPAND (); ROUND_STEP (i);
}
#endif
/* rev
digest[0] += a;
digest[1] += b;
digest[2] += c;
digest[3] += d;
digest[4] += e;
digest[5] += f;
digest[6] += g;
digest[7] += h;
*/
digest[0] = a;
digest[1] = b;
digest[2] = c;
digest[3] = d;
digest[4] = e;
digest[5] = f;
digest[6] = 0;
digest[7] = 0;
}
KERNEL_FQ void m10840_m04 (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 pw_buf0[4];
u32 pw_buf1[4];
pw_buf0[0] = pws[gid].i[0];
pw_buf0[1] = pws[gid].i[1];
pw_buf0[2] = pws[gid].i[2];
pw_buf0[3] = pws[gid].i[3];
pw_buf1[0] = pws[gid].i[4];
pw_buf1[1] = pws[gid].i[5];
pw_buf1[2] = pws[gid].i[6];
pw_buf1[3] = pws[gid].i[7];
const u32 pw_l_len = pws[gid].pw_len & 63;
/**
* salt
*/
u32 salt_buf0[4];
u32 salt_buf1[4];
u32 salt_buf2[4];
u32 salt_buf3[4];
salt_buf0[0] = salt_bufs[SALT_POS].salt_buf[ 0];
salt_buf0[1] = salt_bufs[SALT_POS].salt_buf[ 1];
salt_buf0[2] = salt_bufs[SALT_POS].salt_buf[ 2];
salt_buf0[3] = salt_bufs[SALT_POS].salt_buf[ 3];
salt_buf1[0] = salt_bufs[SALT_POS].salt_buf[ 4];
salt_buf1[1] = salt_bufs[SALT_POS].salt_buf[ 5];
salt_buf1[2] = salt_bufs[SALT_POS].salt_buf[ 6];
salt_buf1[3] = salt_bufs[SALT_POS].salt_buf[ 7];
salt_buf2[0] = salt_bufs[SALT_POS].salt_buf[ 8];
salt_buf2[1] = salt_bufs[SALT_POS].salt_buf[ 9];
salt_buf2[2] = salt_bufs[SALT_POS].salt_buf[10];
salt_buf2[3] = salt_bufs[SALT_POS].salt_buf[11];
salt_buf3[0] = salt_bufs[SALT_POS].salt_buf[12];
salt_buf3[1] = salt_bufs[SALT_POS].salt_buf[13];
salt_buf3[2] = salt_bufs[SALT_POS].salt_buf[14];
salt_buf3[3] = salt_bufs[SALT_POS].salt_buf[15];
const u32 salt_len = salt_bufs[SALT_POS].salt_len;
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
/**
* concat password candidate
*/
u32x wordl0[4] = { 0 };
u32x wordl1[4] = { 0 };
u32x wordl2[4] = { 0 };
u32x wordl3[4] = { 0 };
wordl0[0] = pw_buf0[0];
wordl0[1] = pw_buf0[1];
wordl0[2] = pw_buf0[2];
wordl0[3] = pw_buf0[3];
wordl1[0] = pw_buf1[0];
wordl1[1] = pw_buf1[1];
wordl1[2] = pw_buf1[2];
wordl1[3] = pw_buf1[3];
u32x wordr0[4] = { 0 };
u32x wordr1[4] = { 0 };
u32x wordr2[4] = { 0 };
u32x wordr3[4] = { 0 };
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
}
else
{
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
}
u32x w0[4];
u32x w1[4];
u32x w2[4];
u32x w3[4];
w0[0] = wordl0[0] | wordr0[0];
w0[1] = wordl0[1] | wordr0[1];
w0[2] = wordl0[2] | wordr0[2];
w0[3] = wordl0[3] | wordr0[3];
w1[0] = wordl1[0] | wordr1[0];
w1[1] = wordl1[1] | wordr1[1];
w1[2] = wordl1[2] | wordr1[2];
w1[3] = wordl1[3] | wordr1[3];
w2[0] = wordl2[0] | wordr2[0];
w2[1] = wordl2[1] | wordr2[1];
w2[2] = wordl2[2] | wordr2[2];
w2[3] = wordl2[3] | wordr2[3];
w3[0] = wordl3[0] | wordr3[0];
w3[1] = wordl3[1] | wordr3[1];
w3[2] = wordl3[2] | wordr3[2];
w3[3] = wordl3[3] | wordr3[3];
make_utf16le (w1, w2, w3);
make_utf16le (w0, w0, w1);
const u32x pw_len2 = pw_len * 2;
/**
* prepend salt
*/
switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len);
const u32x pw_salt_len = pw_len2 + salt_len;
w0[0] |= salt_buf0[0];
w0[1] |= salt_buf0[1];
w0[2] |= salt_buf0[2];
w0[3] |= salt_buf0[3];
w1[0] |= salt_buf1[0];
w1[1] |= salt_buf1[1];
w1[2] |= salt_buf1[2];
w1[3] |= salt_buf1[3];
w2[0] |= salt_buf2[0];
w2[1] |= salt_buf2[1];
w2[2] |= salt_buf2[2];
w2[3] |= salt_buf2[3];
w3[0] |= salt_buf3[0];
w3[1] |= salt_buf3[1];
w3[2] |= salt_buf3[2];
w3[3] |= salt_buf3[3];
/**
* sha512
*/
u32x w0_t[4];
u32x w1_t[4];
u32x w2_t[4];
u32x w3_t[4];
w0_t[0] = hc_swap32 (w0[0]);
w0_t[1] = hc_swap32 (w0[1]);
w0_t[2] = hc_swap32 (w0[2]);
w0_t[3] = hc_swap32 (w0[3]);
w1_t[0] = hc_swap32 (w1[0]);
w1_t[1] = hc_swap32 (w1[1]);
w1_t[2] = hc_swap32 (w1[2]);
w1_t[3] = hc_swap32 (w1[3]);
w2_t[0] = hc_swap32 (w2[0]);
w2_t[1] = hc_swap32 (w2[1]);
w2_t[2] = hc_swap32 (w2[2]);
w2_t[3] = hc_swap32 (w2[3]);
w3_t[0] = hc_swap32 (w3[0]);
w3_t[1] = hc_swap32 (w3[1]);
w3_t[2] = 0;
w3_t[3] = pw_salt_len * 8;
u64x digest[8];
digest[0] = SHA384M_A;
digest[1] = SHA384M_B;
digest[2] = SHA384M_C;
digest[3] = SHA384M_D;
digest[4] = SHA384M_E;
digest[5] = SHA384M_F;
digest[6] = SHA384M_G;
digest[7] = SHA384M_H;
sha384_transform_intern (w0_t, w1_t, w2_t, w3_t, digest);
const u32x r0 = l32_from_64 (digest[3]);
const u32x r1 = h32_from_64 (digest[3]);
const u32x r2 = l32_from_64 (digest[2]);
const u32x r3 = h32_from_64 (digest[2]);
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_m08 (KERN_ATTR_BASIC ())
{
}
KERNEL_FQ void m10840_m16 (KERN_ATTR_BASIC ())
{
}
KERNEL_FQ void m10840_s04 (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 pw_buf0[4];
u32 pw_buf1[4];
pw_buf0[0] = pws[gid].i[0];
pw_buf0[1] = pws[gid].i[1];
pw_buf0[2] = pws[gid].i[2];
pw_buf0[3] = pws[gid].i[3];
pw_buf1[0] = pws[gid].i[4];
pw_buf1[1] = pws[gid].i[5];
pw_buf1[2] = pws[gid].i[6];
pw_buf1[3] = pws[gid].i[7];
const u32 pw_l_len = pws[gid].pw_len & 63;
/**
* salt
*/
u32 salt_buf0[4];
u32 salt_buf1[4];
u32 salt_buf2[4];
u32 salt_buf3[4];
salt_buf0[0] = salt_bufs[SALT_POS].salt_buf[ 0];
salt_buf0[1] = salt_bufs[SALT_POS].salt_buf[ 1];
salt_buf0[2] = salt_bufs[SALT_POS].salt_buf[ 2];
salt_buf0[3] = salt_bufs[SALT_POS].salt_buf[ 3];
salt_buf1[0] = salt_bufs[SALT_POS].salt_buf[ 4];
salt_buf1[1] = salt_bufs[SALT_POS].salt_buf[ 5];
salt_buf1[2] = salt_bufs[SALT_POS].salt_buf[ 6];
salt_buf1[3] = salt_bufs[SALT_POS].salt_buf[ 7];
salt_buf2[0] = salt_bufs[SALT_POS].salt_buf[ 8];
salt_buf2[1] = salt_bufs[SALT_POS].salt_buf[ 9];
salt_buf2[2] = salt_bufs[SALT_POS].salt_buf[10];
salt_buf2[3] = salt_bufs[SALT_POS].salt_buf[11];
salt_buf3[0] = salt_bufs[SALT_POS].salt_buf[12];
salt_buf3[1] = salt_bufs[SALT_POS].salt_buf[13];
salt_buf3[2] = salt_bufs[SALT_POS].salt_buf[14];
salt_buf3[3] = salt_bufs[SALT_POS].salt_buf[15];
const u32 salt_len = salt_bufs[SALT_POS].salt_len;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
/**
* concat password candidate
*/
u32x wordl0[4] = { 0 };
u32x wordl1[4] = { 0 };
u32x wordl2[4] = { 0 };
u32x wordl3[4] = { 0 };
wordl0[0] = pw_buf0[0];
wordl0[1] = pw_buf0[1];
wordl0[2] = pw_buf0[2];
wordl0[3] = pw_buf0[3];
wordl1[0] = pw_buf1[0];
wordl1[1] = pw_buf1[1];
wordl1[2] = pw_buf1[2];
wordl1[3] = pw_buf1[3];
u32x wordr0[4] = { 0 };
u32x wordr1[4] = { 0 };
u32x wordr2[4] = { 0 };
u32x wordr3[4] = { 0 };
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
}
else
{
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
}
u32x w0[4];
u32x w1[4];
u32x w2[4];
u32x w3[4];
w0[0] = wordl0[0] | wordr0[0];
w0[1] = wordl0[1] | wordr0[1];
w0[2] = wordl0[2] | wordr0[2];
w0[3] = wordl0[3] | wordr0[3];
w1[0] = wordl1[0] | wordr1[0];
w1[1] = wordl1[1] | wordr1[1];
w1[2] = wordl1[2] | wordr1[2];
w1[3] = wordl1[3] | wordr1[3];
w2[0] = wordl2[0] | wordr2[0];
w2[1] = wordl2[1] | wordr2[1];
w2[2] = wordl2[2] | wordr2[2];
w2[3] = wordl2[3] | wordr2[3];
w3[0] = wordl3[0] | wordr3[0];
w3[1] = wordl3[1] | wordr3[1];
w3[2] = wordl3[2] | wordr3[2];
w3[3] = wordl3[3] | wordr3[3];
make_utf16le (w1, w2, w3);
make_utf16le (w0, w0, w1);
const u32x pw_len2 = pw_len * 2;
/**
* prepend salt
*/
switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len);
const u32x pw_salt_len = pw_len2 + salt_len;
w0[0] |= salt_buf0[0];
w0[1] |= salt_buf0[1];
w0[2] |= salt_buf0[2];
w0[3] |= salt_buf0[3];
w1[0] |= salt_buf1[0];
w1[1] |= salt_buf1[1];
w1[2] |= salt_buf1[2];
w1[3] |= salt_buf1[3];
w2[0] |= salt_buf2[0];
w2[1] |= salt_buf2[1];
w2[2] |= salt_buf2[2];
w2[3] |= salt_buf2[3];
w3[0] |= salt_buf3[0];
w3[1] |= salt_buf3[1];
w3[2] |= salt_buf3[2];
w3[3] |= salt_buf3[3];
/**
* sha512
*/
u32x w0_t[4];
u32x w1_t[4];
u32x w2_t[4];
u32x w3_t[4];
w0_t[0] = hc_swap32 (w0[0]);
w0_t[1] = hc_swap32 (w0[1]);
w0_t[2] = hc_swap32 (w0[2]);
w0_t[3] = hc_swap32 (w0[3]);
w1_t[0] = hc_swap32 (w1[0]);
w1_t[1] = hc_swap32 (w1[1]);
w1_t[2] = hc_swap32 (w1[2]);
w1_t[3] = hc_swap32 (w1[3]);
w2_t[0] = hc_swap32 (w2[0]);
w2_t[1] = hc_swap32 (w2[1]);
w2_t[2] = hc_swap32 (w2[2]);
w2_t[3] = hc_swap32 (w2[3]);
w3_t[0] = hc_swap32 (w3[0]);
w3_t[1] = hc_swap32 (w3[1]);
w3_t[2] = 0;
w3_t[3] = pw_salt_len * 8;
u64x digest[8];
digest[0] = SHA384M_A;
digest[1] = SHA384M_B;
digest[2] = SHA384M_C;
digest[3] = SHA384M_D;
digest[4] = SHA384M_E;
digest[5] = SHA384M_F;
digest[6] = SHA384M_G;
digest[7] = SHA384M_H;
sha384_transform_intern (w0_t, w1_t, w2_t, w3_t, digest);
const u32x r0 = l32_from_64 (digest[3]);
const u32x r1 = h32_from_64 (digest[3]);
const u32x r2 = l32_from_64 (digest[2]);
const u32x r3 = h32_from_64 (digest[2]);
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_s08 (KERN_ATTR_BASIC ())
{
}
KERNEL_FQ void m10840_s16 (KERN_ATTR_BASIC ())
{
}

@ -0,0 +1,115 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_scalar.cl"
#include "inc_hash_sha384.cl"
#endif
KERNEL_FQ void m10840_mxx (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
/**
* base
*/
sha384_ctx_t ctx0;
sha384_init (&ctx0);
sha384_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
sha384_update_global_utf16le_swap (&ctx0, pws[gid].i, pws[gid].pw_len);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
sha384_ctx_t ctx = ctx0;
sha384_update_global_utf16le_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
sha384_final (&ctx);
const u32 r0 = l32_from_64_S (ctx.h[3]);
const u32 r1 = h32_from_64_S (ctx.h[3]);
const u32 r2 = l32_from_64_S (ctx.h[2]);
const u32 r3 = h32_from_64_S (ctx.h[2]);
COMPARE_M_SCALAR (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_sxx (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
* base
*/
sha384_ctx_t ctx0;
sha384_init (&ctx0);
sha384_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
sha384_update_global_utf16le_swap (&ctx0, pws[gid].i, pws[gid].pw_len);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
sha384_ctx_t ctx = ctx0;
sha384_update_global_utf16le_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
sha384_final (&ctx);
const u32 r0 = l32_from_64_S (ctx.h[3]);
const u32 r1 = h32_from_64_S (ctx.h[3]);
const u32 r2 = l32_from_64_S (ctx.h[2]);
const u32 r3 = h32_from_64_S (ctx.h[2]);
COMPARE_S_SCALAR (r0, r1, r2, r3);
}
}

@ -0,0 +1,597 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_simd.cl"
#include "inc_hash_sha384.cl"
#endif
DECLSPEC void sha384_transform_intern (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u64x *digest)
{
u64x w0_t = hl32_to_64 (w0[0], w0[1]);
u64x w1_t = hl32_to_64 (w0[2], w0[3]);
u64x w2_t = hl32_to_64 (w1[0], w1[1]);
u64x w3_t = hl32_to_64 (w1[2], w1[3]);
u64x w4_t = hl32_to_64 (w2[0], w2[1]);
u64x w5_t = hl32_to_64 (w2[2], w2[3]);
u64x w6_t = hl32_to_64 (w3[0], w3[1]);
u64x w7_t = 0;
u64x w8_t = 0;
u64x w9_t = 0;
u64x wa_t = 0;
u64x wb_t = 0;
u64x wc_t = 0;
u64x wd_t = 0;
u64x we_t = 0;
u64x wf_t = hl32_to_64 (w3[2], w3[3]);
u64x a = digest[0];
u64x b = digest[1];
u64x c = digest[2];
u64x d = digest[3];
u64x e = digest[4];
u64x f = digest[5];
u64x g = digest[6];
u64x h = digest[7];
#define ROUND_EXPAND() \
{ \
w0_t = SHA384_EXPAND (we_t, w9_t, w1_t, w0_t); \
w1_t = SHA384_EXPAND (wf_t, wa_t, w2_t, w1_t); \
w2_t = SHA384_EXPAND (w0_t, wb_t, w3_t, w2_t); \
w3_t = SHA384_EXPAND (w1_t, wc_t, w4_t, w3_t); \
w4_t = SHA384_EXPAND (w2_t, wd_t, w5_t, w4_t); \
w5_t = SHA384_EXPAND (w3_t, we_t, w6_t, w5_t); \
w6_t = SHA384_EXPAND (w4_t, wf_t, w7_t, w6_t); \
w7_t = SHA384_EXPAND (w5_t, w0_t, w8_t, w7_t); \
w8_t = SHA384_EXPAND (w6_t, w1_t, w9_t, w8_t); \
w9_t = SHA384_EXPAND (w7_t, w2_t, wa_t, w9_t); \
wa_t = SHA384_EXPAND (w8_t, w3_t, wb_t, wa_t); \
wb_t = SHA384_EXPAND (w9_t, w4_t, wc_t, wb_t); \
wc_t = SHA384_EXPAND (wa_t, w5_t, wd_t, wc_t); \
wd_t = SHA384_EXPAND (wb_t, w6_t, we_t, wd_t); \
we_t = SHA384_EXPAND (wc_t, w7_t, wf_t, we_t); \
wf_t = SHA384_EXPAND (wd_t, w8_t, w0_t, wf_t); \
}
#define ROUND_STEP(i) \
{ \
SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha384[i + 0]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha384[i + 1]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha384[i + 2]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha384[i + 3]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha384[i + 4]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha384[i + 5]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha384[i + 6]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha384[i + 7]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha384[i + 8]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha384[i + 9]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha384[i + 10]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha384[i + 11]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha384[i + 12]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha384[i + 13]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, c, d, e, f, g, h, a, b, we_t, k_sha384[i + 14]); \
SHA384_STEP (SHA384_F0o, SHA384_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha384[i + 15]); \
}
ROUND_STEP (0);
#ifdef IS_CUDA
ROUND_EXPAND (); ROUND_STEP (16);
ROUND_EXPAND (); ROUND_STEP (32);
ROUND_EXPAND (); ROUND_STEP (48);
ROUND_EXPAND (); ROUND_STEP (64);
#else
#ifdef _unroll
#pragma unroll
#endif
for (int i = 16; i < 80; i += 16)
{
ROUND_EXPAND (); ROUND_STEP (i);
}
#endif
/* rev
digest[0] += a;
digest[1] += b;
digest[2] += c;
digest[3] += d;
digest[4] += e;
digest[5] += f;
digest[6] += g;
digest[7] += h;
*/
digest[0] = a;
digest[1] = b;
digest[2] = c;
digest[3] = d;
digest[4] = e;
digest[5] = f;
digest[6] = 0;
digest[7] = 0;
}
DECLSPEC void m10840m (u32 *w, const u32 pw_len, KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
/**
* salt
*/
u32 salt_buf0[4];
u32 salt_buf1[4];
u32 salt_buf2[4];
u32 salt_buf3[4];
salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 0]);
salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 1]);
salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 2]);
salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 3]);
salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 4]);
salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 5]);
salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 6]);
salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 7]);
salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 8]);
salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 9]);
salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[10]);
salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[11]);
salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[12]);
salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[13]);
salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[14]);
salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[15]);
const u32 salt_len = salt_bufs[SALT_POS].salt_len;
const u32 pw_salt_len = pw_len + salt_len;
/**
* loop
*/
u32 w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = ix_create_bft (bfs_buf, il_pos);
const u32x w0lr = w0l | w0r;
u32x w0_t[4];
u32x w1_t[4];
u32x w2_t[4];
u32x w3_t[4];
w0_t[0] = w0lr;
w0_t[1] = w[ 1];
w0_t[2] = w[ 2];
w0_t[3] = w[ 3];
w1_t[0] = w[ 4];
w1_t[1] = w[ 5];
w1_t[2] = w[ 6];
w1_t[3] = w[ 7];
w2_t[0] = w[ 8];
w2_t[1] = w[ 9];
w2_t[2] = w[10];
w2_t[3] = w[11];
w3_t[0] = w[12];
w3_t[1] = w[13];
w3_t[2] = w[14];
w3_t[3] = w[15];
switch_buffer_by_offset_be (w0_t, w1_t, w2_t, w3_t, salt_len);
w0_t[0] |= salt_buf0[0];
w0_t[1] |= salt_buf0[1];
w0_t[2] |= salt_buf0[2];
w0_t[3] |= salt_buf0[3];
w1_t[0] |= salt_buf1[0];
w1_t[1] |= salt_buf1[1];
w1_t[2] |= salt_buf1[2];
w1_t[3] |= salt_buf1[3];
w2_t[0] |= salt_buf2[0];
w2_t[1] |= salt_buf2[1];
w2_t[2] |= salt_buf2[2];
w2_t[3] |= salt_buf2[3];
w3_t[0] |= salt_buf3[0];
w3_t[1] |= salt_buf3[1];
w3_t[2] = 0;
w3_t[3] = pw_salt_len * 8;
/**
* sha512
*/
u64x digest[8];
digest[0] = SHA384M_A;
digest[1] = SHA384M_B;
digest[2] = SHA384M_C;
digest[3] = SHA384M_D;
digest[4] = SHA384M_E;
digest[5] = SHA384M_F;
digest[6] = SHA384M_G;
digest[7] = SHA384M_H;
sha384_transform_intern (w0_t, w1_t, w2_t, w3_t, digest);
const u32x r0 = l32_from_64 (digest[3]);
const u32x r1 = h32_from_64 (digest[3]);
const u32x r2 = l32_from_64 (digest[2]);
const u32x r3 = h32_from_64 (digest[2]);
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
DECLSPEC void m10840s (u32 *w, const u32 pw_len, KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
* salt
*/
u32 salt_buf0[4];
u32 salt_buf1[4];
u32 salt_buf2[4];
u32 salt_buf3[4];
salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 0]);
salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 1]);
salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 2]);
salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 3]);
salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 4]);
salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 5]);
salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 6]);
salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 7]);
salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 8]);
salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[ 9]);
salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[10]);
salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[11]);
salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[12]);
salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[13]);
salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[14]);
salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS].salt_buf[15]);
const u32 salt_len = salt_bufs[SALT_POS].salt_len;
const u32 pw_salt_len = pw_len + salt_len;
/**
* loop
*/
u32 w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = ix_create_bft (bfs_buf, il_pos);
const u32x w0lr = w0l | w0r;
u32x w0_t[4];
u32x w1_t[4];
u32x w2_t[4];
u32x w3_t[4];
w0_t[0] = w0lr;
w0_t[1] = w[ 1];
w0_t[2] = w[ 2];
w0_t[3] = w[ 3];
w1_t[0] = w[ 4];
w1_t[1] = w[ 5];
w1_t[2] = w[ 6];
w1_t[3] = w[ 7];
w2_t[0] = w[ 8];
w2_t[1] = w[ 9];
w2_t[2] = w[10];
w2_t[3] = w[11];
w3_t[0] = w[12];
w3_t[1] = w[13];
w3_t[2] = w[14];
w3_t[3] = w[15];
switch_buffer_by_offset_be (w0_t, w1_t, w2_t, w3_t, salt_len);
w0_t[0] |= salt_buf0[0];
w0_t[1] |= salt_buf0[1];
w0_t[2] |= salt_buf0[2];
w0_t[3] |= salt_buf0[3];
w1_t[0] |= salt_buf1[0];
w1_t[1] |= salt_buf1[1];
w1_t[2] |= salt_buf1[2];
w1_t[3] |= salt_buf1[3];
w2_t[0] |= salt_buf2[0];
w2_t[1] |= salt_buf2[1];
w2_t[2] |= salt_buf2[2];
w2_t[3] |= salt_buf2[3];
w3_t[0] |= salt_buf3[0];
w3_t[1] |= salt_buf3[1];
w3_t[2] = 0;
w3_t[3] = pw_salt_len * 8;
/**
* sha512
*/
u64x digest[8];
digest[0] = SHA384M_A;
digest[1] = SHA384M_B;
digest[2] = SHA384M_C;
digest[3] = SHA384M_D;
digest[4] = SHA384M_E;
digest[5] = SHA384M_F;
digest[6] = SHA384M_G;
digest[7] = SHA384M_H;
sha384_transform_intern (w0_t, w1_t, w2_t, w3_t, digest);
const u32x r0 = l32_from_64 (digest[3]);
const u32x r1 = h32_from_64 (digest[3]);
const u32x r2 = l32_from_64 (digest[2]);
const u32x r3 = h32_from_64 (digest[2]);
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_m04 (KERN_ATTR_BASIC ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = 0;
w[ 5] = 0;
w[ 6] = 0;
w[ 7] = 0;
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = 0;
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m10840m (w, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, pws_pos, gid_max);
}
KERNEL_FQ void m10840_m08 (KERN_ATTR_BASIC ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = 0;
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m10840m (w, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, pws_pos, gid_max);
}
KERNEL_FQ void m10840_m16 (KERN_ATTR_BASIC ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = pws[gid].i[ 8];
w[ 9] = pws[gid].i[ 9];
w[10] = pws[gid].i[10];
w[11] = pws[gid].i[11];
w[12] = pws[gid].i[12];
w[13] = pws[gid].i[13];
w[14] = pws[gid].i[14];
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m10840m (w, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, pws_pos, gid_max);
}
KERNEL_FQ void m10840_s04 (KERN_ATTR_BASIC ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = 0;
w[ 5] = 0;
w[ 6] = 0;
w[ 7] = 0;
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = 0;
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m10840s (w, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, pws_pos, gid_max);
}
KERNEL_FQ void m10840_s08 (KERN_ATTR_BASIC ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = 0;
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m10840s (w, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, pws_pos, gid_max);
}
KERNEL_FQ void m10840_s16 (KERN_ATTR_BASIC ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = pws[gid].i[ 8];
w[ 9] = pws[gid].i[ 9];
w[10] = pws[gid].i[10];
w[11] = pws[gid].i[11];
w[12] = pws[gid].i[12];
w[13] = pws[gid].i[13];
w[14] = pws[gid].i[14];
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m10840s (w, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, pws_pos, gid_max);
}

@ -0,0 +1,149 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_simd.cl"
#include "inc_hash_sha384.cl"
#endif
KERNEL_FQ void m10840_mxx (KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
/**
* base
*/
const u32 pw_len = pws[gid].pw_len;
u32x w[64] = { 0 };
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
{
w[idx] = pws[gid].i[idx];
}
sha384_ctx_t ctx0;
sha384_init (&ctx0);
sha384_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
/**
* loop
*/
u32x w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
w[0] = w0;
sha384_ctx_vector_t ctx;
sha384_init_vector_from_scalar (&ctx, &ctx0);
sha384_update_vector_utf16beN (&ctx, w, pw_len);
sha384_final_vector (&ctx);
const u32x r0 = l32_from_64 (ctx.h[3]);
const u32x r1 = h32_from_64 (ctx.h[3]);
const u32x r2 = l32_from_64 (ctx.h[2]);
const u32x r3 = h32_from_64 (ctx.h[2]);
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m10840_sxx (KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
* base
*/
const u32 pw_len = pws[gid].pw_len;
u32x w[64] = { 0 };
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
{
w[idx] = pws[gid].i[idx];
}
sha384_ctx_t ctx0;
sha384_init (&ctx0);
sha384_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
/**
* loop
*/
u32x w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
w[0] = w0;
sha384_ctx_vector_t ctx;
sha384_init_vector_from_scalar (&ctx, &ctx0);
sha384_update_vector_utf16beN (&ctx, w, pw_len);
sha384_final_vector (&ctx);
const u32x r0 = l32_from_64 (ctx.h[3]);
const u32x r1 = h32_from_64 (ctx.h[3]);
const u32x r2 = l32_from_64 (ctx.h[2]);
const u32x r3 = h32_from_64 (ctx.h[2]);
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}

@ -14,6 +14,7 @@
- Added hash-mode: RAR3-p (Uncompressed)
- Added hash-mode: RSA/DSA/EC/OPENSSH Private Keys
- Added hash-mode: sha1(sha1($pass).$salt)
- Added hash-mode: sha384($salt.utf16le($pass))
##
## Bugs

@ -107,6 +107,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or
- sha256(sha256($pass).$salt)
- sha256(sha256_bin($pass))
- sha256(utf16le($pass).$salt)
- sha384($salt.utf16le($pass))
- sha512($pass.$salt)
- sha512($salt.$pass)
- sha512($salt.utf16le($pass))

@ -0,0 +1,290 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "modules.h"
#include "bitops.h"
#include "convert.h"
#include "shared.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 6;
static const u32 DGST_POS1 = 7;
static const u32 DGST_POS2 = 4;
static const u32 DGST_POS3 = 5;
static const u32 DGST_SIZE = DGST_SIZE_8_8;
static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH;
static const char *HASH_NAME = "sha384($salt.utf16le($pass))";
static const u64 KERN_TYPE = 10840;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_PRECOMPUTE_INIT
| OPTI_TYPE_EARLY_SKIP
| OPTI_TYPE_NOT_ITERATED
| OPTI_TYPE_PREPENDED_SALT
| OPTI_TYPE_USES_BITS_64
| OPTI_TYPE_RAW_HASH;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE
| OPTS_TYPE_PT_UTF16LE
| OPTS_TYPE_PT_ADD80
| OPTS_TYPE_PT_ADDBITS15;
static const u32 SALT_TYPE = SALT_TYPE_GENERIC;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "316e93ea8e04de3e5a909c53d36923a31a16c1b9e89b44201d6082f87ca49c5bca53cad65f685207db3ea2ccc7ca40f8:700067651";
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; }
u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; }
u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; }
u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; }
u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; }
const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; }
u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; }
u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; }
u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; }
u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; }
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
{
if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE)
{
// self-test failed
if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU))
{
return true;
}
}
return false;
}
char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param)
{
char *jit_build_options = NULL;
// Extra treatment for Apple systems
if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE)
{
return jit_build_options;
}
// ROCM
if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true))
{
hc_asprintf (&jit_build_options, "-D _unroll");
}
return jit_build_options;
}
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len)
{
u64 *digest = (u64 *) digest_buf;
token_t token;
token.token_cnt = 2;
token.sep[0] = hashconfig->separator;
token.len_min[0] = 96;
token.len_max[0] = 96;
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.len_min[1] = SALT_MIN;
token.len_max[1] = SALT_MAX;
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH;
if (hashconfig->opts_type & OPTS_TYPE_ST_HEX)
{
token.len_min[1] *= 2;
token.len_max[1] *= 2;
token.attr[1] |= TOKEN_ATTR_VERIFY_HEX;
}
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
const u8 *hash_pos = token.buf[0];
digest[0] = hex_to_u64 (hash_pos + 0);
digest[1] = hex_to_u64 (hash_pos + 16);
digest[2] = hex_to_u64 (hash_pos + 32);
digest[3] = hex_to_u64 (hash_pos + 48);
digest[4] = hex_to_u64 (hash_pos + 64);
digest[5] = hex_to_u64 (hash_pos + 80);
digest[6] = 0;
digest[7] = 0;
digest[0] = byte_swap_64 (digest[0]);
digest[1] = byte_swap_64 (digest[1]);
digest[2] = byte_swap_64 (digest[2]);
digest[3] = byte_swap_64 (digest[3]);
digest[4] = byte_swap_64 (digest[4]);
digest[5] = byte_swap_64 (digest[5]);
digest[6] = 0;
digest[7] = 0;
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
{
digest[0] -= SHA384M_A;
digest[1] -= SHA384M_B;
digest[2] -= SHA384M_C;
digest[3] -= SHA384M_D;
digest[4] -= SHA384M_E;
digest[5] -= SHA384M_F;
digest[6] -= 0;
digest[7] -= 0;
}
const u8 *salt_pos = token.buf[1];
const int salt_len = token.len[1];
const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len);
if (parse_rc == false) return (PARSER_SALT_LENGTH);
return (PARSER_OK);
}
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
{
const u64 *digest = (const u64 *) digest_buf;
// we can not change anything in the original buffer, otherwise destroying sorting
// therefore create some local buffer
u64 tmp[8];
tmp[0] = digest[0];
tmp[1] = digest[1];
tmp[2] = digest[2];
tmp[3] = digest[3];
tmp[4] = digest[4];
tmp[5] = digest[5];
tmp[6] = 0;
tmp[7] = 0;
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
{
tmp[0] += SHA384M_A;
tmp[1] += SHA384M_B;
tmp[2] += SHA384M_C;
tmp[3] += SHA384M_D;
tmp[4] += SHA384M_E;
tmp[5] += SHA384M_F;
tmp[6] += 0;
tmp[7] += 0;
}
tmp[0] = byte_swap_64 (tmp[0]);
tmp[1] = byte_swap_64 (tmp[1]);
tmp[2] = byte_swap_64 (tmp[2]);
tmp[3] = byte_swap_64 (tmp[3]);
tmp[4] = byte_swap_64 (tmp[4]);
tmp[5] = byte_swap_64 (tmp[5]);
tmp[6] = 0;
tmp[7] = 0;
u8 *out_buf = (u8 *) line_buf;
int out_len = 0;
u64_to_hex (tmp[0], out_buf + out_len); out_len += 16;
u64_to_hex (tmp[1], out_buf + out_len); out_len += 16;
u64_to_hex (tmp[2], out_buf + out_len); out_len += 16;
u64_to_hex (tmp[3], out_buf + out_len); out_len += 16;
u64_to_hex (tmp[4], out_buf + out_len); out_len += 16;
u64_to_hex (tmp[5], out_buf + out_len); out_len += 16;
out_buf[out_len] = hashconfig->separator;
out_len += 1;
out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len);
return out_len;
}
void module_init (module_ctx_t *module_ctx)
{
module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT;
module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT;
module_ctx->module_attack_exec = module_attack_exec;
module_ctx->module_benchmark_esalt = MODULE_DEFAULT;
module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT;
module_ctx->module_benchmark_mask = MODULE_DEFAULT;
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
module_ctx->module_deep_comp_kernel = MODULE_DEFAULT;
module_ctx->module_dgst_pos0 = module_dgst_pos0;
module_ctx->module_dgst_pos1 = module_dgst_pos1;
module_ctx->module_dgst_pos2 = module_dgst_pos2;
module_ctx->module_dgst_pos3 = module_dgst_pos3;
module_ctx->module_dgst_size = module_dgst_size;
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
module_ctx->module_esalt_size = MODULE_DEFAULT;
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
module_ctx->module_forced_outfile_format = MODULE_DEFAULT;
module_ctx->module_hash_binary_count = MODULE_DEFAULT;
module_ctx->module_hash_binary_parse = MODULE_DEFAULT;
module_ctx->module_hash_binary_save = MODULE_DEFAULT;
module_ctx->module_hash_decode_potfile = MODULE_DEFAULT;
module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT;
module_ctx->module_hash_decode = module_hash_decode;
module_ctx->module_hash_encode_status = MODULE_DEFAULT;
module_ctx->module_hash_encode_potfile = MODULE_DEFAULT;
module_ctx->module_hash_encode = module_hash_encode;
module_ctx->module_hash_init_selftest = MODULE_DEFAULT;
module_ctx->module_hash_mode = MODULE_DEFAULT;
module_ctx->module_hash_category = module_hash_category;
module_ctx->module_hash_name = module_hash_name;
module_ctx->module_hashes_count_min = MODULE_DEFAULT;
module_ctx->module_hashes_count_max = MODULE_DEFAULT;
module_ctx->module_hlfmt_disable = MODULE_DEFAULT;
module_ctx->module_hook_extra_param_size = MODULE_DEFAULT;
module_ctx->module_hook_extra_param_init = MODULE_DEFAULT;
module_ctx->module_hook_extra_param_term = MODULE_DEFAULT;
module_ctx->module_hook12 = MODULE_DEFAULT;
module_ctx->module_hook23 = MODULE_DEFAULT;
module_ctx->module_hook_salt_size = MODULE_DEFAULT;
module_ctx->module_hook_size = MODULE_DEFAULT;
module_ctx->module_jit_build_options = module_jit_build_options;
module_ctx->module_jit_cache_disable = MODULE_DEFAULT;
module_ctx->module_kernel_accel_max = MODULE_DEFAULT;
module_ctx->module_kernel_accel_min = MODULE_DEFAULT;
module_ctx->module_kernel_loops_max = MODULE_DEFAULT;
module_ctx->module_kernel_loops_min = MODULE_DEFAULT;
module_ctx->module_kernel_threads_max = MODULE_DEFAULT;
module_ctx->module_kernel_threads_min = MODULE_DEFAULT;
module_ctx->module_kern_type = module_kern_type;
module_ctx->module_kern_type_dynamic = MODULE_DEFAULT;
module_ctx->module_opti_type = module_opti_type;
module_ctx->module_opts_type = module_opts_type;
module_ctx->module_outfile_check_disable = MODULE_DEFAULT;
module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT;
module_ctx->module_potfile_custom_check = MODULE_DEFAULT;
module_ctx->module_potfile_disable = MODULE_DEFAULT;
module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT;
module_ctx->module_pwdump_column = MODULE_DEFAULT;
module_ctx->module_pw_max = MODULE_DEFAULT;
module_ctx->module_pw_min = MODULE_DEFAULT;
module_ctx->module_salt_max = MODULE_DEFAULT;
module_ctx->module_salt_min = MODULE_DEFAULT;
module_ctx->module_salt_type = module_salt_type;
module_ctx->module_separator = MODULE_DEFAULT;
module_ctx->module_st_hash = module_st_hash;
module_ctx->module_st_pass = module_st_pass;
module_ctx->module_tmp_size = MODULE_DEFAULT;
module_ctx->module_unstable_warning = module_unstable_warning;
module_ctx->module_warmup_disable = MODULE_DEFAULT;
}

@ -0,0 +1,45 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha384_hex);
use Encode;
sub module_constraints { [[0, 256], [0, 256], [0, 27], [0, 27], [0, 27]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $digest = sha384_hex ($salt . encode ("UTF-16LE", $word));
my $hash = sprintf ("%s:%s", $digest, $salt);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $salt, $word) = split (':', $line);
return unless defined $hash;
return unless defined $salt;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt);
return ($new_hash, $word);
}
1;
Loading…
Cancel
Save