fix 26700

This commit is contained in:
Gabriele Gristina
2021-07-15 19:58:11 +02:00
parent 50aeaa299d
commit eaedfb3f8a
4 changed files with 73 additions and 42 deletions
+3 -4
View File
@@ -10,14 +10,13 @@ use warnings;
use Crypt::PBKDF2;
use Crypt::CBC;
use Crypt::Mode::CBC;
sub module_constraints { [[0, 256], [32, 32], [-1, -1], [-1, -1], [-1, -1]] }
sub module_generate_hash
{
my $word = shift;
my $salt_str = shift // random_hex_string (32);
my $salt_str = shift;
my $ct_str = shift;
my $iv_str = "";
@@ -72,7 +71,7 @@ sub module_generate_hash
my $encrypted = unpack ("H*", $cipher->encrypt ($data));
$hash = sprintf ("\$vmx\$0\$%s\$%s\$%s%s", $iterations, unpack ("H*", $salt), unpack ("H*", $iv), $encrypted);
$hash = sprintf ("\$vmx\$0\$%s\$%s\$%s%s", $iterations, unpack ("H*", $salt), unpack ("H*", $iv), substr ($encrypted, 0, 32));
}
return $hash;
@@ -92,7 +91,7 @@ sub module_verify_hash
return unless ($signature eq "vmx");
return unless ($version eq 0);
return unless ($rounds eq 10000);
return unless (length $ct lt 32);
return unless (length $ct eq 64);
my $word_packed = pack_if_HEX_notation ($word);
+1 -4
View File
@@ -44,7 +44,6 @@ def parse_keysafe(file):
vmx_ks = ks_struct
# vmx_ks['id'] = hexlify(base64.b64decode(match.group(1))).decode()
vmx_ks['password_hash'] = match.group(2)
if vmx_ks['password_hash'] != 'PBKDF2-HMAC-SHA-1':
msg = 'Unsupported password hash format: ' + vmx_ks['password_hash']
@@ -55,11 +54,9 @@ def parse_keysafe(file):
msg = 'Unsupported cypher format: ' + vmx_ks['password_cypher']
raise ValueError(msg)
vmx_ks['hash_round'] = int(match.group(4))
vmx_ks['salt'] = base64.b64decode(unquote(match.group(5)))
# vmx_ks['config_hash'] = match.group(6)
vmx_ks['dict'] = base64.b64decode(match.group(7))
vmx_ks['dict'] = base64.b64decode(match.group(7))[0:32]
return vmx_ks