made Bytes::Random::Secure optional, version++

This commit is contained in:
git@daemon.de
2012-11-19 11:57:15 +01:00
parent cda77bea88
commit 3d80bb1608
5 changed files with 57 additions and 20 deletions

View File

@@ -1,9 +1,16 @@
1.06
applied patch by https://github.com/Mekk:
https://github.com/TLINDEN/Crypt--PWSafe3/pull/2,
adds new function "deleterecord()", improves performance
when using Bytes::Random::Secure[now optional] and fixes
an error in ::Record::addfield().
1.05 1.05
applied patch by https://github.com/Mekk: applied patch by https://github.com/Mekk:
https://github.com/TLINDEN/Crypt--PWSafe3/pull/1, https://github.com/TLINDEN/Crypt--PWSafe3/pull/1,
which replaces use of cp and mv commands with File::Copy. which replaces use of cp and mv commands with File::Copy.
this makes it portable. this makes it portable.
1.04 1.04
fixed rt.cpan.org#75145. uninitialized fields lead to fixed rt.cpan.org#75145. uninitialized fields lead to

View File

@@ -1,6 +1,18 @@
require 5.004; require 5.004;
use ExtUtils::MakeMaker; use ExtUtils::MakeMaker;
my %optional = (
'Bytes::Random::Secure' => 0.09,
);
foreach my $module (sort keys %optional) {
eval "require $module";
if ($@) {
warn("Optional module $module not installed, $optional{$module}\n");
}
}
WriteMakefile( WriteMakefile(
'NAME' => 'Crypt::PWSafe3', 'NAME' => 'Crypt::PWSafe3',
'VERSION_FROM' => 'lib/Crypt/PWSafe3.pm', 'VERSION_FROM' => 'lib/Crypt/PWSafe3.pm',
@@ -12,7 +24,6 @@ WriteMakefile(
'Crypt::Random' => 1.25, 'Crypt::Random' => 1.25,
'Data::UUID' => 1.217, 'Data::UUID' => 1.217,
'Shell' => 0.5, 'Shell' => 0.5,
'Bytes::Random::Secure' => 0.09,
}, },
'AUTHOR' => 'Thomas Linden <tlinden@cpan.org>', 'AUTHOR' => 'Thomas Linden <tlinden@cpan.org>',
'clean' => { 'clean' => {

2
README
View File

@@ -49,5 +49,5 @@ AUTHOR
VERSION VERSION
1.05 1.06

View File

@@ -22,13 +22,42 @@ use Data::Dumper;
use Exporter (); use Exporter ();
use vars qw(@ISA @EXPORT); use vars qw(@ISA @EXPORT);
$Crypt::PWSafe3::VERSION = '1.05'; $Crypt::PWSafe3::VERSION = '1.06';
use Crypt::PWSafe3::Field; use Crypt::PWSafe3::Field;
use Crypt::PWSafe3::HeaderField; use Crypt::PWSafe3::HeaderField;
use Crypt::PWSafe3::Record; use Crypt::PWSafe3::Record;
use Crypt::PWSafe3::SHA256; 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 my @fields = qw(tag salt iter shaps b1 b2 b3 b4 keyk file program
keyl iv hmac header strechedpw password whoami); keyl iv hmac header strechedpw password whoami);
foreach my $field (@fields) { 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 { sub getheader {
# #
@@ -845,6 +860,10 @@ type with according values. Refer to L<Crypt::PWSafe3::Record>
for details about available fields. for details about available fields.
=head2 B<deleterecord(uuid)>
Delete the record identified by the given UUID.
=head2 B<save([parameter-hash])> =head2 B<save([parameter-hash])>
Save the current password safe vault back to disk. 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 =head1 VERSION
Crypt::PWSafe3 Version 1.05. Crypt::PWSafe3 Version 1.06.
=cut =cut

View File

@@ -9,7 +9,7 @@ my %map2type = %Crypt::PWSafe3::Field::map2type;
my %map2name = %Crypt::PWSafe3::Field::map2name; my %map2name = %Crypt::PWSafe3::Field::map2name;
$Crypt::PWSafe3::Record::VERSION = '1.03'; $Crypt::PWSafe3::Record::VERSION = '1.04';
foreach my $field (keys %map2type ) { foreach my $field (keys %map2type ) {
eval qq( eval qq(