mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 16:18:09 +00:00
Add parameter for second iteration count
This commit is contained in:
parent
74af4eced6
commit
9b66c01535
@ -253,7 +253,7 @@ KERNEL_FQ void m23400_loop (KERN_ATTR_TMPS (bitwarden_tmp_t))
|
|||||||
unpackv (tmps, out, gid, 7, out[7]);
|
unpackv (tmps, out, gid, 7, out[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
KERNEL_FQ void m23400_comp (KERN_ATTR_TMPS_ESALT (bitwarden_tmp_t, u32))
|
KERNEL_FQ void m23400_init2 (KERN_ATTR_TMPS (bitwarden_tmp_t))
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* base
|
* base
|
||||||
@ -278,26 +278,23 @@ KERNEL_FQ void m23400_comp (KERN_ATTR_TMPS_ESALT (bitwarden_tmp_t, u32))
|
|||||||
|
|
||||||
sha256_hmac_init (&sha256_hmac_ctx, out, 32);
|
sha256_hmac_init (&sha256_hmac_ctx, out, 32);
|
||||||
|
|
||||||
u32 ipad[8];
|
tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0];
|
||||||
u32 opad[8];
|
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];
|
||||||
|
|
||||||
ipad[0] = sha256_hmac_ctx.ipad.h[0];
|
tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0];
|
||||||
ipad[1] = sha256_hmac_ctx.ipad.h[1];
|
tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1];
|
||||||
ipad[2] = sha256_hmac_ctx.ipad.h[2];
|
tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2];
|
||||||
ipad[3] = sha256_hmac_ctx.ipad.h[3];
|
tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3];
|
||||||
ipad[4] = sha256_hmac_ctx.ipad.h[4];
|
tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4];
|
||||||
ipad[5] = sha256_hmac_ctx.ipad.h[5];
|
tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5];
|
||||||
ipad[6] = sha256_hmac_ctx.ipad.h[6];
|
tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6];
|
||||||
ipad[7] = sha256_hmac_ctx.ipad.h[7];
|
tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7];
|
||||||
|
|
||||||
opad[0] = sha256_hmac_ctx.opad.h[0];
|
|
||||||
opad[1] = sha256_hmac_ctx.opad.h[1];
|
|
||||||
opad[2] = sha256_hmac_ctx.opad.h[2];
|
|
||||||
opad[3] = sha256_hmac_ctx.opad.h[3];
|
|
||||||
opad[4] = sha256_hmac_ctx.opad.h[4];
|
|
||||||
opad[5] = sha256_hmac_ctx.opad.h[5];
|
|
||||||
opad[6] = sha256_hmac_ctx.opad.h[6];
|
|
||||||
opad[7] = sha256_hmac_ctx.opad.h[7];
|
|
||||||
|
|
||||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len);
|
sha256_hmac_update_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len);
|
||||||
|
|
||||||
@ -324,54 +321,151 @@ KERNEL_FQ void m23400_comp (KERN_ATTR_TMPS_ESALT (bitwarden_tmp_t, u32))
|
|||||||
w3[1] = 0;
|
w3[1] = 0;
|
||||||
w3[2] = 0;
|
w3[2] = 0;
|
||||||
w3[3] = 0;
|
w3[3] = 0;
|
||||||
|
|
||||||
sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4);
|
sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4);
|
||||||
|
|
||||||
sha256_hmac_final (&sha256_hmac_ctx2);
|
sha256_hmac_final (&sha256_hmac_ctx2);
|
||||||
|
|
||||||
const u32 version = esalt_bufs[DIGESTS_OFFSET_HOST];
|
tmps[gid].dgst[0] = sha256_hmac_ctx2.opad.h[0];
|
||||||
if(version == 2)
|
tmps[gid].dgst[1] = sha256_hmac_ctx2.opad.h[1];
|
||||||
{
|
tmps[gid].dgst[2] = sha256_hmac_ctx2.opad.h[2];
|
||||||
|
tmps[gid].dgst[3] = sha256_hmac_ctx2.opad.h[3];
|
||||||
|
tmps[gid].dgst[4] = sha256_hmac_ctx2.opad.h[4];
|
||||||
|
tmps[gid].dgst[5] = sha256_hmac_ctx2.opad.h[5];
|
||||||
|
tmps[gid].dgst[6] = sha256_hmac_ctx2.opad.h[6];
|
||||||
|
tmps[gid].dgst[7] = sha256_hmac_ctx2.opad.h[7];
|
||||||
|
|
||||||
sha256_hmac_ctx_t sha256_hmac_ctx3;
|
tmps[gid].out[0] = tmps[gid].dgst[0];
|
||||||
|
tmps[gid].out[1] = tmps[gid].dgst[1];
|
||||||
|
tmps[gid].out[2] = tmps[gid].dgst[2];
|
||||||
u32 buff[16] = {0};
|
tmps[gid].out[3] = tmps[gid].dgst[3];
|
||||||
buff[0] = sha256_hmac_ctx2.opad.h[0];
|
tmps[gid].out[4] = tmps[gid].dgst[4];
|
||||||
buff[1] = sha256_hmac_ctx2.opad.h[1];
|
tmps[gid].out[5] = tmps[gid].dgst[5];
|
||||||
buff[2] = sha256_hmac_ctx2.opad.h[2];
|
tmps[gid].out[6] = tmps[gid].dgst[6];
|
||||||
buff[3] = sha256_hmac_ctx2.opad.h[3];
|
tmps[gid].out[7] = tmps[gid].dgst[7];
|
||||||
buff[4] = sha256_hmac_ctx2.opad.h[4];
|
}
|
||||||
buff[5] = sha256_hmac_ctx2.opad.h[5];
|
|
||||||
buff[6] = sha256_hmac_ctx2.opad.h[6];
|
KERNEL_FQ void m23400_loop2 (KERN_ATTR_TMPS (bitwarden_tmp_t))
|
||||||
buff[7] = sha256_hmac_ctx2.opad.h[7];
|
{
|
||||||
|
const u64 gid = get_global_id (0);
|
||||||
sha256_hmac_init (&sha256_hmac_ctx3, out, 32);
|
|
||||||
sha256_hmac_update (&sha256_hmac_ctx3, buff, 32);
|
if ((gid * VECT_SIZE) >= GID_CNT) return;
|
||||||
sha256_hmac_final (&sha256_hmac_ctx3);
|
|
||||||
|
u32x ipad[8];
|
||||||
const u32 r0 = sha256_hmac_ctx2.opad.h[0] ^ sha256_hmac_ctx3.opad.h[0];
|
u32x opad[8];
|
||||||
const u32 r1 = sha256_hmac_ctx2.opad.h[1] ^ sha256_hmac_ctx3.opad.h[1];
|
|
||||||
const u32 r2 = sha256_hmac_ctx2.opad.h[2] ^ sha256_hmac_ctx3.opad.h[2];
|
ipad[0] = packv (tmps, ipad, gid, 0);
|
||||||
const u32 r3 = sha256_hmac_ctx2.opad.h[3] ^ sha256_hmac_ctx3.opad.h[3];
|
ipad[1] = packv (tmps, ipad, gid, 1);
|
||||||
|
ipad[2] = packv (tmps, ipad, gid, 2);
|
||||||
#define il_pos 0
|
ipad[3] = packv (tmps, ipad, gid, 3);
|
||||||
|
ipad[4] = packv (tmps, ipad, gid, 4);
|
||||||
#ifdef KERNEL_STATIC
|
ipad[5] = packv (tmps, ipad, gid, 5);
|
||||||
#include COMPARE_M
|
ipad[6] = packv (tmps, ipad, gid, 6);
|
||||||
#endif
|
ipad[7] = packv (tmps, ipad, gid, 7);
|
||||||
}
|
|
||||||
else if (version == 1)
|
opad[0] = packv (tmps, opad, gid, 0);
|
||||||
{
|
opad[1] = packv (tmps, opad, gid, 1);
|
||||||
const u32 r0 = sha256_hmac_ctx2.opad.h[0];
|
opad[2] = packv (tmps, opad, gid, 2);
|
||||||
const u32 r1 = sha256_hmac_ctx2.opad.h[1];
|
opad[3] = packv (tmps, opad, gid, 3);
|
||||||
const u32 r2 = sha256_hmac_ctx2.opad.h[2];
|
opad[4] = packv (tmps, opad, gid, 4);
|
||||||
const u32 r3 = sha256_hmac_ctx2.opad.h[3];
|
opad[5] = packv (tmps, opad, gid, 5);
|
||||||
|
opad[6] = packv (tmps, opad, gid, 6);
|
||||||
#define il_pos 0
|
opad[7] = packv (tmps, opad, gid, 7);
|
||||||
|
|
||||||
#ifdef KERNEL_STATIC
|
u32x dgst[8];
|
||||||
#include COMPARE_M
|
u32x out[8];
|
||||||
#endif
|
|
||||||
}
|
dgst[0] = packv (tmps, dgst, gid, 0);
|
||||||
|
dgst[1] = packv (tmps, dgst, gid, 1);
|
||||||
|
dgst[2] = packv (tmps, dgst, gid, 2);
|
||||||
|
dgst[3] = packv (tmps, dgst, gid, 3);
|
||||||
|
dgst[4] = packv (tmps, dgst, gid, 4);
|
||||||
|
dgst[5] = packv (tmps, dgst, gid, 5);
|
||||||
|
dgst[6] = packv (tmps, dgst, gid, 6);
|
||||||
|
dgst[7] = packv (tmps, dgst, gid, 7);
|
||||||
|
|
||||||
|
out[0] = packv (tmps, out, gid, 0);
|
||||||
|
out[1] = packv (tmps, out, gid, 1);
|
||||||
|
out[2] = packv (tmps, out, gid, 2);
|
||||||
|
out[3] = packv (tmps, out, gid, 3);
|
||||||
|
out[4] = packv (tmps, out, gid, 4);
|
||||||
|
out[5] = packv (tmps, out, gid, 5);
|
||||||
|
out[6] = packv (tmps, out, gid, 6);
|
||||||
|
out[7] = packv (tmps, out, gid, 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, 0, dgst[0]);
|
||||||
|
unpackv (tmps, dgst, gid, 1, dgst[1]);
|
||||||
|
unpackv (tmps, dgst, gid, 2, dgst[2]);
|
||||||
|
unpackv (tmps, dgst, gid, 3, dgst[3]);
|
||||||
|
unpackv (tmps, dgst, gid, 4, dgst[4]);
|
||||||
|
unpackv (tmps, dgst, gid, 5, dgst[5]);
|
||||||
|
unpackv (tmps, dgst, gid, 6, dgst[6]);
|
||||||
|
unpackv (tmps, dgst, gid, 7, dgst[7]);
|
||||||
|
|
||||||
|
unpackv (tmps, out, gid, 0, out[0]);
|
||||||
|
unpackv (tmps, out, gid, 1, out[1]);
|
||||||
|
unpackv (tmps, out, gid, 2, out[2]);
|
||||||
|
unpackv (tmps, out, gid, 3, out[3]);
|
||||||
|
unpackv (tmps, out, gid, 4, out[4]);
|
||||||
|
unpackv (tmps, out, gid, 5, out[5]);
|
||||||
|
unpackv (tmps, out, gid, 6, out[6]);
|
||||||
|
unpackv (tmps, out, gid, 7, out[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
KERNEL_FQ void m23400_comp (KERN_ATTR_TMPS_ESALT (bitwarden_tmp_t, u32))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* base
|
||||||
|
*/
|
||||||
|
|
||||||
|
const u64 gid = get_global_id (0);
|
||||||
|
|
||||||
|
if (gid >= GID_CNT) return;
|
||||||
|
|
||||||
|
const u32 r0 = tmps[gid].out[0];
|
||||||
|
const u32 r1 = tmps[gid].out[1];
|
||||||
|
const u32 r2 = tmps[gid].out[2];
|
||||||
|
const u32 r3 = tmps[gid].out[3];
|
||||||
|
|
||||||
|
#define il_pos 0
|
||||||
|
|
||||||
|
#ifdef KERNEL_STATIC
|
||||||
|
#include COMPARE_M
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,12 @@ static const char *HASH_NAME = "Bitwarden";
|
|||||||
static const u64 KERN_TYPE = 23400;
|
static const u64 KERN_TYPE = 23400;
|
||||||
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
||||||
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
|
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
|
||||||
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE;
|
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE
|
||||||
|
| OPTS_TYPE_LOOP2
|
||||||
|
| OPTS_TYPE_INIT2;
|
||||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||||
static const char *ST_PASS = "hashcat1";
|
static const char *ST_PASS = "hashcat1";
|
||||||
static const char *ST_HASH = "$bitwarden$2*100000*bm9yZXBseUBoYXNoY2F0Lm5ldA==*CWCy4KZEEw1W92qB7xfLRNoJpepTMSyr7WJGZ0/Xr8c=";
|
static const char *ST_HASH = "$bitwarden$2*100000*2*bm9yZXBseUBoYXNoY2F0Lm5ldA==*CWCy4KZEEw1W92qB7xfLRNoJpepTMSyr7WJGZ0/Xr8c=";
|
||||||
|
|
||||||
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
|
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
|
||||||
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
|
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
|
||||||
@ -84,11 +86,6 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
|
|||||||
return jit_build_options;
|
return jit_build_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
|
||||||
{
|
|
||||||
return (u64) sizeof(u32);
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||||
{
|
{
|
||||||
const u64 tmp_size = (const u64) sizeof (bitwarden_tmp_t);
|
const u64 tmp_size = (const u64) sizeof (bitwarden_tmp_t);
|
||||||
@ -110,11 +107,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
{
|
{
|
||||||
u32 *digest = (u32 *) digest_buf;
|
u32 *digest = (u32 *) digest_buf;
|
||||||
|
|
||||||
u32 *ver = (u32 *) esalt_buf;
|
|
||||||
|
|
||||||
hc_token_t token;
|
hc_token_t token;
|
||||||
|
|
||||||
token.token_cnt = 5;
|
token.token_cnt = 6;
|
||||||
|
|
||||||
token.signatures_cnt = 1;
|
token.signatures_cnt = 1;
|
||||||
token.signatures_buf[0] = SIGNATURE_BITWARDEN;
|
token.signatures_buf[0] = SIGNATURE_BITWARDEN;
|
||||||
@ -137,13 +132,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
|
|
||||||
token.sep[3] = '*';
|
token.sep[3] = '*';
|
||||||
token.len_min[3] = 1;
|
token.len_min[3] = 1;
|
||||||
token.len_max[3] = ((SALT_MAX * 8) / 6) + 3;
|
token.len_max[3] = 7;
|
||||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH;
|
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
token.sep[4] = '*';
|
token.sep[4] = '*';
|
||||||
token.len_min[4] = 44;
|
token.len_min[4] = 1;
|
||||||
token.len_max[4] = 44;
|
token.len_max[4] = ((SALT_MAX * 8) / 6) + 3;
|
||||||
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||||
|
|
||||||
|
token.sep[5] = '*';
|
||||||
|
token.len_min[5] = 44;
|
||||||
|
token.len_max[5] = 44;
|
||||||
|
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||||
|
|
||||||
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
||||||
@ -155,27 +156,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
const u8 *version_pos = token.buf[1];
|
const u8 *version_pos = token.buf[1];
|
||||||
const u32 version = *version_pos - 0x30;
|
const u32 version = *version_pos - 0x30;
|
||||||
|
|
||||||
if (version == 1 || version == 2)
|
if (version != 2) return (PARSER_SALT_VALUE);
|
||||||
{
|
|
||||||
*ver = version;
|
|
||||||
}
|
|
||||||
else return (PARSER_SALT_VALUE);
|
|
||||||
|
|
||||||
// iter
|
// iter
|
||||||
|
|
||||||
const u8 *iter_pos = token.buf[2];
|
const u8 *iter1_pos = token.buf[2];
|
||||||
|
const u8 *iter2_pos = token.buf[3];
|
||||||
|
|
||||||
const u32 iter = hc_strtoul ((const char *) iter_pos, NULL, 10);
|
const u32 iter1 = hc_strtoul ((const char *) iter1_pos, NULL, 10);
|
||||||
|
|
||||||
if (iter < 1) return (PARSER_SALT_ITERATION);
|
if (iter1 < 1) return (PARSER_SALT_ITERATION);
|
||||||
if (iter > 999999) return (PARSER_SALT_ITERATION);
|
if (iter1 > 999999) return (PARSER_SALT_ITERATION);
|
||||||
|
|
||||||
salt->salt_iter = iter - 1;
|
salt->salt_iter = iter1 - 1;
|
||||||
|
|
||||||
|
const u32 iter2 = hc_strtoul ((const char *) iter2_pos, NULL, 10);
|
||||||
|
|
||||||
|
if (iter2 < 1) return (PARSER_SALT_ITERATION);
|
||||||
|
if (iter2 > 999999) return (PARSER_SALT_ITERATION);
|
||||||
|
|
||||||
|
salt->salt_iter2 = iter2 - 1;
|
||||||
|
|
||||||
// salt
|
// salt
|
||||||
|
|
||||||
const u8 *salt_pos = token.buf[3];
|
const u8 *salt_pos = token.buf[4];
|
||||||
const int salt_len = token.len[3];
|
const int salt_len = token.len[4];
|
||||||
|
|
||||||
u8 tmp_buf[SALT_MAX + 1] = { 0 };
|
u8 tmp_buf[SALT_MAX + 1] = { 0 };
|
||||||
|
|
||||||
@ -190,8 +195,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
|
|
||||||
// hash
|
// hash
|
||||||
|
|
||||||
const u8 *hash_pos = token.buf[4];
|
const u8 *hash_pos = token.buf[5];
|
||||||
const int hash_len = token.len[4];
|
const int hash_len = token.len[5];
|
||||||
|
|
||||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||||
|
|
||||||
@ -242,9 +247,10 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
|
|
||||||
base64_encode (int_to_base64, (const u8 *) tmp_buf, 32, (u8 *) hash_buf);
|
base64_encode (int_to_base64, (const u8 *) tmp_buf, 32, (u8 *) hash_buf);
|
||||||
|
|
||||||
const int line_len = snprintf (line_buf, line_size, "%s2*%i*%s*%s",
|
const int line_len = snprintf (line_buf, line_size, "%s2*%i*%i*%s*%s",
|
||||||
SIGNATURE_BITWARDEN,
|
SIGNATURE_BITWARDEN,
|
||||||
salt->salt_iter + 1,
|
salt->salt_iter + 1,
|
||||||
|
salt->salt_iter2 + 1,
|
||||||
salt_buf,
|
salt_buf,
|
||||||
hash_buf);
|
hash_buf);
|
||||||
|
|
||||||
@ -270,7 +276,7 @@ void module_init (module_ctx_t *module_ctx)
|
|||||||
module_ctx->module_dgst_pos3 = module_dgst_pos3;
|
module_ctx->module_dgst_pos3 = module_dgst_pos3;
|
||||||
module_ctx->module_dgst_size = module_dgst_size;
|
module_ctx->module_dgst_size = module_dgst_size;
|
||||||
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
|
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
|
||||||
module_ctx->module_esalt_size = module_esalt_size;
|
module_ctx->module_esalt_size = MODULE_DEFAULT;
|
||||||
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
||||||
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
||||||
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
||||||
|
@ -18,6 +18,7 @@ sub module_generate_hash
|
|||||||
my $word = shift;
|
my $word = shift;
|
||||||
my $salt = shift;
|
my $salt = shift;
|
||||||
my $iter = shift // 10000; # or 100000 default but probably too high for tests
|
my $iter = shift // 10000; # or 100000 default but probably too high for tests
|
||||||
|
my $iter2 = shift // 2;
|
||||||
|
|
||||||
my $kdf1 = Crypt::PBKDF2->new
|
my $kdf1 = Crypt::PBKDF2->new
|
||||||
(
|
(
|
||||||
@ -29,7 +30,7 @@ sub module_generate_hash
|
|||||||
my $kdf2 = Crypt::PBKDF2->new
|
my $kdf2 = Crypt::PBKDF2->new
|
||||||
(
|
(
|
||||||
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
|
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
|
||||||
iterations => 2,
|
iterations => $iter2,
|
||||||
output_len => 32
|
output_len => 32
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ sub module_generate_hash
|
|||||||
my $digest1 = $kdf1->PBKDF2 ($email, $word);
|
my $digest1 = $kdf1->PBKDF2 ($email, $word);
|
||||||
my $digest2 = $kdf2->PBKDF2 ($word, $digest1); # position of $word switched !
|
my $digest2 = $kdf2->PBKDF2 ($word, $digest1); # position of $word switched !
|
||||||
|
|
||||||
my $hash = sprintf ("\$bitwarden\$2*%d*%s*%s", $iter, encode_base64 ($email, ""), encode_base64 ($digest2, ""));
|
my $hash = sprintf ("\$bitwarden\$2*%d*%d*%s*%s", $iter, $iter2, encode_base64 ($email, ""), encode_base64 ($digest2, ""));
|
||||||
|
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user