mirror of
https://codeberg.org/scip/Crypt--PWSafe3.git
synced 2025-12-16 20:21:01 +01:00
avoid blocking /dev/random on cpantesters systems
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
NEXT:
|
1.17:
|
||||||
added license to META
|
added license to META
|
||||||
|
|
||||||
open tmpfiles with O_EXLOCK disabled (cpantesters)
|
open tmpfiles with O_EXLOCK disabled (cpantesters)
|
||||||
@@ -16,6 +16,10 @@ NEXT:
|
|||||||
replaced "new $perl::$object" with $perl::$object->new()
|
replaced "new $perl::$object" with $perl::$object->new()
|
||||||
everywhere.
|
everywhere.
|
||||||
|
|
||||||
|
using weak random source for unit tests to avoid blocking
|
||||||
|
/dev/random on cpantesters systems with heavy entropy
|
||||||
|
load.
|
||||||
|
|
||||||
1.16
|
1.16
|
||||||
re-licensed from artistic1 to artistic2 in order to be
|
re-licensed from artistic1 to artistic2 in order to be
|
||||||
compatible to fedora packaging. no code changes otherwise
|
compatible to fedora packaging. no code changes otherwise
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ use Digest::SHA;
|
|||||||
use Crypt::Random qw( makerandom );
|
use Crypt::Random qw( makerandom );
|
||||||
use Data::UUID;
|
use Data::UUID;
|
||||||
use File::Copy qw(copy move);
|
use File::Copy qw(copy move);
|
||||||
#use File::Spec;
|
|
||||||
use File::Temp;
|
use File::Temp;
|
||||||
use FileHandle;
|
use FileHandle;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
@@ -176,7 +175,6 @@ sub create {
|
|||||||
|
|
||||||
# encrypt b1 .. b4
|
# encrypt b1 .. b4
|
||||||
my $crypt = Crypt::ECB->new;
|
my $crypt = Crypt::ECB->new;
|
||||||
#$crypt->padding(PADDING_AUTO);
|
|
||||||
$crypt->cipher('Twofish');
|
$crypt->cipher('Twofish');
|
||||||
$crypt->key( $this->strechedpw() );
|
$crypt->key( $this->strechedpw() );
|
||||||
$this->b1( $crypt->encrypt( $this->random(16) ) );
|
$this->b1( $crypt->encrypt( $this->random(16) ) );
|
||||||
|
|||||||
17
t/run.t
17
t/run.t
@@ -15,6 +15,7 @@ use Data::Dumper;
|
|||||||
use Test::More tests => 11;
|
use Test::More tests => 11;
|
||||||
#use Test::More qw(no_plan);
|
#use Test::More qw(no_plan);
|
||||||
|
|
||||||
|
|
||||||
my %params = (create => 0, password => 'tom');
|
my %params = (create => 0, password => 'tom');
|
||||||
|
|
||||||
my %record = (
|
my %record = (
|
||||||
@@ -25,6 +26,8 @@ my %record = (
|
|||||||
notes => 'n3'
|
notes => 'n3'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub rdpw {
|
sub rdpw {
|
||||||
my $file = shift;
|
my $file = shift;
|
||||||
my $vault = Crypt::PWSafe3->new(file => $file, %params) or die "$!";
|
my $vault = Crypt::PWSafe3->new(file => $file, %params) or die "$!";
|
||||||
@@ -36,6 +39,18 @@ sub rdpw {
|
|||||||
BEGIN { use_ok "Crypt::PWSafe3"};
|
BEGIN { use_ok "Crypt::PWSafe3"};
|
||||||
require_ok( 'Crypt::PWSafe3' );
|
require_ok( 'Crypt::PWSafe3' );
|
||||||
|
|
||||||
|
# I'm going to replace the secure random number generator
|
||||||
|
# backends with this very primitive and insecure one, because
|
||||||
|
# these are only unit tests and because we use external modules
|
||||||
|
# for the purpose anyway (which are not to be tested with these
|
||||||
|
# unit tests).
|
||||||
|
# This has to be done, so that unit tests running on cpantesters
|
||||||
|
# don't block if we use a real random source, which has reportedly
|
||||||
|
# happened in the past.
|
||||||
|
# ***** CAUTION: DO NOT USE THIS CODE IN PRODUCTION. EVER. ****
|
||||||
|
*Crypt::PWSafe3::random = sub { return join'',map{chr(int(rand(255)))}(1..$_[1]); };
|
||||||
|
|
||||||
|
|
||||||
### 2
|
### 2
|
||||||
# open vault and read in all records
|
# open vault and read in all records
|
||||||
eval {
|
eval {
|
||||||
@@ -62,7 +77,7 @@ my $tmpfile = "$fd";
|
|||||||
close($fd);
|
close($fd);
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
my $vault = Crypt::PWSafe3->new(file => $tmpfile, password => 'tom') or die "$!";
|
my $vault = Crypt::PWSafe3->new(file => $tmpfile, password => 'tom', random => $trand) or die "$!";
|
||||||
$vault->newrecord(%record);
|
$vault->newrecord(%record);
|
||||||
$vault->save();
|
$vault->save();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user