Use Bytes::Random::Secure instead of deprecated Data-Entropy. Fall back to Data-Entropy. Fixes #4333
parent
3ee0057130
commit
38c0f743c1
|
@ -1041,7 +1041,18 @@ sub patchDB {
|
||||||
|
|
||||||
sub migratePasswords {
|
sub migratePasswords {
|
||||||
use Crypt::Eksblowfish::Bcrypt;
|
use Crypt::Eksblowfish::Bcrypt;
|
||||||
use Data::Entropy::Algorithms qw(rand_bits);
|
my $random;
|
||||||
|
eval {
|
||||||
|
require Bytes::Random::Secure;
|
||||||
|
$random = Bytes::Random::Secure->new( Bits => 16*8);
|
||||||
|
};
|
||||||
|
if ($@ or !$random) {
|
||||||
|
eval {
|
||||||
|
require Data::Entropy::Algorithms;
|
||||||
|
$random =Data::Entropy::Algorithms::rand_bits(16*8);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
print("Migratings passwords, if any...\n");
|
print("Migratings passwords, if any...\n");
|
||||||
my $sql = 'SELECT * FROM `Users`';
|
my $sql = 'SELECT * FROM `Users`';
|
||||||
my $sth = $dbh->prepare_cached($sql) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
my $sth = $dbh->prepare_cached($sql) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
@ -1050,7 +1061,7 @@ sub migratePasswords {
|
||||||
my $scheme = substr($user->{Password}, 0, 1);
|
my $scheme = substr($user->{Password}, 0, 1);
|
||||||
if ($scheme eq '*') {
|
if ($scheme eq '*') {
|
||||||
print('-->'.$user->{Username}." password will be migrated\n");
|
print('-->'.$user->{Username}." password will be migrated\n");
|
||||||
my $salt = Crypt::Eksblowfish::Bcrypt::en_base64(rand_bits(16*8));
|
my $salt = Crypt::Eksblowfish::Bcrypt::en_base64($random);
|
||||||
my $settings = '$2a$10$'.$salt;
|
my $settings = '$2a$10$'.$salt;
|
||||||
my $pass_hash = Crypt::Eksblowfish::Bcrypt::bcrypt($user->{Password},$settings);
|
my $pass_hash = Crypt::Eksblowfish::Bcrypt::bcrypt($user->{Password},$settings);
|
||||||
my $new_pass_hash = '-ZM-'.$pass_hash;
|
my $new_pass_hash = '-ZM-'.$pass_hash;
|
||||||
|
|
Loading…
Reference in New Issue