mirror of https://github.com/hashcat/hashcat.git
Merge branch 'master' of https://github.com/roycewilliams/hashcat
commit
e4626dc471
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "inc_vendor.h"
|
||||
#include "inc_types.h"
|
||||
#include "inc_platform.h"
|
||||
#include "inc_common.h"
|
||||
#include "inc_veracrypt_keyfile.h"
|
||||
|
||||
DECLSPEC u32 u8add (const u32 a, const u32 b)
|
||||
{
|
||||
const u32 a1 = (a >> 0) & 0xff;
|
||||
const u32 a2 = (a >> 8) & 0xff;
|
||||
const u32 a3 = (a >> 16) & 0xff;
|
||||
const u32 a4 = (a >> 24) & 0xff;
|
||||
|
||||
const u32 b1 = (b >> 0) & 0xff;
|
||||
const u32 b2 = (b >> 8) & 0xff;
|
||||
const u32 b3 = (b >> 16) & 0xff;
|
||||
const u32 b4 = (b >> 24) & 0xff;
|
||||
|
||||
const u32 r1 = (a1 + b1) & 0xff;
|
||||
const u32 r2 = (a2 + b2) & 0xff;
|
||||
const u32 r3 = (a3 + b3) & 0xff;
|
||||
const u32 r4 = (a4 + b4) & 0xff;
|
||||
|
||||
const u32 r = r1 << 0
|
||||
| r2 << 8
|
||||
| r3 << 16
|
||||
| r4 << 24;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
DECLSPEC u32 hc_apply_keyfile_vc (u32 *w, const int pw_len, const GLOBAL_AS vc_t *vc)
|
||||
{
|
||||
if (vc->keyfile_enabled == 0) return pw_len;
|
||||
|
||||
if (pw_len > 64)
|
||||
{
|
||||
w[ 0] = u8add (w[ 0], vc->keyfile_buf32[ 0]);
|
||||
w[ 1] = u8add (w[ 1], vc->keyfile_buf32[ 1]);
|
||||
w[ 2] = u8add (w[ 2], vc->keyfile_buf32[ 2]);
|
||||
w[ 3] = u8add (w[ 3], vc->keyfile_buf32[ 3]);
|
||||
w[ 4] = u8add (w[ 4], vc->keyfile_buf32[ 4]);
|
||||
w[ 5] = u8add (w[ 5], vc->keyfile_buf32[ 5]);
|
||||
w[ 6] = u8add (w[ 6], vc->keyfile_buf32[ 6]);
|
||||
w[ 7] = u8add (w[ 7], vc->keyfile_buf32[ 7]);
|
||||
w[ 8] = u8add (w[ 8], vc->keyfile_buf32[ 8]);
|
||||
w[ 9] = u8add (w[ 9], vc->keyfile_buf32[ 9]);
|
||||
w[10] = u8add (w[10], vc->keyfile_buf32[10]);
|
||||
w[11] = u8add (w[11], vc->keyfile_buf32[11]);
|
||||
w[12] = u8add (w[12], vc->keyfile_buf32[12]);
|
||||
w[13] = u8add (w[13], vc->keyfile_buf32[13]);
|
||||
w[14] = u8add (w[14], vc->keyfile_buf32[14]);
|
||||
w[15] = u8add (w[15], vc->keyfile_buf32[15]);
|
||||
w[16] = u8add (w[16], vc->keyfile_buf32[16]);
|
||||
w[17] = u8add (w[17], vc->keyfile_buf32[17]);
|
||||
w[18] = u8add (w[18], vc->keyfile_buf32[18]);
|
||||
w[19] = u8add (w[19], vc->keyfile_buf32[19]);
|
||||
w[20] = u8add (w[20], vc->keyfile_buf32[20]);
|
||||
w[21] = u8add (w[21], vc->keyfile_buf32[21]);
|
||||
w[22] = u8add (w[22], vc->keyfile_buf32[22]);
|
||||
w[23] = u8add (w[23], vc->keyfile_buf32[23]);
|
||||
w[24] = u8add (w[24], vc->keyfile_buf32[24]);
|
||||
w[25] = u8add (w[25], vc->keyfile_buf32[25]);
|
||||
w[26] = u8add (w[26], vc->keyfile_buf32[26]);
|
||||
w[27] = u8add (w[27], vc->keyfile_buf32[27]);
|
||||
w[28] = u8add (w[28], vc->keyfile_buf32[28]);
|
||||
w[29] = u8add (w[29], vc->keyfile_buf32[29]);
|
||||
w[30] = u8add (w[30], vc->keyfile_buf32[30]);
|
||||
w[31] = u8add (w[31], vc->keyfile_buf32[31]);
|
||||
|
||||
return 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
w[ 0] = u8add (w[ 0], vc->keyfile_buf16[ 0]);
|
||||
w[ 1] = u8add (w[ 1], vc->keyfile_buf16[ 1]);
|
||||
w[ 2] = u8add (w[ 2], vc->keyfile_buf16[ 2]);
|
||||
w[ 3] = u8add (w[ 3], vc->keyfile_buf16[ 3]);
|
||||
w[ 4] = u8add (w[ 4], vc->keyfile_buf16[ 4]);
|
||||
w[ 5] = u8add (w[ 5], vc->keyfile_buf16[ 5]);
|
||||
w[ 6] = u8add (w[ 6], vc->keyfile_buf16[ 6]);
|
||||
w[ 7] = u8add (w[ 7], vc->keyfile_buf16[ 7]);
|
||||
w[ 8] = u8add (w[ 8], vc->keyfile_buf16[ 8]);
|
||||
w[ 9] = u8add (w[ 9], vc->keyfile_buf16[ 9]);
|
||||
w[10] = u8add (w[10], vc->keyfile_buf16[10]);
|
||||
w[11] = u8add (w[11], vc->keyfile_buf16[11]);
|
||||
w[12] = u8add (w[12], vc->keyfile_buf16[12]);
|
||||
w[13] = u8add (w[13], vc->keyfile_buf16[13]);
|
||||
w[14] = u8add (w[14], vc->keyfile_buf16[14]);
|
||||
w[15] = u8add (w[15], vc->keyfile_buf16[15]);
|
||||
|
||||
return 64;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef _INC_VERACRYPT_KEYFILE_H
|
||||
#define _INC_VERACRYPT_KEYFILE_H
|
||||
|
||||
DECLSPEC u32 u8add (const u32 a, const u32 b);
|
||||
DECLSPEC u32 hc_apply_keyfile_vc (u32 *w, const int pw_len, const GLOBAL_AS vc_t *vc);
|
||||
|
||||
#endif // _INC_VERACRYPT_KEYFILE_H
|
@ -1,455 +0,0 @@
|
||||
/**
|
||||
* 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_sha256.cl"
|
||||
#include "inc_cipher_aes.cl"
|
||||
#include "inc_cipher_aes-gcm.cl"
|
||||
#endif
|
||||
|
||||
#define COMPARE_S "inc_comp_single.cl"
|
||||
#define COMPARE_M "inc_comp_multi.cl"
|
||||
|
||||
typedef struct pbkdf2_sha256_tmp
|
||||
{
|
||||
u32 ipad[8];
|
||||
u32 opad[8];
|
||||
|
||||
u32 dgst[32];
|
||||
u32 out[32];
|
||||
|
||||
} pbkdf2_sha256_tmp_t;
|
||||
|
||||
typedef struct pbkdf2_sha256_aes_gcm
|
||||
{
|
||||
u32 salt_buf[64];
|
||||
u32 iv_buf[4];
|
||||
u32 iv_len;
|
||||
u32 ct_buf[16];
|
||||
u32 ct_len;
|
||||
|
||||
} pbkdf2_sha256_aes_gcm_t;
|
||||
|
||||
DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest)
|
||||
{
|
||||
digest[0] = ipad[0];
|
||||
digest[1] = ipad[1];
|
||||
digest[2] = ipad[2];
|
||||
digest[3] = ipad[3];
|
||||
digest[4] = ipad[4];
|
||||
digest[5] = ipad[5];
|
||||
digest[6] = ipad[6];
|
||||
digest[7] = ipad[7];
|
||||
|
||||
sha256_transform_vector (w0, w1, w2, w3, digest);
|
||||
|
||||
w0[0] = digest[0];
|
||||
w0[1] = digest[1];
|
||||
w0[2] = digest[2];
|
||||
w0[3] = digest[3];
|
||||
w1[0] = digest[4];
|
||||
w1[1] = digest[5];
|
||||
w1[2] = digest[6];
|
||||
w1[3] = digest[7];
|
||||
w2[0] = 0x80000000;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = (64 + 32) * 8;
|
||||
|
||||
digest[0] = opad[0];
|
||||
digest[1] = opad[1];
|
||||
digest[2] = opad[2];
|
||||
digest[3] = opad[3];
|
||||
digest[4] = opad[4];
|
||||
digest[5] = opad[5];
|
||||
digest[6] = opad[6];
|
||||
digest[7] = opad[7];
|
||||
|
||||
sha256_transform_vector (w0, w1, w2, w3, digest);
|
||||
}
|
||||
|
||||
KERNEL_FQ void m25500_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if (gid >= gid_max) return;
|
||||
|
||||
sha256_hmac_ctx_t sha256_hmac_ctx;
|
||||
|
||||
sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len);
|
||||
|
||||
tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0];
|
||||
tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1];
|
||||
tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2];
|
||||
tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3];
|
||||
tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4];
|
||||
tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5];
|
||||
tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6];
|
||||
tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7];
|
||||
|
||||
tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0];
|
||||
tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1];
|
||||
tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2];
|
||||
tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3];
|
||||
tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4];
|
||||
tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5];
|
||||
tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6];
|
||||
tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7];
|
||||
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET].salt_buf, salt_bufs[SALT_POS].salt_len);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 8; i += 8, j += 1)
|
||||
{
|
||||
sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx;
|
||||
|
||||
u32 w0[4];
|
||||
u32 w1[4];
|
||||
u32 w2[4];
|
||||
u32 w3[4];
|
||||
|
||||
w0[0] = j;
|
||||
w0[1] = 0;
|
||||
w0[2] = 0;
|
||||
w0[3] = 0;
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4);
|
||||
|
||||
sha256_hmac_final (&sha256_hmac_ctx2);
|
||||
|
||||
tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0];
|
||||
tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1];
|
||||
tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2];
|
||||
tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3];
|
||||
tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4];
|
||||
tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5];
|
||||
tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6];
|
||||
tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7];
|
||||
|
||||
tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0];
|
||||
tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1];
|
||||
tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2];
|
||||
tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3];
|
||||
tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4];
|
||||
tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5];
|
||||
tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6];
|
||||
tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7];
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m25500_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t))
|
||||
{
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if ((gid * VECT_SIZE) >= gid_max) return;
|
||||
|
||||
u32x ipad[8];
|
||||
u32x opad[8];
|
||||
|
||||
ipad[0] = packv (tmps, ipad, gid, 0);
|
||||
ipad[1] = packv (tmps, ipad, gid, 1);
|
||||
ipad[2] = packv (tmps, ipad, gid, 2);
|
||||
ipad[3] = packv (tmps, ipad, gid, 3);
|
||||
ipad[4] = packv (tmps, ipad, gid, 4);
|
||||
ipad[5] = packv (tmps, ipad, gid, 5);
|
||||
ipad[6] = packv (tmps, ipad, gid, 6);
|
||||
ipad[7] = packv (tmps, ipad, gid, 7);
|
||||
|
||||
opad[0] = packv (tmps, opad, gid, 0);
|
||||
opad[1] = packv (tmps, opad, gid, 1);
|
||||
opad[2] = packv (tmps, opad, gid, 2);
|
||||
opad[3] = packv (tmps, opad, gid, 3);
|
||||
opad[4] = packv (tmps, opad, gid, 4);
|
||||
opad[5] = packv (tmps, opad, gid, 5);
|
||||
opad[6] = packv (tmps, opad, gid, 6);
|
||||
opad[7] = packv (tmps, opad, gid, 7);
|
||||
|
||||
for (u32 i = 0; i < 8; i += 8)
|
||||
{
|
||||
u32x dgst[8];
|
||||
u32x out[8];
|
||||
|
||||
dgst[0] = packv (tmps, dgst, gid, i + 0);
|
||||
dgst[1] = packv (tmps, dgst, gid, i + 1);
|
||||
dgst[2] = packv (tmps, dgst, gid, i + 2);
|
||||
dgst[3] = packv (tmps, dgst, gid, i + 3);
|
||||
dgst[4] = packv (tmps, dgst, gid, i + 4);
|
||||
dgst[5] = packv (tmps, dgst, gid, i + 5);
|
||||
dgst[6] = packv (tmps, dgst, gid, i + 6);
|
||||
dgst[7] = packv (tmps, dgst, gid, i + 7);
|
||||
|
||||
out[0] = packv (tmps, out, gid, i + 0);
|
||||
out[1] = packv (tmps, out, gid, i + 1);
|
||||
out[2] = packv (tmps, out, gid, i + 2);
|
||||
out[3] = packv (tmps, out, gid, i + 3);
|
||||
out[4] = packv (tmps, out, gid, i + 4);
|
||||
out[5] = packv (tmps, out, gid, i + 5);
|
||||
out[6] = packv (tmps, out, gid, i + 6);
|
||||
out[7] = packv (tmps, out, gid, i + 7);
|
||||
|
||||
for (u32 j = 0; j < loop_cnt; j++)
|
||||
{
|
||||
u32x w0[4];
|
||||
u32x w1[4];
|
||||
u32x w2[4];
|
||||
u32x w3[4];
|
||||
|
||||
w0[0] = dgst[0];
|
||||
w0[1] = dgst[1];
|
||||
w0[2] = dgst[2];
|
||||
w0[3] = dgst[3];
|
||||
w1[0] = dgst[4];
|
||||
w1[1] = dgst[5];
|
||||
w1[2] = dgst[6];
|
||||
w1[3] = dgst[7];
|
||||
w2[0] = 0x80000000;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = (64 + 32) * 8;
|
||||
|
||||
hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst);
|
||||
|
||||
out[0] ^= dgst[0];
|
||||
out[1] ^= dgst[1];
|
||||
out[2] ^= dgst[2];
|
||||
out[3] ^= dgst[3];
|
||||
out[4] ^= dgst[4];
|
||||
out[5] ^= dgst[5];
|
||||
out[6] ^= dgst[6];
|
||||
out[7] ^= dgst[7];
|
||||
}
|
||||
|
||||
unpackv (tmps, dgst, gid, i + 0, dgst[0]);
|
||||
unpackv (tmps, dgst, gid, i + 1, dgst[1]);
|
||||
unpackv (tmps, dgst, gid, i + 2, dgst[2]);
|
||||
unpackv (tmps, dgst, gid, i + 3, dgst[3]);
|
||||
unpackv (tmps, dgst, gid, i + 4, dgst[4]);
|
||||
unpackv (tmps, dgst, gid, i + 5, dgst[5]);
|
||||
unpackv (tmps, dgst, gid, i + 6, dgst[6]);
|
||||
unpackv (tmps, dgst, gid, i + 7, dgst[7]);
|
||||
|
||||
unpackv (tmps, out, gid, i + 0, out[0]);
|
||||
unpackv (tmps, out, gid, i + 1, out[1]);
|
||||
unpackv (tmps, out, gid, i + 2, out[2]);
|
||||
unpackv (tmps, out, gid, i + 3, out[3]);
|
||||
unpackv (tmps, out, gid, i + 4, out[4]);
|
||||
unpackv (tmps, out, gid, i + 5, out[5]);
|
||||
unpackv (tmps, out, gid, i + 6, out[6]);
|
||||
unpackv (tmps, out, gid, i + 7, out[7]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m25500_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t))
|
||||
{
|
||||
const u64 gid = get_global_id (0);
|
||||
const u64 lid = get_local_id (0);
|
||||
const u64 lsz = get_local_size (0);
|
||||
|
||||
/**
|
||||
* aes shared
|
||||
*/
|
||||
|
||||
#ifdef REAL_SHM
|
||||
|
||||
LOCAL_VK u32 s_te0[256];
|
||||
LOCAL_VK u32 s_te1[256];
|
||||
LOCAL_VK u32 s_te2[256];
|
||||
LOCAL_VK u32 s_te3[256];
|
||||
LOCAL_VK u32 s_te4[256];
|
||||
|
||||
for (u32 i = lid; i < 256; i += lsz)
|
||||
{
|
||||
s_te0[i] = te0[i];
|
||||
s_te1[i] = te1[i];
|
||||
s_te2[i] = te2[i];
|
||||
s_te3[i] = te3[i];
|
||||
s_te4[i] = te4[i];
|
||||
}
|
||||
|
||||
SYNC_THREADS ();
|
||||
|
||||
#else
|
||||
|
||||
CONSTANT_AS u32a *s_te0 = te0;
|
||||
CONSTANT_AS u32a *s_te1 = te1;
|
||||
CONSTANT_AS u32a *s_te2 = te2;
|
||||
CONSTANT_AS u32a *s_te3 = te3;
|
||||
CONSTANT_AS u32a *s_te4 = te4;
|
||||
|
||||
#endif
|
||||
|
||||
if (gid >= gid_max) return;
|
||||
|
||||
// keys
|
||||
|
||||
u32 ukey[8];
|
||||
|
||||
ukey[0] = tmps[gid].out[0];
|
||||
ukey[1] = tmps[gid].out[1];
|
||||
ukey[2] = tmps[gid].out[2];
|
||||
ukey[3] = tmps[gid].out[3];
|
||||
ukey[4] = tmps[gid].out[4];
|
||||
ukey[5] = tmps[gid].out[5];
|
||||
ukey[6] = tmps[gid].out[6];
|
||||
ukey[7] = tmps[gid].out[7];
|
||||
|
||||
u32 key[60] = { 0 };
|
||||
|
||||
u32 subKey[4] = { 0 };
|
||||
|
||||
AES256_set_encrypt_key (key, ukey, s_te0, s_te1, s_te2, s_te3);
|
||||
|
||||
AES256_encrypt (key, subKey, subKey, s_te0, s_te1, s_te2, s_te3, s_te4);
|
||||
|
||||
// iv
|
||||
|
||||
const u32 iv[4] = {
|
||||
esalt_bufs[DIGESTS_OFFSET].iv_buf[0],
|
||||
esalt_bufs[DIGESTS_OFFSET].iv_buf[1],
|
||||
esalt_bufs[DIGESTS_OFFSET].iv_buf[2],
|
||||
esalt_bufs[DIGESTS_OFFSET].iv_buf[3]
|
||||
};
|
||||
|
||||
u32 J0[4] = {
|
||||
iv[0],
|
||||
iv[1],
|
||||
iv[2],
|
||||
0x00000001
|
||||
};
|
||||
|
||||
// ct
|
||||
|
||||
u32 enc[14] = { 0 };
|
||||
|
||||
enc[ 0] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 0];
|
||||
enc[ 1] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 1];
|
||||
enc[ 2] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 2];
|
||||
enc[ 3] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 3];
|
||||
enc[ 4] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 4];
|
||||
enc[ 5] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 5];
|
||||
enc[ 6] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 6];
|
||||
enc[ 7] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 7];
|
||||
enc[ 8] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 8];
|
||||
enc[ 9] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 9];
|
||||
enc[10] = esalt_bufs[DIGESTS_OFFSET].ct_buf[10];
|
||||
enc[11] = esalt_bufs[DIGESTS_OFFSET].ct_buf[11];
|
||||
enc[12] = esalt_bufs[DIGESTS_OFFSET].ct_buf[12];
|
||||
enc[13] = esalt_bufs[DIGESTS_OFFSET].ct_buf[13];
|
||||
|
||||
u32 enc_len = esalt_bufs[DIGESTS_OFFSET].ct_len;
|
||||
|
||||
u32 S[4] = { 0 };
|
||||
|
||||
u32 t[4] = { 0 };
|
||||
|
||||
S[0] ^= enc[0];
|
||||
S[1] ^= enc[1];
|
||||
S[2] ^= enc[2];
|
||||
S[3] ^= enc[3];
|
||||
|
||||
AES_GCM_gf_mult (S, subKey, t);
|
||||
|
||||
S[0] = t[0] ^ enc[4];
|
||||
S[1] = t[1] ^ enc[5];
|
||||
S[2] = t[2] ^ enc[6];
|
||||
S[3] = t[3] ^ enc[7];
|
||||
|
||||
AES_GCM_gf_mult (S, subKey, t);
|
||||
|
||||
S[0] = t[0] ^ enc[8];
|
||||
S[1] = t[1] ^ enc[9];
|
||||
S[2] = t[2] ^ enc[10];
|
||||
S[3] = t[3] ^ enc[11];
|
||||
|
||||
AES_GCM_gf_mult (S, subKey, t);
|
||||
|
||||
S[0] = t[0];
|
||||
S[1] = t[1];
|
||||
S[2] = t[2];
|
||||
S[3] = t[3];
|
||||
|
||||
t[0] = enc[12];
|
||||
t[1] = enc[13];
|
||||
t[2] = 0;
|
||||
t[3] = 0;
|
||||
|
||||
S[0] ^= t[0];
|
||||
S[1] ^= t[1];
|
||||
S[2] ^= t[2];
|
||||
S[3] ^= t[3];
|
||||
|
||||
AES_GCM_gf_mult (S, subKey, t);
|
||||
|
||||
S[0] = t[0];
|
||||
S[1] = t[1];
|
||||
S[2] = t[2];
|
||||
S[3] = t[3];
|
||||
|
||||
u32 len_buf[4] = { 0 };
|
||||
|
||||
len_buf[0] = 0;
|
||||
len_buf[3] = enc_len * 8;
|
||||
|
||||
S[0] ^= len_buf[0];
|
||||
S[1] ^= len_buf[1];
|
||||
S[2] ^= len_buf[2];
|
||||
S[3] ^= len_buf[3];
|
||||
|
||||
AES_GCM_gf_mult (S, subKey, t);
|
||||
|
||||
S[0] = t[0];
|
||||
S[1] = t[1];
|
||||
S[2] = t[2];
|
||||
S[3] = t[3];
|
||||
|
||||
J0[3] = 0x00000001;
|
||||
|
||||
u32 T[4] = { 0 };
|
||||
|
||||
AES256_encrypt (key, J0, T, s_te0, s_te1, s_te2, s_te3, s_te4);
|
||||
|
||||
/* compare tag */
|
||||
|
||||
const u32 r0 = T[0] ^ S[0];
|
||||
const u32 r1 = T[1] ^ S[1];
|
||||
const u32 r2 = T[2] ^ S[2];
|
||||
const u32 r3 = T[3] ^ S[3];
|
||||
|
||||
#define il_pos 0
|
||||
|
||||
#ifdef KERNEL_STATIC
|
||||
#include COMPARE_M
|
||||
#endif
|
||||
}
|
@ -0,0 +1,234 @@
|
||||
/**
|
||||
* 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"
|
||||
#endif
|
||||
|
||||
CONSTANT_VK u32a PE_CONST[256] =
|
||||
{
|
||||
0, 49345, 49537, 320, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088,
|
||||
52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265,
|
||||
55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, 8000, 56577, 7616, 7296, 56385,
|
||||
5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160,
|
||||
61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529,
|
||||
15360, 64705, 64897, 15680, 65281, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400,
|
||||
10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328,
|
||||
58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409,
|
||||
40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049,
|
||||
27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688,
|
||||
30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, 32000, 48577, 48257, 31808,
|
||||
46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121,
|
||||
20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568,
|
||||
39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977,
|
||||
34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905,
|
||||
17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448
|
||||
};
|
||||
|
||||
KERNEL_FQ void m26200_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]);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
u32 hash = 17;
|
||||
|
||||
u8 scratch[16] = { 0 };
|
||||
|
||||
u8 *input = (u8 *) tmp.i;
|
||||
|
||||
for (u32 i = 0; i < 5; i++)
|
||||
{
|
||||
for (u32 j = 0; j < tmp.pw_len; j++)
|
||||
{
|
||||
int idx = 15 - (j & 15);
|
||||
|
||||
scratch[idx] ^= input[j];
|
||||
}
|
||||
|
||||
for (u32 j = 0; j < 16; j += 2)
|
||||
{
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]);
|
||||
|
||||
scratch[j] = (unsigned char)( hash & 0xff);
|
||||
scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
u8 target[16] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
u8 lower = (scratch[i] & 0x7f);
|
||||
|
||||
if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z'))
|
||||
{
|
||||
target[i] = lower;
|
||||
}
|
||||
else
|
||||
{
|
||||
target[i] = (u8)((scratch[i] >> 4) + 0x61);
|
||||
}
|
||||
}
|
||||
|
||||
u32 *digest = (u32 *) target;
|
||||
|
||||
const u32 r0 = digest[DGST_R0];
|
||||
const u32 r1 = digest[DGST_R1];
|
||||
const u32 r2 = digest[DGST_R2];
|
||||
const u32 r3 = digest[DGST_R3];
|
||||
|
||||
COMPARE_M_SCALAR (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m26200_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]);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
u32 hash = 17;
|
||||
|
||||
u8 scratch[16] = { 0 };
|
||||
|
||||
u8 *input = (u8 *) tmp.i;
|
||||
|
||||
for (u32 i = 0; i < 5; i++)
|
||||
{
|
||||
for (u32 j = 0; j < tmp.pw_len; j++)
|
||||
{
|
||||
int idx = 15 - (j & 15);
|
||||
|
||||
scratch[idx] ^= input[j];
|
||||
}
|
||||
|
||||
for (u32 j = 0; j < 16; j += 2)
|
||||
{
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]);
|
||||
|
||||
scratch[j] = (unsigned char)( hash & 0xff);
|
||||
scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
u8 target[16] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
u8 lower = (scratch[i] & 0x7f);
|
||||
|
||||
if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z'))
|
||||
{
|
||||
target[i] = lower;
|
||||
}
|
||||
else
|
||||
{
|
||||
target[i] = (u8)((scratch[i] >> 4) + 0x61);
|
||||
}
|
||||
}
|
||||
|
||||
u32 *digest = (u32 *) target;
|
||||
|
||||
const u32 r0 = digest[DGST_R0];
|
||||
const u32 r1 = digest[DGST_R1];
|
||||
const u32 r2 = digest[DGST_R2];
|
||||
const u32 r3 = digest[DGST_R3];
|
||||
|
||||
COMPARE_S_SCALAR (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
@ -0,0 +1,367 @@
|
||||
/**
|
||||
* 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"
|
||||
#endif
|
||||
|
||||
CONSTANT_VK u32a PE_CONST[256] =
|
||||
{
|
||||
0, 49345, 49537, 320, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088,
|
||||
52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265,
|
||||
55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, 8000, 56577, 7616, 7296, 56385,
|
||||
5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160,
|
||||
61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529,
|
||||
15360, 64705, 64897, 15680, 65281, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400,
|
||||
10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328,
|
||||
58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409,
|
||||
40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049,
|
||||
27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688,
|
||||
30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, 32000, 48577, 48257, 31808,
|
||||
46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121,
|
||||
20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568,
|
||||
39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977,
|
||||
34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905,
|
||||
17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448
|
||||
};
|
||||
|
||||
KERNEL_FQ void m26200_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
|
||||
*/
|
||||
|
||||
u32 pw_buf0[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];
|
||||
|
||||
const u32 pw_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
|
||||
{
|
||||
const u32 pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32 pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32 wordl0[4] = { 0 };
|
||||
u32 wordl1[4] = { 0 };
|
||||
u32 wordl2[4] = { 0 };
|
||||
u32 wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
|
||||
u32 wordr0[4] = { 0 };
|
||||
u32 wordr1[4] = { 0 };
|
||||
u32 wordr2[4] = { 0 };
|
||||
u32 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);
|
||||
}
|
||||
|
||||
u32 w0[4];
|
||||
u32 w1[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];
|
||||
|
||||
u32 w[8] = { 0 };
|
||||
|
||||
w[ 0] = w0[0];
|
||||
w[ 1] = w0[1];
|
||||
w[ 2] = w0[2];
|
||||
w[ 3] = w0[3];
|
||||
w[ 4] = w1[0];
|
||||
w[ 5] = w1[1];
|
||||
w[ 6] = w1[2];
|
||||
w[ 7] = w1[3];
|
||||
|
||||
u32 hash = 17;
|
||||
|
||||
u8 scratch[16] = { 0 };
|
||||
|
||||
u8 *input = (u8 *) w;
|
||||
|
||||
for (u32 i = 0; i < 5; i++)
|
||||
{
|
||||
for (u32 j = 0; j < pw_len; j++)
|
||||
{
|
||||
int idx = 15 - (j & 15);
|
||||
|
||||
scratch[idx] ^= input[j];
|
||||
}
|
||||
|
||||
for (u32 j = 0; j < 16; j += 2)
|
||||
{
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]);
|
||||
|
||||
scratch[j] = (unsigned char)( hash & 0xff);
|
||||
scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
u8 target[16] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
u8 lower = (scratch[i] & 0x7f);
|
||||
|
||||
if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z'))
|
||||
{
|
||||
target[i] = lower;
|
||||
}
|
||||
else
|
||||
{
|
||||
target[i] = (u8)((scratch[i] >> 4) + 0x61);
|
||||
}
|
||||
}
|
||||
|
||||
u32 *digest = (u32 *) target;
|
||||
|
||||
const u32 r0 = digest[DGST_R0];
|
||||
const u32 r1 = digest[DGST_R1];
|
||||
const u32 r2 = digest[DGST_R2];
|
||||
const u32 r3 = digest[DGST_R3];
|
||||
|
||||
COMPARE_M_SIMD (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m26200_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
|
||||
*/
|
||||
|
||||
u32 pw_buf0[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];
|
||||
|
||||
const u32 pw_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
|
||||
{
|
||||
|
||||
const u32 pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32 pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32 wordl0[4] = { 0 };
|
||||
u32 wordl1[4] = { 0 };
|
||||
u32 wordl2[4] = { 0 };
|
||||
u32 wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
|
||||
u32 wordr0[4] = { 0 };
|
||||
u32 wordr1[4] = { 0 };
|
||||
u32 wordr2[4] = { 0 };
|
||||
u32 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);
|
||||
}
|
||||
|
||||
u32 w0[4];
|
||||
u32 w1[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];
|
||||
|
||||
u32 w[8] = { 0 };
|
||||
|
||||
w[ 0] = w0[0];
|
||||
w[ 1] = w0[1];
|
||||
w[ 2] = w0[2];
|
||||
w[ 3] = w0[3];
|
||||
w[ 4] = w1[0];
|
||||
w[ 5] = w1[1];
|
||||
w[ 6] = w1[2];
|
||||
w[ 7] = w1[3];
|
||||
|
||||
u32 hash = 17;
|
||||
|
||||
u8 scratch[16] = { 0 };
|
||||
|
||||
u8 *input = (u8 *) w;
|
||||
|
||||
for (u32 i = 0; i < 5; i++)
|
||||
{
|
||||
for (u32 j = 0; j < pw_len; j++)
|
||||
{
|
||||
int idx = 15 - (j & 15);
|
||||
|
||||
scratch[idx] ^= input[j];
|
||||
}
|
||||
|
||||
for (u32 j = 0; j < 16; j += 2)
|
||||
{
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]);
|
||||
|
||||
scratch[j] = (unsigned char)( hash & 0xff);
|
||||
scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
u8 target[16] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
u8 lower = (scratch[i] & 0x7f);
|
||||
|
||||
if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z'))
|
||||
{
|
||||
target[i] = lower;
|
||||
}
|
||||
else
|
||||
{
|
||||
target[i] = (u8)((scratch[i] >> 4) + 0x61);
|
||||
}
|
||||
}
|
||||
|
||||
u32 *digest = (u32 *) target;
|
||||
|
||||
const u32 r0 = digest[DGST_R0];
|
||||
const u32 r1 = digest[DGST_R1];
|
||||
const u32 r2 = digest[DGST_R2];
|
||||
const u32 r3 = digest[DGST_R3];
|
||||
|
||||
COMPARE_S_SIMD (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
@ -0,0 +1,254 @@
|
||||
/**
|
||||
* 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"
|
||||
#endif
|
||||
|
||||
CONSTANT_VK u32a PE_CONST[256] =
|
||||
{
|
||||
0, 49345, 49537, 320, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088,
|
||||
52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265,
|
||||
55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, 8000, 56577, 7616, 7296, 56385,
|
||||
5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160,
|
||||
61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529,
|
||||
15360, 64705, 64897, 15680, 65281, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400,
|
||||
10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328,
|
||||
58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409,
|
||||
40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049,
|
||||
27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688,
|
||||
30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, 32000, 48577, 48257, 31808,
|
||||
46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121,
|
||||
20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568,
|
||||
39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977,
|
||||
34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905,
|
||||
17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448
|
||||
};
|
||||
|
||||
KERNEL_FQ void m26200_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
|
||||
*/
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len;
|
||||
|
||||
u32 w[64] = { 0 };
|
||||
|
||||
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
|
||||
{
|
||||
w[idx] = pws[gid].i[idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
u32 w0l = w[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0 = w0l | w0r;
|
||||
|
||||
w[0] = w0;
|
||||
|
||||
u32 hash = 17;
|
||||
|
||||
u8 scratch[16] = { 0 };
|
||||
|
||||
u8 *input = (u8 *) w;
|
||||
|
||||
for (u32 i = 0; i < 5; i++)
|
||||
{
|
||||
for (u32 j = 0; j < pw_len; j++)
|
||||
{
|
||||
int idx = 15 - (j & 15);
|
||||
|
||||
scratch[idx] ^= input[j];
|
||||
}
|
||||
|
||||
for (u32 j = 0; j < 16; j += 2)
|
||||
{
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]);
|
||||
|
||||
scratch[j] = (unsigned char)( hash & 0xff);
|
||||
scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
u8 target[16] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
u8 lower = (scratch[i] & 0x7f);
|
||||
|
||||
if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z'))
|
||||
{
|
||||
target[i] = lower;
|
||||
}
|
||||
else
|
||||
{
|
||||
target[i] = (u8)((scratch[i] >> 4) + 0x61);
|
||||
}
|
||||
}
|
||||
|
||||
u32 *digest = (u32 *) target;
|
||||
|
||||
const u32 r0 = digest[DGST_R0];
|
||||
const u32 r1 = digest[DGST_R1];
|
||||
const u32 r2 = digest[DGST_R2];
|
||||
const u32 r3 = digest[DGST_R3];
|
||||
|
||||
COMPARE_M_SIMD (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m26200_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
|
||||
*/
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len;
|
||||
|
||||
u32 w[64] = { 0 };
|
||||
|
||||
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
|
||||
{
|
||||
w[idx] = pws[gid].i[idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
u32 w0l = w[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0 = w0l | w0r;
|
||||
|
||||
w[0] = w0;
|
||||
|
||||
u32 hash = 17;
|
||||
|
||||
u8 scratch[16] = { 0 };
|
||||
|
||||
u8 *input = (u8 *) w;
|
||||
|
||||
for (u32 i = 0; i < 5; i++)
|
||||
{
|
||||
for (u32 j = 0; j < pw_len; j++)
|
||||
{
|
||||
int idx = 15 - (j & 15);
|
||||
|
||||
scratch[idx] ^= input[j];
|
||||
}
|
||||
|
||||
for (u32 j = 0; j < 16; j += 2)
|
||||
{
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]);
|
||||
hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]);
|
||||
|
||||
scratch[j] = (unsigned char)( hash & 0xff);
|
||||
scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
u8 target[16] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
u8 lower = (scratch[i] & 0x7f);
|
||||
|
||||
if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z'))
|
||||
{
|
||||
target[i] = lower;
|
||||
}
|
||||
else
|
||||
{
|
||||
target[i] = (u8)((scratch[i] >> 4) + 0x61);
|
||||
}
|
||||
}
|
||||
|
||||
u32 *digest = (u32 *) target;
|
||||
|
||||
const u32 r0 = digest[DGST_R0];
|
||||
const u32 r1 = digest[DGST_R1];
|
||||
const u32 r2 = digest[DGST_R2];
|
||||
const u32 r3 = digest[DGST_R3];
|
||||
|
||||
COMPARE_S_SIMD (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
/**
|
||||
* 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_sha256.cl"
|
||||
#endif
|
||||
|
||||
KERNEL_FQ void m26300_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]);
|
||||
|
||||
sha256_ctx_t ctx0;
|
||||
|
||||
sha256_init (&ctx0);
|
||||
|
||||
sha256_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);
|
||||
|
||||
sha256_ctx_t ctx = ctx0;
|
||||
|
||||
sha256_update_swap (&ctx, tmp.i, tmp.pw_len);
|
||||
|
||||
/**
|
||||
* pepper
|
||||
*/
|
||||
|
||||
u32 p0[4];
|
||||
u32 p1[4];
|
||||
u32 p2[4];
|
||||
u32 p3[4];
|
||||
|
||||
p0[0] = hc_swap32_S (FORTIGATE_A);
|
||||
p0[1] = hc_swap32_S (FORTIGATE_B);
|
||||
p0[2] = hc_swap32_S (FORTIGATE_C);
|
||||
p0[3] = hc_swap32_S (FORTIGATE_D);
|
||||
p1[0] = hc_swap32_S (FORTIGATE_E);
|
||||
p1[1] = hc_swap32_S (FORTIGATE_F);
|
||||
p1[2] = 0;
|
||||
p1[3] = 0;
|
||||
p2[0] = 0;
|
||||
p2[1] = 0;
|
||||
p2[2] = 0;
|
||||
p2[3] = 0;
|
||||
p3[0] = 0;
|
||||
p3[1] = 0;
|
||||
p3[2] = 0;
|
||||
p3[3] = 0;
|
||||
|
||||
sha256_update_64 (&ctx, p0, p1, p2, p3, 24);
|
||||
|
||||
sha256_final (&ctx);
|
||||
|
||||
const u32 r0 = ctx.h[DGST_R0];
|
||||
const u32 r1 = ctx.h[DGST_R1];
|
||||
const u32 r2 = ctx.h[DGST_R2];
|
||||
const u32 r3 = ctx.h[DGST_R3];
|
||||
|
||||
COMPARE_M_SCALAR (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m26300_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]);
|
||||
|
||||
sha256_ctx_t ctx0;
|
||||
|
||||
sha256_init (&ctx0);
|
||||
|
||||
sha256_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);
|
||||
|
||||
sha256_ctx_t ctx = ctx0;
|
||||
|
||||
sha256_update_swap (&ctx, tmp.i, tmp.pw_len);
|
||||
|
||||
/**
|
||||
* pepper
|
||||
*/
|
||||
|
||||
u32 p0[4];
|
||||
u32 p1[4];
|
||||
u32 p2[4];
|
||||
u32 p3[4];
|
||||
|
||||
p0[0] = hc_swap32_S (FORTIGATE_A);
|
||||
p0[1] = hc_swap32_S (FORTIGATE_B);
|
||||
p0[2] = hc_swap32_S (FORTIGATE_C);
|
||||
p0[3] = hc_swap32_S (FORTIGATE_D);
|
||||
p1[0] = hc_swap32_S (FORTIGATE_E);
|
||||
p1[1] = hc_swap32_S (FORTIGATE_F);
|
||||
p1[2] = 0;
|
||||
p1[3] = 0;
|
||||
p2[0] = 0;
|
||||
p2[1] = 0;
|
||||
p2[2] = 0;
|
||||
p2[3] = 0;
|
||||
p3[0] = 0;
|
||||
p3[1] = 0;
|
||||
p3[2] = 0;
|
||||
p3[3] = 0;
|
||||
|
||||
sha256_update_64 (&ctx, p0, p1, p2, p3, 24);
|
||||
|
||||
sha256_final (&ctx);
|
||||
|
||||
const u32 r0 = ctx.h[DGST_R0];
|
||||
const u32 r1 = ctx.h[DGST_R1];
|
||||
const u32 r2 = ctx.h[DGST_R2];
|
||||
const u32 r3 = ctx.h[DGST_R3];
|
||||
|
||||
COMPARE_S_SCALAR (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
/**
|
||||
* 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_sha256.cl"
|
||||
#endif
|
||||
|
||||
KERNEL_FQ void m26300_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
|
||||
*/
|
||||
|
||||
sha256_ctx_t ctx0;
|
||||
|
||||
sha256_init (&ctx0);
|
||||
|
||||
sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
|
||||
|
||||
sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len);
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
|
||||
{
|
||||
sha256_ctx_t ctx = ctx0;
|
||||
|
||||
sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
|
||||
|
||||
/**
|
||||
* pepper
|
||||
*/
|
||||
|
||||
u32 p0[4];
|
||||
u32 p1[4];
|
||||
u32 p2[4];
|
||||
u32 p3[4];
|
||||
|
||||
p0[0] = hc_swap32_S (FORTIGATE_A);
|
||||
p0[1] = hc_swap32_S (FORTIGATE_B);
|
||||
p0[2] = hc_swap32_S (FORTIGATE_C);
|
||||
p0[3] = hc_swap32_S (FORTIGATE_D);
|
||||
p1[0] = hc_swap32_S (FORTIGATE_E);
|
||||
p1[1] = hc_swap32_S (FORTIGATE_F);
|
||||
p1[2] = 0;
|
||||
p1[3] = 0;
|
||||
p2[0] = 0;
|
||||
p2[1] = 0;
|
||||
p2[2] = 0;
|
||||
p2[3] = 0;
|
||||
p3[0] = 0;
|
||||
p3[1] = 0;
|
||||
p3[2] = 0;
|
||||
p3[3] = 0;
|
||||
|
||||
sha256_update_64 (&ctx, p0, p1, p2, p3, 24);
|
||||
|
||||
sha256_final (&ctx);
|
||||
|
||||
const u32 r0 = ctx.h[DGST_R0];
|
||||
const u32 r1 = ctx.h[DGST_R1];
|
||||
const u32 r2 = ctx.h[DGST_R2];
|
||||
const u32 r3 = ctx.h[DGST_R3];
|
||||
|
||||
COMPARE_M_SCALAR (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m26300_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
|
||||
*/
|
||||
|
||||
sha256_ctx_t ctx0;
|
||||
|
||||
sha256_init (&ctx0);
|
||||
|
||||
sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
|
||||
|
||||
sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len);
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
|
||||
{
|
||||
sha256_ctx_t ctx = ctx0;
|
||||
|
||||
sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
|
||||
|
||||
/**
|
||||
* pepper
|
||||
*/
|
||||
|
||||
u32 p0[4];
|
||||
u32 p1[4];
|
||||
u32 p2[4];
|
||||
u32 p3[4];
|
||||
|
||||
p0[0] = hc_swap32_S (FORTIGATE_A);
|
||||
p0[1] = hc_swap32_S (FORTIGATE_B);
|
||||
p0[2] = hc_swap32_S (FORTIGATE_C);
|
||||
p0[3] = hc_swap32_S (FORTIGATE_D);
|
||||
p1[0] = hc_swap32_S (FORTIGATE_E);
|
||||
p1[1] = hc_swap32_S (FORTIGATE_F);
|
||||
p1[2] = 0;
|
||||
p1[3] = 0;
|
||||
p2[0] = 0;
|
||||
p2[1] = 0;
|
||||
p2[2] = 0;
|
||||
p2[3] = 0;
|
||||
p3[0] = 0;
|
||||
p3[1] = 0;
|
||||
p3[2] = 0;
|
||||
p3[3] = 0;
|
||||
|
||||
sha256_update_64 (&ctx, p0, p1, p2, p3, 24);
|
||||
|
||||
sha256_final (&ctx);
|
||||
|
||||
const u32 r0 = ctx.h[DGST_R0];
|
||||
const u32 r1 = ctx.h[DGST_R1];
|
||||
const u32 r2 = ctx.h[DGST_R2];
|
||||
const u32 r3 = ctx.h[DGST_R3];
|
||||
|
||||
COMPARE_S_SCALAR (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
/**
|
||||
* 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_sha256.cl"
|
||||
#endif
|
||||
|
||||
KERNEL_FQ void m26300_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];
|
||||
}
|
||||
|
||||
sha256_ctx_t ctx0;
|
||||
|
||||
sha256_init (&ctx0);
|
||||
|
||||
sha256_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;
|
||||
|
||||
sha256_ctx_vector_t ctx;
|
||||
|
||||
sha256_init_vector_from_scalar (&ctx, &ctx0);
|
||||
|
||||
sha256_update_vector (&ctx, w, pw_len);
|
||||
|
||||
/**
|
||||
* pepper
|
||||
*/
|
||||
|
||||
u32x p0[4];
|
||||
u32x p1[4];
|
||||
u32x p2[4];
|
||||
u32x p3[4];
|
||||
|
||||
p0[0] = hc_swap32 (FORTIGATE_A);
|
||||
p0[1] = hc_swap32 (FORTIGATE_B);
|
||||
p0[2] = hc_swap32 (FORTIGATE_C);
|
||||
p0[3] = hc_swap32 (FORTIGATE_D);
|
||||
p1[0] = hc_swap32 (FORTIGATE_E);
|
||||
p1[1] = hc_swap32 (FORTIGATE_F);
|
||||
p1[2] = 0;
|
||||
p1[3] = 0;
|
||||
p2[0] = 0;
|
||||
p2[1] = 0;
|
||||
p2[2] = 0;
|
||||
p2[3] = 0;
|
||||
p3[0] = 0;
|
||||
p3[1] = 0;
|
||||
p3[2] = 0;
|
||||
p3[3] = 0;
|
||||
|
||||
sha256_update_vector_64 (&ctx, p0, p1, p2, p3, 24);
|
||||
|
||||
sha256_final_vector (&ctx);
|
||||
|
||||
const u32x r0 = ctx.h[DGST_R0];
|
||||
const u32x r1 = ctx.h[DGST_R1];
|
||||
const u32x r2 = ctx.h[DGST_R2];
|
||||
const u32x r3 = ctx.h[DGST_R3];
|
||||
|
||||
COMPARE_M_SIMD (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m26300_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];
|
||||
}
|
||||
|
||||
sha256_ctx_t ctx0;
|
||||
|
||||
sha256_init (&ctx0);
|
||||
|
||||
sha256_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;
|
||||
|
||||
sha256_ctx_vector_t ctx;
|
||||
|
||||
sha256_init_vector_from_scalar (&ctx, &ctx0);
|
||||
|
||||
sha256_update_vector (&ctx, w, pw_len);
|
||||
|
||||
/**
|
||||
* pepper
|
||||
*/
|
||||
|
||||
u32x p0[4];
|
||||
u32x p1[4];
|
||||
u32x p2[4];
|
||||
u32x p3[4];
|
||||
|
||||
p0[0] = hc_swap32 (FORTIGATE_A);
|
||||
p0[1] = hc_swap32 (FORTIGATE_B);
|
||||
p0[2] = hc_swap32 (FORTIGATE_C);
|
||||
p0[3] = hc_swap32 (FORTIGATE_D);
|
||||
p1[0] = hc_swap32 (FORTIGATE_E);
|
||||
p1[1] = hc_swap32 (FORTIGATE_F);
|
||||
p1[2] = 0;
|
||||
p1[3] = 0;
|
||||
p2[0] = 0;
|
||||
p2[1] = 0;
|
||||
p2[2] = 0;
|
||||
p2[3] = 0;
|
||||
p3[0] = 0;
|
||||
p3[1] = 0;
|
||||
p3[2] = 0;
|
||||
p3[3] = 0;
|
||||
|
||||
sha256_update_vector_64 (&ctx, p0, p1, p2, p3, 24);
|
||||
|
||||
sha256_final_vector (&ctx);
|
||||
|
||||
const u32x r0 = ctx.h[DGST_R0];
|
||||
const u32x r1 = ctx.h[DGST_R1];
|
||||
const u32x r2 = ctx.h[DGST_R2];
|
||||
const u32x r3 = ctx.h[DGST_R3];
|
||||
|
||||
COMPARE_S_SIMD (r0, r1, r2, r3);
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef _EXT_IOKIT_H
|
||||
#define _EXT_IOKIT_H
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
// Apple SMC Keys
|
||||
#define HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT "SGHT"
|
||||
#define HM_IOKIT_SMC_CPU_PROXIMITY "TC0P"
|
||||
#define HM_IOKIT_SMC_GPU_PROXIMITY "TG0P"
|
||||
#define HM_IOKIT_SMC_PECI_GPU "TCGC"
|
||||
|
||||
#define KERNEL_INDEX_SMC 2
|
||||
|
||||
#define DATATYPE_FPE2 "fpe2"
|
||||
#define DATATYPE_FLT "flt "
|
||||
#define DATATYPE_UINT8 "ui8 "
|
||||
#define DATATYPE_UINT16 "ui16"
|
||||
#define DATATYPE_UINT32 "ui32"
|
||||
#define DATATYPE_SP78 "sp78"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SMC_CMD_READ_BYTES = 5,
|
||||
SMC_CMD_WRITE_BYTES = 6,
|
||||
SMC_CMD_READ_INDEX = 8,
|
||||
SMC_CMD_READ_KEYINFO = 9,
|
||||
SMC_CMD_READ_PLIMIT = 11,
|
||||
SMC_CMD_READ_VERS = 12
|
||||
|
||||
} SMCCommands_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char major;
|
||||
char minor;
|
||||
char build;
|
||||
char reserved[1];
|
||||
UInt16 release;
|
||||
|
||||
} SMCKeyData_vers_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt16 version;
|
||||
UInt16 length;
|
||||
UInt32 cpuPLimit;
|
||||
UInt32 gpuPLimit;
|
||||
UInt32 memPLimit;
|
||||
|
||||
} SMCKeyData_pLimitData_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt32 dataSize;
|
||||
UInt32 dataType;
|
||||
|
||||
char dataAttributes;
|
||||
|
||||
} SMCKeyData_keyInfo_t;
|
||||
|
||||
typedef char SMCBytes_t[32];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt32 key;
|
||||
|
||||
SMCKeyData_vers_t vers;
|
||||
SMCKeyData_pLimitData_t pLimitData;
|
||||
SMCKeyData_keyInfo_t keyInfo;
|
||||
|
||||
char result;
|
||||
char status;
|
||||
char data8;
|
||||
|
||||
UInt32 data32;
|
||||
SMCBytes_t bytes;
|
||||
|
||||
} SMCKeyData_t;
|
||||
|
||||
typedef char UInt32Char_t[5];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt32Char_t key;
|
||||
UInt32 dataSize;
|
||||
UInt32Char_t dataType;
|
||||
SMCBytes_t bytes;
|
||||
|
||||
} SMCVal_t;
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
typedef int HM_ADAPTER_IOKIT;
|
||||
|
||||
typedef void *IOKIT_LIB;
|
||||
|
||||
typedef struct hm_iokit_lib
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
io_connect_t conn;
|
||||
#endif // __APPLE__
|
||||
|
||||
} hm_iokit_lib_t;
|
||||
|
||||
typedef hm_iokit_lib_t IOKIT_PTR;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
UInt32 hm_IOKIT_strtoul (char *str, int size, int base);
|
||||
void hm_IOKIT_ultostr (char *str, UInt32 val);
|
||||
kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn);
|
||||
kern_return_t hm_IOKIT_SMCClose (io_connect_t conn);
|
||||
kern_return_t hm_IOKIT_SMCCall (int index, SMCKeyData_t *inData, SMCKeyData_t *outData, io_connect_t conn);
|
||||
kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t conn);
|
||||
int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx);
|
||||
int hm_IOKIT_SMCGetTemperature (void *hashcat_ctx, char *key, double *temp);
|
||||
bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret);
|
||||
int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf);
|
||||
bool iokit_init (void *hashcat_ctx);
|
||||
bool iokit_close (void *hashcat_ctx);
|
||||
#endif // __APPLE__
|
||||
|
||||
#endif // _EXT_IOKIT_H
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "emu_general.h"
|
||||
|
||||
#include "inc_truecrypt_crc32.cl"
|
||||
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "emu_general.h"
|
||||
|
||||
#include "inc_truecrypt_keyfile.cl"
|
||||
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "emu_general.h"
|
||||
|
||||
#include "inc_truecrypt_xts.cl"
|
||||
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "emu_general.h"
|
||||
|
||||
#include "inc_veracrypt_xts.cl"
|
||||
|
@ -0,0 +1,305 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "memory.h"
|
||||
#include "shared.h"
|
||||
#include "event.h"
|
||||
#include "ext_iokit.h"
|
||||
|
||||
#if defined (__APPLE__)
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
UInt32 hm_IOKIT_strtoul (char *str, int size, int base)
|
||||
{
|
||||
int i;
|
||||
|
||||
UInt32 total = 0;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (base == 16)
|
||||
{
|
||||
total += str[i] << (size - 1 - i) * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
total += (unsigned char)(str[i] << (size - 1 - i) * 8);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
void hm_IOKIT_ultostr (char *str, UInt32 val)
|
||||
{
|
||||
str[0] = '\0';
|
||||
|
||||
sprintf (str, "%c%c%c%c", (unsigned int)(val >> 24), (unsigned int)(val >> 16), (unsigned int)(val >> 8), (unsigned int)(val));
|
||||
}
|
||||
|
||||
kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn)
|
||||
{
|
||||
kern_return_t result;
|
||||
io_iterator_t iterator;
|
||||
io_object_t device;
|
||||
|
||||
CFMutableDictionaryRef matchingDictionary = IOServiceMatching ("AppleSMC");
|
||||
|
||||
result = IOServiceGetMatchingServices (kIOMasterPortDefault, matchingDictionary, &iterator);
|
||||
|
||||
if (result != kIOReturnSuccess)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "IOServiceGetMatchingServices(): %08x", result);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
device = IOIteratorNext (iterator);
|
||||
|
||||
IOObjectRelease (iterator);
|
||||
|
||||
if (device == 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "hm_IOKIT_SMCOpen(): no SMC found.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
result = IOServiceOpen (device, mach_task_self(), 0, conn);
|
||||
|
||||
IOObjectRelease (device);
|
||||
|
||||
if (result != kIOReturnSuccess)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "IOServiceOpen(): %08x", result);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return kIOReturnSuccess;
|
||||
}
|
||||
|
||||
kern_return_t hm_IOKIT_SMCClose (io_connect_t conn)
|
||||
{
|
||||
return IOServiceClose (conn);
|
||||
}
|
||||
|
||||
kern_return_t hm_IOKIT_SMCCall (int index, SMCKeyData_t *inData, SMCKeyData_t *outData, io_connect_t conn)
|
||||
{
|
||||
size_t inDataSize = sizeof (SMCKeyData_t);
|
||||
size_t outDataSize = sizeof (SMCKeyData_t);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_5
|
||||
return IOConnectCallStructMethod (conn, index, inData, inDataSize, outData, &outDataSize);
|
||||
#else
|
||||
return IOConnectMethodStructureIStructureO (conn, index, inDataSize, &outDataSize, inData, outData);
|
||||
#endif
|
||||
}
|
||||
|
||||
kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t conn)
|
||||
{
|
||||
SMCKeyData_t inData;
|
||||
SMCKeyData_t outData;
|
||||
|
||||
memset (&inData, 0, sizeof (SMCKeyData_t));
|
||||
memset (&outData, 0, sizeof (SMCKeyData_t));
|
||||
memset (val, 0, sizeof (SMCVal_t));
|
||||
|
||||
inData.key = hm_IOKIT_strtoul (key, 4, 16);
|
||||
|
||||
inData.data8 = SMC_CMD_READ_KEYINFO;
|
||||
|
||||
if (hm_IOKIT_SMCCall (KERNEL_INDEX_SMC, &inData, &outData, conn) != kIOReturnSuccess) return 1;
|
||||
|
||||
val->dataSize = outData.keyInfo.dataSize;
|
||||
|
||||
hm_IOKIT_ultostr (val->dataType, outData.keyInfo.dataType);
|
||||
|
||||
inData.keyInfo.dataSize = val->dataSize;
|
||||
|
||||
inData.data8 = SMC_CMD_READ_BYTES;
|
||||
|
||||
if (hm_IOKIT_SMCCall (KERNEL_INDEX_SMC, &inData, &outData, conn) != kIOReturnSuccess) return 1;
|
||||
|
||||
memcpy(val->bytes, outData.bytes, sizeof(outData.bytes));
|
||||
|
||||
return kIOReturnSuccess;
|
||||
}
|
||||
|
||||
int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx)
|
||||
{
|
||||
hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx;
|
||||
|
||||
IOKIT_PTR *iokit = hwmon_ctx->hm_iokit;
|
||||
|
||||
SMCVal_t val;
|
||||
|
||||
memset (&val, 0, sizeof (SMCVal_t));
|
||||
|
||||
if (hm_IOKIT_SMCReadKey (HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT, &val, iokit->conn) == kIOReturnSuccess)
|
||||
{
|
||||
int alarm = -1;
|
||||
|
||||
if (val.dataSize > 0)
|
||||
{
|
||||
if (strcmp(val.dataType, DATATYPE_UINT8) == 0)
|
||||
{
|
||||
alarm = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10);
|
||||
}
|
||||
}
|
||||
|
||||
return alarm;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int hm_IOKIT_SMCGetTemperature (void *hashcat_ctx, char *key, double *temp)
|
||||
{
|
||||
hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx;
|
||||
|
||||
IOKIT_PTR *iokit = hwmon_ctx->hm_iokit;
|
||||
|
||||
SMCVal_t val;
|
||||
|
||||
memset (&val, 0, sizeof (SMCVal_t));
|
||||
|
||||
if (hm_IOKIT_SMCReadKey (key, &val, iokit->conn) == kIOReturnSuccess)
|
||||
{
|
||||
if (val.dataSize > 0)
|
||||
{
|
||||
if (strcmp(val.dataType, DATATYPE_SP78) == 0)
|
||||
{
|
||||
// convert sp78 value to temperature
|
||||
int intValue = val.bytes[0] * 256 + (unsigned char)val.bytes[1];
|
||||
|
||||
*temp = (intValue / 256.0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read failed
|
||||
|
||||
*temp = 0.0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret)
|
||||
{
|
||||
SMCVal_t val;
|
||||
|
||||
memset (&val, 0, sizeof (SMCVal_t));
|
||||
|
||||
if (hm_IOKIT_SMCReadKey (key, &val, conn) == kIOReturnSuccess)
|
||||
{
|
||||
if (val.dataSize > 0)
|
||||
{
|
||||
if (strcmp(val.dataType, DATATYPE_FLT) == 0)
|
||||
{
|
||||
*ret = *(float *) val.bytes;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcmp(val.dataType, DATATYPE_FPE2) == 0)
|
||||
{
|
||||
// convert fpe2 value to RPM
|
||||
*ret = ntohs (*(UInt16*)val.bytes) / 4.0;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read failed
|
||||
*ret = -1.f;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf)
|
||||
{
|
||||
hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx;
|
||||
|
||||
IOKIT_PTR *iokit = hwmon_ctx->hm_iokit;
|
||||
|
||||
SMCVal_t val;
|
||||
|
||||
UInt32Char_t key;
|
||||
|
||||
memset (&val, 0, sizeof (SMCVal_t));
|
||||
|
||||
if (hm_IOKIT_SMCReadKey ("FNum", &val, iokit->conn) == kIOReturnSuccess)
|
||||
{
|
||||
int totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10);
|
||||
|
||||
if (totalFans <= 0) return -1;
|
||||
|
||||
char tmp_buf[16];
|
||||
|
||||
for (int i = 0; i < totalFans; i++)
|
||||
{
|
||||
int fan_speed = 0;
|
||||
float actual_speed = 0.0f;
|
||||
float maximum_speed = 0.0f;
|
||||
|
||||
memset (&key, 0, sizeof (UInt32Char_t));
|
||||
sprintf (key, "F%dAc", i);
|
||||
hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &actual_speed);
|
||||
if (actual_speed < 0.f) continue;
|
||||
|
||||
memset (&key, 0, sizeof (UInt32Char_t));
|
||||
sprintf (key, "F%dMx", i);
|
||||
hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &maximum_speed);
|
||||
if (maximum_speed < 0.f) continue;
|
||||
|
||||
fan_speed = (actual_speed / maximum_speed) * 100.f;
|
||||
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
snprintf (tmp_buf, sizeof (tmp_buf) - 1, "Fan%d: %d%%, ", i, fan_speed);
|
||||
strncat (fan_speed_buf, tmp_buf, strlen (tmp_buf));
|
||||
}
|
||||
|
||||
// remove last two bytes
|
||||
size_t out_len = strlen (fan_speed_buf);
|
||||
if (out_len > 2) fan_speed_buf[out_len-2] = '\0';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool iokit_init (void *hashcat_ctx)
|
||||
{
|
||||
hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx;
|
||||
|
||||
IOKIT_PTR *iokit = hwmon_ctx->hm_iokit;
|
||||
|
||||
memset (iokit, 0, sizeof (IOKIT_PTR));
|
||||
|
||||
if (hm_IOKIT_SMCOpen (hashcat_ctx, &iokit->conn) == kIOReturnSuccess) return true;
|
||||
|
||||
hcfree (hwmon_ctx->hm_iokit);
|
||||
|
||||
hwmon_ctx->hm_iokit = NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool iokit_close (void *hashcat_ctx)
|
||||
{
|
||||
hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx;
|
||||
|
||||
IOKIT_PTR *iokit = hwmon_ctx->hm_iokit;
|
||||
|
||||
hm_IOKIT_SMCClose (iokit->conn);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // __APPLE__
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue