1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-21 23:58:07 +00:00

Remove SHA1_TRANSFORM_SWAP modificaton in inc_hash_sha1.cl and use replacement of sha1_final in -m 32700 sources as replacement

This commit is contained in:
Jens Steube 2023-09-13 07:50:20 +00:00
parent 573423af97
commit a74270b120
3 changed files with 47 additions and 64 deletions

View File

@ -41,27 +41,6 @@ DECLSPEC void sha1_transform (PRIVATE_AS const u32 *w0, PRIVATE_AS const u32 *w1
u32 we_t = w3[2];
u32 wf_t = w3[3];
#ifdef SHA1_TRANSFORM_SWAP
w0_t = hc_swap32 (w0_t);
w1_t = hc_swap32 (w1_t);
w2_t = hc_swap32 (w2_t);
w3_t = hc_swap32 (w3_t);
w4_t = hc_swap32 (w4_t);
w5_t = hc_swap32 (w5_t);
w6_t = hc_swap32 (w6_t);
w7_t = hc_swap32 (w7_t);
w8_t = hc_swap32 (w8_t);
w9_t = hc_swap32 (w9_t);
wa_t = hc_swap32 (wa_t);
wb_t = hc_swap32 (wb_t);
wc_t = hc_swap32 (wc_t);
wd_t = hc_swap32 (wd_t);
we_t = hc_swap32 (we_t);
wf_t = hc_swap32 (wf_t);
#endif
#define K SHA1C00
SHA1_STEP_S (SHA1_F0o, a, b, c, d, e, w0_t);
@ -242,27 +221,6 @@ DECLSPEC void sha1_transform (PRIVATE_AS const u32 *w0, PRIVATE_AS const u32 *w1
u32 w4e_t;
u32 w4f_t;
#ifdef SHA1_TRANSFORM_SWAP
w00_t = hc_swap32 (w00_t);
w01_t = hc_swap32 (w01_t);
w02_t = hc_swap32 (w02_t);
w03_t = hc_swap32 (w03_t);
w04_t = hc_swap32 (w04_t);
w05_t = hc_swap32 (w05_t);
w06_t = hc_swap32 (w06_t);
w07_t = hc_swap32 (w07_t);
w08_t = hc_swap32 (w08_t);
w09_t = hc_swap32 (w09_t);
w0a_t = hc_swap32 (w0a_t);
w0b_t = hc_swap32 (w0b_t);
w0c_t = hc_swap32 (w0c_t);
w0d_t = hc_swap32 (w0d_t);
w0e_t = hc_swap32 (w0e_t);
w0f_t = hc_swap32 (w0f_t);
#endif
#define K SHA1C00
SHA1_STEP_S (SHA1_F0o, a, b, c, d, e, w00_t);

View File

@ -73,19 +73,53 @@ DECLSPEC void new_des (uchar * block, uchar * newdes_key)
DECLSPEC void key_expansion (uchar * sha1sum, uchar * result)
{
uchar *shi = sha1sum;
for (int count = 0; count < 15; count++)
{
*result = *shi;
*(result + 1) = *shi ^ sha1sum[7];
*(result + 2) = *shi ^ sha1sum[8];
*(result + 3) = *shi++ ^ sha1sum[9];
const uchar shi = sha1sum[count];
*(result + 0) = shi;
*(result + 1) = shi ^ sha1sum[7];
*(result + 2) = shi ^ sha1sum[8];
*(result + 3) = shi ^ sha1sum[9];
result += 4;
}
}
DECLSPEC void sha1_final_32700 (PRIVATE_AS sha1_ctx_t *ctx)
{
const int pos = ctx->len & 63;
append_0x80_4x4_S (ctx->w0, ctx->w1, ctx->w2, ctx->w3, pos);
if (pos >= 56)
{
sha1_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
ctx->w0[0] = 0;
ctx->w0[1] = 0;
ctx->w0[2] = 0;
ctx->w0[3] = 0;
ctx->w1[0] = 0;
ctx->w1[1] = 0;
ctx->w1[2] = 0;
ctx->w1[3] = 0;
ctx->w2[0] = 0;
ctx->w2[1] = 0;
ctx->w2[2] = 0;
ctx->w2[3] = 0;
ctx->w3[0] = 0;
ctx->w3[1] = 0;
ctx->w3[2] = 0;
ctx->w3[3] = 0;
}
ctx->w3[2] = 0;
ctx->w3[3] = hc_swap32_S (ctx->len * 8);
sha1_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
}
KERNEL_FQ void m32700_init (KERN_ATTR_TMPS (sha1_tmp_t))
{
const u64 gid = get_global_id (0);
@ -96,8 +130,9 @@ KERNEL_FQ void m32700_init (KERN_ATTR_TMPS (sha1_tmp_t))
sha1_ctx_t ctx;
sha1_init (&ctx);
sha1_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len);
sha1_final (&ctx);
sha1_update_global (&ctx, pws[gid].i, pws[gid].pw_len);
sha1_final_32700 (&ctx);
// sha1_final (&ctx);
ctx.h[0] = hc_swap32_S (ctx.h[0]);
ctx.h[1] = hc_swap32_S (ctx.h[1]);
@ -169,9 +204,9 @@ KERNEL_FQ void m32700_comp (KERN_ATTR_TMPS (sha1_tmp_t))
sha1_ctx_t ctx;
sha1_init (&ctx);
sha1_update_swap (&ctx, salt, 8);
sha1_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len);
sha1_final (&ctx);
sha1_update (&ctx, salt, 8);
sha1_update_global (&ctx, pws[gid].i, pws[gid].pw_len);
sha1_final_32700 (&ctx);
const u32 r0 = ctx.h[0];
const u32 r1 = ctx.h[1];

View File

@ -102,16 +102,6 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t * hashconfig, MAYBE_
return ST_PASS;
}
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;
// Use SHA1 with endianness bug
hc_asprintf (&jit_build_options, "-D SHA1_TRANSFORM_SWAP");
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)
{
u32 *digest = (u32 *) digest_buf;
@ -241,7 +231,7 @@ void module_init (module_ctx_t * module_ctx)
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_build_options = MODULE_DEFAULT;
module_ctx->module_jit_cache_disable = MODULE_DEFAULT;
module_ctx->module_kernel_accel_max = MODULE_DEFAULT;
module_ctx->module_kernel_accel_min = MODULE_DEFAULT;