Subject: | Self test fails. |
Attached is a test script that essentially loops over signature creation and
verification.
It demonstrates failures and unpredictable results.
Once this is fixed I also have a feature request. Instead of reading the PEM encoded key from a file I would like to be able to pass the PEM encoded keys around as strings. (I have to construct them myself and writing them to file gives a little overhead).
I hope you will get this fixed soon. I am trying to port Net::DNS::SEC so that Crypt::DSA (and thus Math::Pari ) is not needed.
--Olaf
Version information:
Crypt::OpenSSL 0.03
openssl version
OpenSSL 0.9.6g 9 Aug 2002
uname -a
FreeBSD pinkje 4.7-RC FreeBSD 4.7-RC #21: Thu Sep 19 00:14:10 EEST 2002 root@pinkje:/divers/usr.obj/divers/usr.src/sys/VAIO i386
perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=freebsd, osvers=4.6-stable, archname=i386-freebsd
uname='freebsd pinkje.secret-wg.org 4.6-stable freebsd 4.6-stable #19: mon aug 12 22:20:32 jst 2002 toor@pinkje.secret-wg.org:diversusr.objdiversusr.srcsysvaio i386 '
config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.6.1/mach -Dprivlib=/usr/local/lib/perl5/5.6.1 -Dman3dir=/usr/local/lib/perl5/5.6.1/man/man3 -Dsitearch=/usr/local/lib/perl5/site_perl/5.6.1/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.6.1 -Ui_malloc -Ui_iconv -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.6.1/BSDPAN" -Ui_gdbm -Dusemymalloc=n'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.6.1/BSDPAN" -fno-strict-aliasing -I/usr/local/include',
optimize='-O -pipe ',
cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.6.1/BSDPAN" -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.4 20020320 [FreeBSD]', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags ='-Wl,-E -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
libs=-lgdbm -lm -lc -lcrypt -lutil
perllibs=-lm -lc -lcrypt -lutil
libc=, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under freebsd
Compiled at Aug 12 2002 23:25:53
@INC:
/usr/local/lib/perl5/site_perl/5.6.1/mach
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.6.1/BSDPAN
/usr/local/lib/perl5/5.6.1/mach
/usr/local/lib/perl5/5.6.1
use Crypt::OpenSSL::DSA;
my $prifilename="/tmp/test.dsa.pri";
my $pubfilename="/tmp/test.dsa.pub";
my $message="Test message";
# generate keys and write out to PEM files
my $dsa = Crypt::OpenSSL::DSA->generate_parameters( 512 );
$dsa->generate_key;
$dsa->write_pub_key( $pubfilename );
$dsa->write_priv_key( $prifilename );
for (my $i=0;$i<20;$i++){
# using keys from PEM files
my $dsa_priv = Crypt::OpenSSL::DSA->read_priv_key( $prifilename );
my $sig = $dsa_priv->sign($message);
my $dsa_pub = Crypt::OpenSSL::DSA->read_pub_key( $pubfilename );
my $valid = $dsa_pub->verify($message, $sig);
print "VALID:".$valid."\n";
}