From 57fe66dd10507183059a27f13576be3845345a2f Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 13 Dec 2022 22:43:47 +0000 Subject: [PATCH] Precompute byteswap for salt in -m 28200 --- OpenCL/m28200-pure.cl | 2 +- src/modules/module_28200.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenCL/m28200-pure.cl b/OpenCL/m28200-pure.cl index 0cfec89d7..2ead5b4bc 100644 --- a/OpenCL/m28200-pure.cl +++ b/OpenCL/m28200-pure.cl @@ -291,7 +291,7 @@ KERNEL_FQ void m28200_init (KERN_ATTR_TMPS_ESALT (exodus_tmp_t, exodus_t)) sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len); - sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + sha256_hmac_update_global (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); for (u32 i = 0, j = 1, k = 0; i < SCRYPT_CNT; i += 8, j += 1, k += 2) { diff --git a/src/modules/module_28200.c b/src/modules/module_28200.c index 2d60c50cb..af538472a 100644 --- a/src/modules/module_28200.c +++ b/src/modules/module_28200.c @@ -369,6 +369,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE memcpy (salt->salt_buf, tmp_buf, tmp_len); + for (int i = 0; i < 8; i++) salt->salt_buf[i] = byte_swap_32 (salt->salt_buf[i]); + salt->salt_len = tmp_len; // iv @@ -428,9 +430,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt + u32 tmp_salt[8] = { 0 }; + + for (int i = 0; i < 8; i++) tmp_salt[i] = byte_swap_32 (salt->salt_buf[i]); + char base64_salt[64]; - int base64_salt_len = base64_encode (int_to_base64, (const u8 *) salt->salt_buf, salt->salt_len, (u8 *) base64_salt); + int base64_salt_len = base64_encode (int_to_base64, (const u8 *) tmp_salt, salt->salt_len, (u8 *) base64_salt); base64_salt[base64_salt_len] = 0;