Crypt::PWSafe3 already prefers Bytes::Random::Secure over Crypt::Random but
still has a hard dependency on it, via an unconditional "use Crypt::Random".
This is no longer necessary since Crypt::Random will be require-d if a
suitably recent version of Bytes::Random::Secure cannot be found.
The Makefile.PL is also updated to reflect this approach.
was installed ended up with:
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/run.t .. 1/?
# Failed test 'open a pwsafe3 database'
# at t/run.t line 36.
# Failed test 'read a pwsafe3 database and change a record (Undefined subroutine &Crypt::PWSafe3::random_bytes called at /home/marcink/.cpan/build/Crypt-PWSafe3-1.06-qScJdO/blib/lib/Crypt/PWSafe3.pm line 56.
# )'
# at t/run.t line 66.
(and more such errors).
Note: I am not sure about return value. Currently I return "did I delete
sth flag", alternatively one could return deleted record, or even croak
if record was not there.
Attempt to improve performance.
Previous implementation happened to be very slow (on my laptop it took 5
minutes to read small pwsafe file and save it back). I profiled the code
and it turned out, this cost was totally dominated by the
Crypt::PWSafe3::random function (which on every call accesses system
random seed).
I replaced it with Bytes::Random::Secure which seeds using OS crypto but
afterwards uses embedded generator. Performance improvement is drastical,
the same read&save takes about half a second on the same laptop.
Resolved problem with warnings
Use of uninitialized value within %map2name in hash element at /usr/local/share/perl/5.14.2/Crypt/PWSafe3/Record.pm line 140.
occuring on true PasswordSafe file.
I am not sure whether this could cause some data to be dropped, but the fix seems consistent with the other code.