2015-12-04 15:47:52 +01:00
|
|
|
/**
|
2016-09-11 22:20:15 +02:00
|
|
|
* Author......: See docs/credits.txt
|
2015-12-04 15:47:52 +01:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2019-03-22 15:16:25 +01:00
|
|
|
#ifdef KERNEL_STATIC
|
2022-02-07 09:57:08 +01:00
|
|
|
#include M2S(INCLUDE_PATH/inc_vendor.h)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_types.h)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_platform.cl)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_common.cl)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_hash_sha256.cl)
|
2019-03-22 15:16:25 +01:00
|
|
|
#endif
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2019-03-08 11:14:33 +01:00
|
|
|
typedef struct seven_zip_tmp
|
|
|
|
{
|
|
|
|
u32 h[8];
|
|
|
|
|
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
|
|
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
} seven_zip_tmp_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
u32 ukey[8];
|
|
|
|
|
|
|
|
u32 hook_success;
|
|
|
|
|
|
|
|
} seven_zip_hook_t;
|
|
|
|
|
2022-02-04 19:54:00 +01:00
|
|
|
DECLSPEC void memcat8c_be (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 len, const u32 append, PRIVATE_AS u32 *digest)
|
2015-12-04 15:47:52 +01:00
|
|
|
{
|
2019-03-03 19:18:56 +01:00
|
|
|
const u32 func_len = len & 63;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2019-04-05 22:25:28 +02:00
|
|
|
//const u32 mod = func_len & 3;
|
2019-03-03 19:18:56 +01:00
|
|
|
const u32 div = func_len / 4;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2015-12-15 12:04:22 +01:00
|
|
|
u32 tmp0;
|
|
|
|
u32 tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2021-07-26 07:59:12 +02:00
|
|
|
#if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 0) || defined IS_GENERIC
|
2019-03-01 14:49:00 +01:00
|
|
|
tmp0 = hc_bytealign_be (0, append, func_len);
|
|
|
|
tmp1 = hc_bytealign_be (append, 0, func_len);
|
|
|
|
#endif
|
|
|
|
|
2021-07-26 07:59:12 +02:00
|
|
|
#if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 1) || defined IS_NV
|
|
|
|
|
|
|
|
#if defined IS_NV
|
2017-07-07 16:48:18 +02:00
|
|
|
const int selector = (0x76543210 >> ((func_len & 3) * 4)) & 0xffff;
|
2021-07-26 07:59:12 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (defined IS_AMD || defined IS_HIP)
|
|
|
|
const int selector = l32_from_64_S (0x0706050403020100UL >> ((func_len & 3) * 8));
|
|
|
|
#endif
|
2015-12-15 16:50:21 +01:00
|
|
|
|
2018-07-22 12:20:20 +02:00
|
|
|
tmp0 = hc_byte_perm (append, 0, selector);
|
|
|
|
tmp1 = hc_byte_perm (0, append, selector);
|
2015-12-15 16:50:21 +01:00
|
|
|
#endif
|
|
|
|
|
2016-05-08 14:39:44 +02:00
|
|
|
u32 carry = 0;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
|
|
|
switch (div)
|
|
|
|
{
|
2017-07-07 16:48:18 +02:00
|
|
|
case 0: w0[0] |= tmp0;
|
|
|
|
w0[1] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 1: w0[1] |= tmp0;
|
|
|
|
w0[2] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 2: w0[2] |= tmp0;
|
|
|
|
w0[3] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 3: w0[3] |= tmp0;
|
|
|
|
w1[0] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 4: w1[0] |= tmp0;
|
|
|
|
w1[1] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 5: w1[1] |= tmp0;
|
|
|
|
w1[2] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 6: w1[2] |= tmp0;
|
|
|
|
w1[3] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 7: w1[3] |= tmp0;
|
|
|
|
w2[0] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 8: w2[0] |= tmp0;
|
|
|
|
w2[1] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 9: w2[1] |= tmp0;
|
|
|
|
w2[2] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 10: w2[2] |= tmp0;
|
|
|
|
w2[3] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 11: w2[3] |= tmp0;
|
|
|
|
w3[0] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 12: w3[0] |= tmp0;
|
|
|
|
w3[1] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 13: w3[1] |= tmp0;
|
|
|
|
w3[2] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 14: w3[2] |= tmp0;
|
|
|
|
w3[3] = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
2017-07-07 16:48:18 +02:00
|
|
|
case 15: w3[3] |= tmp0;
|
|
|
|
carry = tmp1;
|
2015-12-04 15:47:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-07-07 16:48:18 +02:00
|
|
|
const u32 new_len = func_len + 8;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
|
|
|
if (new_len >= 64)
|
|
|
|
{
|
2017-07-07 16:48:18 +02:00
|
|
|
sha256_transform (w0, w1, w2, w3, digest);
|
|
|
|
|
|
|
|
w0[0] = carry;
|
|
|
|
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;
|
2015-12-04 15:47:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m11600_init (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t))
|
2015-12-04 15:47:52 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2017-08-19 16:39:22 +02:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2022-01-04 22:57:26 +01:00
|
|
|
if (gid >= GID_CNT) return;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* context save
|
|
|
|
*/
|
|
|
|
|
2017-07-07 16:48:18 +02:00
|
|
|
sha256_ctx_t ctx;
|
|
|
|
|
|
|
|
sha256_init (&ctx);
|
|
|
|
|
|
|
|
tmps[gid].h[0] = ctx.h[0];
|
|
|
|
tmps[gid].h[1] = ctx.h[1];
|
|
|
|
tmps[gid].h[2] = ctx.h[2];
|
|
|
|
tmps[gid].h[3] = ctx.h[3];
|
|
|
|
tmps[gid].h[4] = ctx.h[4];
|
|
|
|
tmps[gid].h[5] = ctx.h[5];
|
|
|
|
tmps[gid].h[6] = ctx.h[6];
|
|
|
|
tmps[gid].h[7] = ctx.h[7];
|
|
|
|
|
|
|
|
tmps[gid].w0[0] = ctx.w0[0];
|
|
|
|
tmps[gid].w0[1] = ctx.w0[1];
|
|
|
|
tmps[gid].w0[2] = ctx.w0[2];
|
|
|
|
tmps[gid].w0[3] = ctx.w0[3];
|
|
|
|
tmps[gid].w1[0] = ctx.w1[0];
|
|
|
|
tmps[gid].w1[1] = ctx.w1[1];
|
|
|
|
tmps[gid].w1[2] = ctx.w1[2];
|
|
|
|
tmps[gid].w1[3] = ctx.w1[3];
|
|
|
|
tmps[gid].w2[0] = ctx.w2[0];
|
|
|
|
tmps[gid].w2[1] = ctx.w2[1];
|
|
|
|
tmps[gid].w2[2] = ctx.w2[2];
|
|
|
|
tmps[gid].w2[3] = ctx.w2[3];
|
|
|
|
tmps[gid].w3[0] = ctx.w3[0];
|
|
|
|
tmps[gid].w3[1] = ctx.w3[1];
|
|
|
|
tmps[gid].w3[2] = ctx.w3[2];
|
|
|
|
tmps[gid].w3[3] = ctx.w3[3];
|
|
|
|
|
|
|
|
tmps[gid].len = ctx.len;
|
2015-12-04 15:47:52 +01:00
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m11600_loop (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t))
|
2015-12-04 15:47:52 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2017-08-19 16:39:22 +02:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2022-01-04 22:57:26 +01:00
|
|
|
if (gid >= GID_CNT) return;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2019-02-26 21:20:07 +01:00
|
|
|
const u32 pw_len = pws[gid].pw_len;
|
2017-07-07 16:48:18 +02:00
|
|
|
|
|
|
|
u32 w[64] = { 0 };
|
|
|
|
|
2019-04-05 22:25:28 +02:00
|
|
|
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
|
2017-07-07 16:48:18 +02:00
|
|
|
{
|
|
|
|
w[idx] = pws[gid].i[idx];
|
|
|
|
}
|
2016-05-08 15:33:32 +02:00
|
|
|
|
2015-12-04 15:47:52 +01:00
|
|
|
/**
|
|
|
|
* context load
|
|
|
|
*/
|
|
|
|
|
2017-07-07 16:48:18 +02:00
|
|
|
sha256_ctx_t ctx;
|
|
|
|
|
|
|
|
ctx.h[0] = tmps[gid].h[0];
|
|
|
|
ctx.h[1] = tmps[gid].h[1];
|
|
|
|
ctx.h[2] = tmps[gid].h[2];
|
|
|
|
ctx.h[3] = tmps[gid].h[3];
|
|
|
|
ctx.h[4] = tmps[gid].h[4];
|
|
|
|
ctx.h[5] = tmps[gid].h[5];
|
|
|
|
ctx.h[6] = tmps[gid].h[6];
|
|
|
|
ctx.h[7] = tmps[gid].h[7];
|
|
|
|
|
|
|
|
ctx.w0[0] = tmps[gid].w0[0];
|
|
|
|
ctx.w0[1] = tmps[gid].w0[1];
|
|
|
|
ctx.w0[2] = tmps[gid].w0[2];
|
|
|
|
ctx.w0[3] = tmps[gid].w0[3];
|
|
|
|
ctx.w1[0] = tmps[gid].w1[0];
|
|
|
|
ctx.w1[1] = tmps[gid].w1[1];
|
|
|
|
ctx.w1[2] = tmps[gid].w1[2];
|
|
|
|
ctx.w1[3] = tmps[gid].w1[3];
|
|
|
|
ctx.w2[0] = tmps[gid].w2[0];
|
|
|
|
ctx.w2[1] = tmps[gid].w2[1];
|
|
|
|
ctx.w2[2] = tmps[gid].w2[2];
|
|
|
|
ctx.w2[3] = tmps[gid].w2[3];
|
|
|
|
ctx.w3[0] = tmps[gid].w3[0];
|
|
|
|
ctx.w3[1] = tmps[gid].w3[1];
|
|
|
|
ctx.w3[2] = tmps[gid].w3[2];
|
|
|
|
ctx.w3[3] = tmps[gid].w3[3];
|
|
|
|
|
|
|
|
ctx.len = tmps[gid].len;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* base
|
|
|
|
*/
|
|
|
|
|
2022-01-04 18:07:18 +01:00
|
|
|
for (u32 i = 0, j = LOOP_POS; i < LOOP_CNT; i++, j++)
|
2015-12-04 15:47:52 +01:00
|
|
|
{
|
2017-07-07 16:48:18 +02:00
|
|
|
sha256_update_utf16le_swap (&ctx, w, pw_len);
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
memcat8c_be (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.len, hc_swap32_S (j), ctx.h);
|
2016-05-08 15:33:32 +02:00
|
|
|
|
2017-07-07 16:48:18 +02:00
|
|
|
ctx.len += 8;
|
2015-12-04 15:47:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* context save
|
|
|
|
*/
|
|
|
|
|
2017-07-07 16:48:18 +02:00
|
|
|
tmps[gid].h[0] = ctx.h[0];
|
|
|
|
tmps[gid].h[1] = ctx.h[1];
|
|
|
|
tmps[gid].h[2] = ctx.h[2];
|
|
|
|
tmps[gid].h[3] = ctx.h[3];
|
|
|
|
tmps[gid].h[4] = ctx.h[4];
|
|
|
|
tmps[gid].h[5] = ctx.h[5];
|
|
|
|
tmps[gid].h[6] = ctx.h[6];
|
|
|
|
tmps[gid].h[7] = ctx.h[7];
|
|
|
|
|
|
|
|
tmps[gid].w0[0] = ctx.w0[0];
|
|
|
|
tmps[gid].w0[1] = ctx.w0[1];
|
|
|
|
tmps[gid].w0[2] = ctx.w0[2];
|
|
|
|
tmps[gid].w0[3] = ctx.w0[3];
|
|
|
|
tmps[gid].w1[0] = ctx.w1[0];
|
|
|
|
tmps[gid].w1[1] = ctx.w1[1];
|
|
|
|
tmps[gid].w1[2] = ctx.w1[2];
|
|
|
|
tmps[gid].w1[3] = ctx.w1[3];
|
|
|
|
tmps[gid].w2[0] = ctx.w2[0];
|
|
|
|
tmps[gid].w2[1] = ctx.w2[1];
|
|
|
|
tmps[gid].w2[2] = ctx.w2[2];
|
|
|
|
tmps[gid].w2[3] = ctx.w2[3];
|
|
|
|
tmps[gid].w3[0] = ctx.w3[0];
|
|
|
|
tmps[gid].w3[1] = ctx.w3[1];
|
|
|
|
tmps[gid].w3[2] = ctx.w3[2];
|
|
|
|
tmps[gid].w3[3] = ctx.w3[3];
|
|
|
|
|
|
|
|
tmps[gid].len = ctx.len;
|
2015-12-04 15:47:52 +01:00
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m11600_hook23 (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t))
|
2015-12-04 15:47:52 +01:00
|
|
|
{
|
2017-08-19 16:39:22 +02:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2022-01-04 22:57:26 +01:00
|
|
|
if (gid >= GID_CNT) return;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* context load
|
|
|
|
*/
|
|
|
|
|
2020-01-26 18:38:47 +01:00
|
|
|
u32 h[8];
|
2017-07-07 16:48:18 +02:00
|
|
|
|
2020-01-26 18:38:47 +01:00
|
|
|
h[0] = tmps[gid].h[0];
|
|
|
|
h[1] = tmps[gid].h[1];
|
|
|
|
h[2] = tmps[gid].h[2];
|
|
|
|
h[3] = tmps[gid].h[3];
|
|
|
|
h[4] = tmps[gid].h[4];
|
|
|
|
h[5] = tmps[gid].h[5];
|
|
|
|
h[6] = tmps[gid].h[6];
|
|
|
|
h[7] = tmps[gid].h[7];
|
2017-07-07 16:48:18 +02:00
|
|
|
|
2020-01-26 18:38:47 +01:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
2017-07-07 16:48:18 +02:00
|
|
|
|
2020-01-26 18:38:47 +01:00
|
|
|
w0[0] = 0x80000000;
|
|
|
|
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] = tmps[gid].len * 8;
|
|
|
|
|
|
|
|
sha256_transform (w0, w1, w2, w3, h);
|
|
|
|
|
|
|
|
hooks[gid].ukey[0] = hc_swap32_S (h[0]);
|
|
|
|
hooks[gid].ukey[1] = hc_swap32_S (h[1]);
|
|
|
|
hooks[gid].ukey[2] = hc_swap32_S (h[2]);
|
|
|
|
hooks[gid].ukey[3] = hc_swap32_S (h[3]);
|
|
|
|
hooks[gid].ukey[4] = hc_swap32_S (h[4]);
|
|
|
|
hooks[gid].ukey[5] = hc_swap32_S (h[5]);
|
|
|
|
hooks[gid].ukey[6] = hc_swap32_S (h[6]);
|
|
|
|
hooks[gid].ukey[7] = hc_swap32_S (h[7]);
|
2017-01-24 10:28:35 +01:00
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m11600_comp (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t))
|
2017-01-24 10:28:35 +01:00
|
|
|
{
|
2015-12-04 15:47:52 +01:00
|
|
|
/**
|
2017-01-24 10:28:35 +01:00
|
|
|
* base
|
2015-12-04 15:47:52 +01:00
|
|
|
*/
|
|
|
|
|
2017-08-19 16:39:22 +02:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2022-01-04 22:57:26 +01:00
|
|
|
if (gid >= GID_CNT) return;
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2018-11-16 14:30:45 +01:00
|
|
|
if (hooks[gid].hook_success == 1)
|
2015-12-04 15:47:52 +01:00
|
|
|
{
|
2022-01-04 18:07:18 +01:00
|
|
|
if (hc_atomic_inc (&hashes_shown[DIGESTS_OFFSET_HOST]) == 0)
|
2017-06-16 10:48:10 +02:00
|
|
|
{
|
2022-01-04 18:07:18 +01:00
|
|
|
mark_hash (plains_buf, d_return_buf, SALT_POS_HOST, DIGESTS_CNT, 0, DIGESTS_OFFSET_HOST + 0, gid, 0, 0, 0);
|
2017-06-16 10:48:10 +02:00
|
|
|
}
|
2015-12-04 15:47:52 +01:00
|
|
|
|
2017-01-24 10:28:35 +01:00
|
|
|
return;
|
2015-12-04 15:47:52 +01:00
|
|
|
}
|
2017-06-16 10:48:10 +02:00
|
|
|
}
|