sha512-sparcv9.pl: minor optimization of sha256.
[openssl.git] / fips / fipsalgtest.pl
index 2228592d31d56f9af104ec2cd5caadd17287b785..094b141065130e91e97b15f3cc09a0b162f85450 100644 (file)
@@ -266,6 +266,52 @@ my @fips_aes_cfb1_test_list = (
 
 );
 
+my @fips_aes_ccm_test_list = (
+
+    # AES CCM tests
+
+    "AES CCM",
+
+    [ "DVPT128",  "fips_gcmtest -ccm" ],
+    [ "DVPT192",  "fips_gcmtest -ccm" ],
+    [ "DVPT256",  "fips_gcmtest -ccm" ],
+    [ "VADT128",  "fips_gcmtest -ccm" ],
+    [ "VADT192",  "fips_gcmtest -ccm" ],
+    [ "VADT256",  "fips_gcmtest -ccm" ],
+    [ "VNT128",  "fips_gcmtest -ccm" ],
+    [ "VNT192",  "fips_gcmtest -ccm" ],
+    [ "VNT256",  "fips_gcmtest -ccm" ],
+    [ "VPT128",  "fips_gcmtest -ccm" ],
+    [ "VPT192",  "fips_gcmtest -ccm" ],
+    [ "VPT256",  "fips_gcmtest -ccm" ],
+    [ "VTT128",  "fips_gcmtest -ccm" ],
+    [ "VTT192",  "fips_gcmtest -ccm" ],
+    [ "VTT256",  "fips_gcmtest -ccm" ]
+
+);
+
+my @fips_aes_gcm_test_list = (
+
+    # AES GCM tests
+
+    "AES GCM",
+
+    [ "gcmDecrypt128",  "fips_gcmtest -decrypt" ],
+    [ "gcmDecrypt192",  "fips_gcmtest -decrypt" ],
+    [ "gcmDecrypt256",  "fips_gcmtest -decrypt" ],
+
+);
+
+my @fips_aes_xts_test_list = (
+    # AES XTS tests
+
+    "AES XTS",
+
+    [ "XTSGenAES128",  "fips_gcmtest -xts" ],
+    [ "XTSGenAES256",  "fips_gcmtest -xts" ],
+
+);
+
 # Triple DES tests
 
 my @fips_des3_test_list = (
@@ -348,6 +394,36 @@ my @fips_des3_cfb1_test_list = (
 
 );
 
+my @fips_drbg_test_list = (
+
+    # SP800-90 DRBG tests
+    "SP800-90 DRBG",
+    [ "CTR_DRBG",   "fips_drbgvs" ],
+    [ "Hash_DRBG",  "fips_drbgvs" ]
+
+);
+
+my @fips_dh_test_list = (
+
+    # DH
+    "DH Ephemeral Primitives Only",
+    [ "KASValidityTest_FFCEphem_NOKC_ZZOnly_init",   "fips_dhvs dhver" ],
+    [ "KASValidityTest_FFCEphem_NOKC_ZZOnly_resp",   "fips_dhvs dhver" ],
+
+);
+
+my @fips_ecdh_test_list = (
+
+    # ECDH
+    "ECDH Ephemeral Primitives Only",
+    [ "KASValidityTest_ECCEphemeralUnified_NOKC_ZZOnly_init",
+                                                       "fips_ecdhvs ecdhver" ],
+    [ "KASValidityTest_ECCEphemeralUnified_NOKC_ZZOnly_resp",
+                                                       "fips_ecdhvs ecdhver" ],
+
+);
+
+
 # Verification special cases.
 # In most cases the output of a test is deterministic and
 # it can be compared to a known good result. A few involve
@@ -384,6 +460,10 @@ my $bufout         = '';
 my $list_tests     = 0;
 my $minimal_script = 0;
 my $outfile        = '';
+my $no_warn_missing = 0;
+my $no_warn_bogus = 0;
+my $rmcmd = "rm -rf";
+my $mkcmd = "mkdir";
 
 my %fips_enabled = (
     dsa         => 1,
@@ -399,7 +479,13 @@ my %fips_enabled = (
     aes         => 1,
     "aes-cfb1"  => 0,
     des3        => 1,
-    "des3-cfb1" => 0
+    "des3-cfb1" => 0,
+    drbg       => 0,
+    ccm                => 0,
+    "aes-xts"  => 0,
+    gcm                => 0,
+    dh         => 0,
+    ecdh       => 0,
 );
 
 foreach (@ARGV) {
@@ -412,9 +498,17 @@ foreach (@ARGV) {
     elsif ( $_ eq "--debug" ) {
         $debug = 1;
     }
+    elsif ( $_ eq "--quiet-missing" ) {
+        $ignore_missing = 1;
+        $no_warn_missing = 1;
+    }
     elsif ( $_ eq "--ignore-missing" ) {
         $ignore_missing = 1;
     }
+    elsif ( $_ eq "--quiet-bogus" ) {
+        $ignore_bogus = 1;
+       $no_warn_bogus = 1;
+    }
     elsif ( $_ eq "--ignore-bogus" ) {
         $ignore_bogus = 1;
     }
@@ -445,6 +539,7 @@ foreach (@ARGV) {
     elsif (/^--(enable|disable)-(.*)$/) {
         if ( !exists $fips_enabled{$2} ) {
             print STDERR "Unknown test $2\n";
+           exit(1);
         }
         if ( $1 eq "enable" ) {
             $fips_enabled{$2} = 1;
@@ -456,6 +551,15 @@ foreach (@ARGV) {
     elsif (/--filter=(.*)$/) {
         $filter = $1;
     }
+    elsif (/--rm=(.*)$/) {
+        $rmcmd = $1;
+    }
+    elsif (/--script-tprefix=(.*)$/) {
+        $stprefix = $1;
+    }
+    elsif (/--mkdir=(.*)$/) {
+        $mkcmd = $1;
+    }
     elsif (/^--list-tests$/) {
         $list_tests = 1;
     }
@@ -481,6 +585,12 @@ push @fips_test_list, @fips_aes_test_list       if $fips_enabled{"aes"};
 push @fips_test_list, @fips_aes_cfb1_test_list  if $fips_enabled{"aes-cfb1"};
 push @fips_test_list, @fips_des3_test_list      if $fips_enabled{"des3"};
 push @fips_test_list, @fips_des3_cfb1_test_list if $fips_enabled{"des3-cfb1"};
+push @fips_test_list, @fips_drbg_test_list     if $fips_enabled{"drbg"};
+push @fips_test_list, @fips_aes_ccm_test_list  if $fips_enabled{"aes-ccm"};
+push @fips_test_list, @fips_aes_gcm_test_list  if $fips_enabled{"aes-gcm"};
+push @fips_test_list, @fips_aes_xts_test_list  if $fips_enabled{"aes-xts"};
+push @fips_test_list, @fips_dh_test_list       if $fips_enabled{"dh"};
+push @fips_test_list, @fips_ecdh_test_list     if $fips_enabled{"ecdh"};
 
 if ($list_tests) {
     my ( $test, $en );
@@ -648,7 +758,7 @@ sub find_files {
                     }
                 }
                 else {
-                    print STDERR "WARNING: bogus file $_\n";
+                    print STDERR "WARNING: bogus file $_\n" unless $no_warn_bogus;
                     $nbogus++;
                 }
             }
@@ -668,7 +778,7 @@ sub find_files {
 
                 }
                 elsif ( !/SHAmix\.req$/ ) {
-                    print STDERR "WARNING: unrecognized filename $_\n";
+                    print STDERR "WARNING: unrecognized filename $_\n" unless $no_warn_bogus;
                     $nbogus++;
                 }
             }
@@ -716,7 +826,7 @@ sub sanity_check_files {
 
         #print STDERR "FILES $tst, $cmd, $req, $resp\n";
         if ( $req eq "" ) {
-            print STDERR "WARNING: missing request file for $tst\n";
+            print STDERR "WARNING: missing request file for $tst\n" unless $no_warn_missing;
             $bad = 1;
             next;
         }
@@ -762,7 +872,8 @@ echo Running Algorithm Tests
 
 END
        } else {
-           print OUT <<\END;
+       $stprefix = $tprefix unless defined $stprefix;
+           print OUT <<END;
 #!/bin/sh
 
 # Test vector run script
@@ -771,6 +882,10 @@ END
 
 echo Running Algorithm Tests
 
+RM="$rmcmd";
+MKDIR="$mkcmd";
+TPREFIX=$stprefix
+
 END
        }
 
@@ -793,7 +908,7 @@ END
         }
         if ( $req eq "" ) {
             print STDERR
-              "WARNING: Request file for $tname missing: test skipped\n";
+              "WARNING: Request file for $tname missing: test skipped\n" unless $no_warn_missing;
             $skipcnt++;
             next;
         }
@@ -827,8 +942,8 @@ md \"$outdir\"
 END
                    } else {
                    print OUT <<END
-rm -rf \"$outdir\"
-mkdir \"$outdir\"
+\$RM \"$outdir\"
+\$MKDIR \"$outdir\"
 
 END
                    }
@@ -839,12 +954,13 @@ END
                 mkdir($outdir) || die "Can't create directory $outdir";
             }
         }
-        my $cmd = "$tprefix$tcmd \"$req\" \"$out\"";
+        my $cmd = "$tcmd \"$req\" \"$out\"";
         print STDERR "DEBUG: running test $tname\n" if ( $debug && !$verify );
        if ($outfile ne "") {
            print OUT "echo \"    running $tname test\"\n" unless $minimal_script;
-           print OUT "$cmd\n";
+           print OUT "\${TPREFIX}$cmd\n";
         } else {
+            $cmd = "$tprefix$cmd";
             system($cmd);
             if ( $? != 0 ) {
                print STDERR