From: Dr. Stephen Henson Date: Thu, 8 Nov 2007 18:01:06 +0000 (+0000) Subject: Update mkfipsscr.pl to perform some sanity checks on testvector tree. X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a3a426cfb52e7bad402e8725adfb1b491e96c1be;p=oweals%2Fopenssl.git Update mkfipsscr.pl to perform some sanity checks on testvector tree. --- diff --git a/fips/mkfipsscr.pl b/fips/mkfipsscr.pl index 8f1275c7b5..d55c1146be 100644 --- a/fips/mkfipsscr.pl +++ b/fips/mkfipsscr.pl @@ -1,5 +1,11 @@ #!/usr/local/bin/perl -w +# Quick & dirty utility to generate a script for executing the +# FIPS 140-2 CMVP algorithm tests based on the pathnames of +# input algorithm test files actually present (the unqualified +# file names are consistent but the pathnames are not). +# +# List of all the unqualified file names we expect. my %fips_tests = ( # FIPS test definitions @@ -277,8 +283,15 @@ my %fips_tests = ( "TOFBvartext" => "fips_desmovs -f" ); +my %salt_names = ( +"SigVerPSS (salt 0)" => "SigVerPSS", +"SigVerPSS (salt 62)" => "SigVerPSS", +"SigGenPSS (salt 0)" => "SigGenPSS", +"SigGenPSS (salt 62)" => "SigGenPSS", +); + -my $win32 = 0; +my $win32 = $^O =~ m/mswin/i; my $onedir = 0; my $filter = ""; my $tvdir; @@ -287,6 +300,10 @@ my $shwrap_prefix; my $debug = 0; my $quiet = 0; my $rspdir = "rsp"; +my $rspignore = 0; +my @bogus = (); # list of unmatched *.rsp files +my $bufout = ''; +my %_programs = (); # list of external programs to check foreach (@ARGV) { @@ -314,6 +331,10 @@ foreach (@ARGV) { $rspdir = $1; } + elsif (/--rspignore$/) + { + $rspignore = 1; + } elsif (/--tprefix=(.*)$/) { $tprefix = $1; @@ -330,6 +351,11 @@ foreach (@ARGV) { $outfile = $1; } + else + { + &Help(); + exit(1); + } } $tvdir = "." unless defined $tvdir; @@ -347,10 +373,8 @@ if ($win32) $tprefix = "..\\out32dll\\"; } } - $outfile = "fipstests.bat" unless defined $outfile; - open(OUT, ">$outfile"); - print OUT <$outfile"); - print OUT <$outfile") || die "Error opening $outfile: $!"; + print OUT $bufinit; + if (!$rspignore && @bogus) + { + print STDERR "ERROR: please remove bogus *.rsp files\n"; + print OUT < Optional root for *.req file search + --filter= + --onedir Assume all components in current directory + --outfile= Optional name of output script, default fipstests.{sh|bat} + --rspdir= Name of subdirectories containing *.rsp files, default "resp" + --rspignore Ignore any bogus *.rsp files + --shwrap_prefix= + --tprefix= + --quiet Shhh.... + --win32 Generate script for Win32 environment +EOF +} + +#-------------------------------- +sub countentry { + my ($key,$value) = @_; if ($value == 0) { print STDERR "WARNING: test file $key not found\n" unless $quiet; @@ -408,7 +489,7 @@ while (($key, $value) = each %fips_found) } } - +#-------------------------------- sub recurse_test { my ($win32, $tprefix, $filter, $dir) = @_; @@ -420,17 +501,29 @@ sub recurse_test $_ = "$dir/$_"; if (-f "$_") { + if (/\/([^\/]*)\.rsp$/) + { + if (exists $fips_tests{$1}) + { + $debug && print "DEBUG: $1 found, will be overwritten\n"; + } + else + { + print STDERR "ERROR: bogus file $_\n"; + push @bogus, $_; + } + } next unless /$filter.*\.req$/i; if (/\/([^\/]*)\.req$/ && exists $fips_tests{$1}) { $fips_found{$1}++; - test_line($win32, $_, $tprefix, $fips_tests{$1}); + test_line($win32, $_, $tprefix, $1); } elsif (! /SHAmix\.req$/) { print STDERR "WARNING: unrecognized filename $_\n"; } - } + } elsif (-d "$_") { if (/$filter.*req$/i) @@ -443,6 +536,7 @@ sub recurse_test closedir($dirh); } +#-------------------------------- sub test_dir { my ($win32, $req) = @_; @@ -452,7 +546,7 @@ sub test_dir { $rsp =~ tr|/|\\|; $req =~ tr|/|\\|; - print OUT < \"$rsp\"\n"; + $bufout .= "$tprefix$tcmd < \"$req\" > \"$rsp\"\n"; + $_programs{"$tprefix$tcmd.exe"} = 1; } else { - print OUT < "$rsp" || { echo "$req failure" ; exit 1; } END + $_programs{"$tprefix$tcmd"} = 1; } }