Skip to content

Commit 6716447

Browse files
committed
Add support for zero-length salts in Electrum $4 and $5
1 parent fafb277 commit 6716447

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

OpenCL/m21700-pure.cl

+9-5
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ KERNEL_FQ void m21700_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t))
325325

326326
if (gid >= GID_CNT) return;
327327

328+
const u32 digest_pos = LOOP_POS;
329+
330+
const u32 digest_cur = DIGESTS_OFFSET_HOST + digest_pos;
331+
332+
GLOBAL_AS const electrum_t *electrum = &esalt_bufs[digest_cur];
333+
328334
u64 out[8];
329335

330336
out[0] = tmps[gid].out[0];
@@ -379,13 +385,12 @@ KERNEL_FQ void m21700_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t))
379385
* the main secp256k1 point multiplication by a scalar/tweak:
380386
*/
381387

382-
GLOBAL_AS secp256k1_t *coords = (GLOBAL_AS secp256k1_t *) &esalt_bufs[DIGESTS_OFFSET_HOST].coords;
388+
GLOBAL_AS const secp256k1_t *coords = (GLOBAL_AS const secp256k1_t *) &electrum->coords;
383389

384390
u32 pubkey[64] = { 0 }; // for point_mul () we need: 1 + 32 bytes (for sha512 () we need more)
385391

386392
point_mul (pubkey, tweak, coords);
387393

388-
389394
/*
390395
* sha512 () of the pubkey:
391396
*/
@@ -396,14 +401,13 @@ KERNEL_FQ void m21700_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t))
396401
sha512_update (&sha512_ctx, pubkey, 33); // 33 because of 32 byte curve point + sign
397402
sha512_final (&sha512_ctx);
398403

399-
400404
/*
401405
* sha256-hmac () of the data_buf
402406
*/
403407

404-
GLOBAL_AS u32 *data_buf = (GLOBAL_AS u32 *) esalt_bufs[DIGESTS_OFFSET_HOST].data_buf;
408+
GLOBAL_AS const u32 *data_buf = (GLOBAL_AS const u32 *) electrum->data_buf;
405409

406-
u32 data_len = esalt_bufs[DIGESTS_OFFSET_HOST].data_len;
410+
u32 data_len = electrum->data_len;
407411

408412
u32 key[16] = { 0 };
409413

OpenCL/m21800-pure.cl

+7-2
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ KERNEL_FQ void m21800_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t))
375375

376376
if (gid >= GID_CNT) return;
377377

378+
const u32 digest_pos = LOOP_POS;
379+
380+
const u32 digest_cur = DIGESTS_OFFSET_HOST + digest_pos;
381+
382+
GLOBAL_AS const electrum_t *electrum = &esalt_bufs[digest_cur];
378383

379384
/*
380385
* Start by copying/aligning the data
@@ -434,7 +439,7 @@ KERNEL_FQ void m21800_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t))
434439
* the main secp256k1 point multiplication by a scalar/tweak:
435440
*/
436441

437-
GLOBAL_AS secp256k1_t *coords = (GLOBAL_AS secp256k1_t *) &esalt_bufs[DIGESTS_OFFSET_HOST].coords;
442+
GLOBAL_AS const secp256k1_t *coords = (GLOBAL_AS const secp256k1_t *) &electrum->coords;
438443

439444
u32 pubkey[64] = { 0 }; // for point_mul () we need: 1 + 32 bytes (for sha512 () we need more)
440445

@@ -499,7 +504,7 @@ KERNEL_FQ void m21800_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t))
499504

500505
// we need to run it at least once:
501506

502-
GLOBAL_AS u32 *data_buf = (GLOBAL_AS u32 *) esalt_bufs[DIGESTS_OFFSET_HOST].data_buf;
507+
GLOBAL_AS const u32 *data_buf = (GLOBAL_AS const u32 *) electrum->data_buf;
503508

504509
u32 data[4];
505510

src/modules/module_21700.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
2525
| OPTI_TYPE_USES_BITS_64
2626
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
2727
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
28+
| OPTS_TYPE_DEEP_COMP_KERNEL
2829
| OPTS_TYPE_PT_GENERATE_LE;
2930
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
3031
static const char *ST_PASS = "hashcat";
@@ -66,6 +67,11 @@ typedef struct electrum_tmp
6667

6768
static const char *SIGNATURE_ELECTRUM = "$electrum$4*";
6869

70+
u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos)
71+
{
72+
return KERN_RUN_3;
73+
}
74+
6975
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
7076
{
7177
if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK)
@@ -214,13 +220,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
214220

215221
// fake salt
216222

217-
salt->salt_buf[0] = esalt->data_buf[0];
218-
salt->salt_buf[1] = esalt->data_buf[1];
219-
salt->salt_buf[2] = esalt->data_buf[2];
220-
salt->salt_buf[3] = esalt->data_buf[3];
221-
222-
salt->salt_len = 16;
223-
223+
salt->salt_buf[0] = 0;
224+
salt->salt_len = 0;
224225
salt->salt_iter = 1024 - 1;
225226

226227
return (PARSER_OK);
@@ -294,7 +295,7 @@ void module_init (module_ctx_t *module_ctx)
294295
module_ctx->module_benchmark_charset = MODULE_DEFAULT;
295296
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
296297
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
297-
module_ctx->module_deep_comp_kernel = MODULE_DEFAULT;
298+
module_ctx->module_deep_comp_kernel = module_deep_comp_kernel;
298299
module_ctx->module_deprecated_notice = MODULE_DEFAULT;
299300
module_ctx->module_dgst_pos0 = module_dgst_pos0;
300301
module_ctx->module_dgst_pos1 = module_dgst_pos1;

src/modules/module_21800.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
2626
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
2727
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
2828
| OPTS_TYPE_PT_GENERATE_LE
29+
| OPTS_TYPE_DEEP_COMP_KERNEL
2930
| OPTS_TYPE_NATIVE_THREADS;
3031
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
3132
static const char *ST_PASS = "hashcat";
@@ -66,6 +67,11 @@ typedef struct electrum_tmp
6667

6768
static const char *SIGNATURE_ELECTRUM = "$electrum$5*";
6869

70+
u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos)
71+
{
72+
return KERN_RUN_3;
73+
}
74+
6975
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
7076
{
7177
// problem with this kernel is the huge amount of register pressure on u8 tmp[TMPSIZ];
@@ -191,13 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
191197

192198
// fake salt
193199

194-
salt->salt_buf[0] = esalt->data_buf[0];
195-
salt->salt_buf[1] = esalt->data_buf[1];
196-
salt->salt_buf[2] = esalt->data_buf[2];
197-
salt->salt_buf[3] = esalt->data_buf[3];
198-
199-
salt->salt_len = 16;
200-
200+
salt->salt_buf[0] = 0;
201+
salt->salt_len = 0;
201202
salt->salt_iter = 1024 - 1;
202203

203204
return (PARSER_OK);
@@ -271,7 +272,7 @@ void module_init (module_ctx_t *module_ctx)
271272
module_ctx->module_benchmark_charset = MODULE_DEFAULT;
272273
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
273274
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
274-
module_ctx->module_deep_comp_kernel = MODULE_DEFAULT;
275+
module_ctx->module_deep_comp_kernel = module_deep_comp_kernel;
275276
module_ctx->module_deprecated_notice = MODULE_DEFAULT;
276277
module_ctx->module_dgst_pos0 = module_dgst_pos0;
277278
module_ctx->module_dgst_pos1 = module_dgst_pos1;

0 commit comments

Comments
 (0)