Subject: | Crypt-DSA-0.13 patch for MSWin32 support |
I'm running perl 5.8.8, built with mingw gcc 3.4.5, on Windows XP.
Attached are patches for:
lib/Crypt/DSA/KeyChain.pm
lib/Crypt/DSA/Util.pm
Makefile.PL
I've changed KeyChain::generate_params() so that it uses 'openssl.exe'
on windows instead of 'openssl'.
I've also changed Util::makerandom() so that if it can't open
/dev/random, it tries to load Data::Random.
(Crypt::Random is no use for windows, as it still uses /dev/random in
the background)
I've also changed makerandom(), so that if it then fails to load
Data::Random, it calls croak() rather than returning undef and going
into an infinite loop.
The Makefile.PL has been changed so that Data::Random is required on
MSWin32.
I hope the patches are suitable.
Please contact my cpan email address if you want to test anything
further on a windows box.
Subject: | KeyChain.pm.patch |
7a8,10
> use IPC::Open3;
> use File::Spec;
> use Symbol qw( gensym );
31c34,35
< my $openssl = `which openssl`;
---
> my $bin = $^O eq 'MSWin32' ? 'openssl.exe' : 'openssl';
> my $openssl = `which $bin`;
36c40,46
< my @res = `$openssl dsaparam -text -noout $bits_n 2>/dev/null`;
---
> open( NULL, ">", File::Spec->devnull );
> my $pid = open3( gensym, \*OPENSSL, ">&NULL", "$openssl dsaparam -text -noout $bits_n" );
> my @res;
> while( <OPENSSL> ) {
> push @res, $_;
> }
> waitpid( $pid, 0 );
Subject: | Makefile.PL.patch |
16a17
> requires('Data::Random' => '0.05') if $^O eq 'MSWin32';
Subject: | Util.pm.patch |
7a8
> use Carp qw( croak );
53,61c54,70
< sysopen my $fh, '/dev/random', O_RDONLY
< or return;
< my($r, $read) = ('', 0);
< while ($read < $bytes) {
< my $got = sysread $fh, my($chunk), $bytes - $read;
< next unless $got;
< die "Error: $!" if $got == -1;
< $r .= $chunk;
< $read = length $r;
---
> my $r = '';
> if ( sysopen my $fh, '/dev/random', O_RDONLY ) {
> my $read = 0;
> while ($read < $bytes) {
> my $got = sysread $fh, my($chunk), $bytes - $read;
> next unless $got;
> die "Error: $!" if $got == -1;
> $r .= $chunk;
> $read = length $r;
> }
> close $fh;
> }
> elsif ( require Data::Random ) {
> $r .= Data::Random::rand_chars( set=>'numeric' ) for 1..$bytes;
> }
> else {
> croak "makerandom requires /dev/random or Data::Random";
63d71
< close $fh;