mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-08-14 14:34:56 +00:00
encrypt_pw: avoid '+' for crypt salt
And make salt less predictable.
This commit is contained in:
parent
0835385bea
commit
54028297ea
@ -130,11 +130,18 @@ sub parse_tfa_config {
|
||||
return $res;
|
||||
}
|
||||
|
||||
my $salt_starter = time();
|
||||
|
||||
sub encrypt_pw {
|
||||
my ($pw) = @_;
|
||||
|
||||
my $time = substr(Digest::SHA::sha1_base64 (time), 0, 8);
|
||||
return crypt(encode("utf8", $pw), "\$5\$$time\$");
|
||||
$salt_starter++;
|
||||
my $salt = substr(Digest::SHA::sha1_base64(time() + $salt_starter + $$), 0, 8);
|
||||
|
||||
# crypt does not want '+' in salt (see 'man crypt')
|
||||
$salt =~ s/\+/X/g;
|
||||
|
||||
return crypt(encode("utf8", $pw), "\$5\$$salt\$");
|
||||
}
|
||||
|
||||
my $defaultData = {
|
||||
|
Loading…
Reference in New Issue
Block a user