mirror of
https://codeberg.org/scip/Crypt--PWSafe3.git
synced 2025-12-17 04:31:00 +01:00
made Bytes::Random::Secure optional, version++
This commit is contained in:
@@ -22,13 +22,42 @@ use Data::Dumper;
|
||||
use Exporter ();
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
$Crypt::PWSafe3::VERSION = '1.05';
|
||||
$Crypt::PWSafe3::VERSION = '1.06';
|
||||
|
||||
use Crypt::PWSafe3::Field;
|
||||
use Crypt::PWSafe3::HeaderField;
|
||||
use Crypt::PWSafe3::Record;
|
||||
use Crypt::PWSafe3::SHA256;
|
||||
|
||||
#
|
||||
# check, which random source to use.
|
||||
# install a wrapper closure around the
|
||||
# one we found.
|
||||
BEGIN {
|
||||
eval { require Bytes::Random::Secure };
|
||||
if ($@) {
|
||||
# well, didn' work, use slow function
|
||||
eval { require Crypt::Random; };# qw( makerandom ); };
|
||||
if ($@) {
|
||||
croak "Could not find either Crypt::Random or Bytes::Random::Secure. Install one of them and retry!";
|
||||
}
|
||||
else {
|
||||
*Crypt::PWSafe3::random = sub {
|
||||
my($this, $len) = @_;
|
||||
my $bits = makerandom(Size => 256, Strength => 1);
|
||||
return substr($bits, 0, $len);
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
# good. use the faster one
|
||||
*Crypt::PWSafe3::random = sub {
|
||||
my($this, $len) = @_;
|
||||
return random_bytes($len);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
my @fields = qw(tag salt iter shaps b1 b2 b3 b4 keyk file program
|
||||
keyl iv hmac header strechedpw password whoami);
|
||||
foreach my $field (@fields) {
|
||||
@@ -641,20 +670,6 @@ sub writebytes {
|
||||
}
|
||||
}
|
||||
|
||||
# This is original, very slow random
|
||||
#sub random {
|
||||
# #
|
||||
# # helper, return some secure random bytes
|
||||
# my($this, $len) = @_;
|
||||
# my $bits = makerandom(Size => 256, Strength => 1);
|
||||
# return substr($bits, 0, $len);
|
||||
#}
|
||||
|
||||
use Bytes::Random::Secure qw(random_bytes random_bytes_hex);
|
||||
sub random {
|
||||
my($this, $len) = @_;
|
||||
return random_bytes($len);
|
||||
}
|
||||
|
||||
sub getheader {
|
||||
#
|
||||
@@ -845,6 +860,10 @@ type with according values. Refer to L<Crypt::PWSafe3::Record>
|
||||
for details about available fields.
|
||||
|
||||
|
||||
=head2 B<deleterecord(uuid)>
|
||||
|
||||
Delete the record identified by the given UUID.
|
||||
|
||||
=head2 B<save([parameter-hash])>
|
||||
|
||||
Save the current password safe vault back to disk.
|
||||
@@ -928,7 +947,7 @@ and/or modify it under the same terms as Perl itself.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Crypt::PWSafe3 Version 1.05.
|
||||
Crypt::PWSafe3 Version 1.06.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
Reference in New Issue
Block a user