sha512-sparcv9.pl: minor optimization of sha256.
[openssl.git] / fips / fipsalgtest.pl
index 079b00624d1047aa4b56b20bf12e6d4487796293..094b141065130e91e97b15f3cc09a0b162f85450 100644 (file)
@@ -290,6 +290,28 @@ my @fips_aes_ccm_test_list = (
 
 );
 
+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 = (
@@ -377,7 +399,27 @@ my @fips_drbg_test_list = (
     # SP800-90 DRBG tests
     "SP800-90 DRBG",
     [ "CTR_DRBG",   "fips_drbgvs" ],
-    [ "Hash_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" ],
 
 );
 
@@ -419,6 +461,9 @@ 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,
@@ -437,6 +482,10 @@ my %fips_enabled = (
     "des3-cfb1" => 0,
     drbg       => 0,
     ccm                => 0,
+    "aes-xts"  => 0,
+    gcm                => 0,
+    dh         => 0,
+    ecdh       => 0,
 );
 
 foreach (@ARGV) {
@@ -456,6 +505,10 @@ foreach (@ARGV) {
     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;
     }
@@ -486,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;
@@ -497,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;
     }
@@ -524,6 +587,10 @@ 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 );
@@ -691,7 +758,7 @@ sub find_files {
                     }
                 }
                 else {
-                    print STDERR "WARNING: bogus file $_\n";
+                    print STDERR "WARNING: bogus file $_\n" unless $no_warn_bogus;
                     $nbogus++;
                 }
             }
@@ -711,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++;
                 }
             }
@@ -805,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
@@ -814,6 +882,10 @@ END
 
 echo Running Algorithm Tests
 
+RM="$rmcmd";
+MKDIR="$mkcmd";
+TPREFIX=$stprefix
+
 END
        }
 
@@ -870,8 +942,8 @@ md \"$outdir\"
 END
                    } else {
                    print OUT <<END
-rm -rf \"$outdir\"
-mkdir \"$outdir\"
+\$RM \"$outdir\"
+\$MKDIR \"$outdir\"
 
 END
                    }
@@ -882,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