#!/usr/bin/perl -w
# Perl utility to run or verify FIPS 140-2 CAVP algorithm tests based on the
# pathnames of input algorithm test files actually present (the unqualified
# file names are consistent but the pathnames are not).
#
# FIPS test definitions
# List of all the unqualified file names we expect and command lines to run
# DSA tests
my @fips_dsa_test_list = (
"DSA",
[ "PQGGen", "fips_dssvs pqg", "path:[^C]DSA/.*PQGGen" ],
[ "KeyPair", "fips_dssvs keypair", "path:[^C]DSA/.*KeyPair" ],
[ "SigGen", "fips_dssvs siggen", "path:[^C]DSA/.*SigGen" ],
[ "SigVer", "fips_dssvs sigver", "path:[^C]DSA/.*SigVer" ]
);
my @fips_dsa_pqgver_test_list = (
[ "PQGVer", "fips_dssvs pqgver", "path:[^C]DSA/.*PQGVer" ]
);
# DSA2 tests
my @fips_dsa2_test_list = (
"DSA2",
[ "PQGGen", "fips_dssvs pqg", "path:[^C]DSA2/.*PQGGen" ],
[ "KeyPair", "fips_dssvs keypair", "path:[^C]DSA2/.*KeyPair" ],
[ "SigGen", "fips_dssvs siggen", "path:[^C]DSA2/.*SigGen" ],
[ "SigVer", "fips_dssvs sigver", "path:[^C]DSA2/.*SigVer" ],
[ "PQGVer", "fips_dssvs pqgver", "path:[^C]DSA2/.*PQGVer" ]
);
# ECDSA and ECDSA2 tests
my @fips_ecdsa_test_list = (
"ECDSA",
[ "KeyPair", "fips_ecdsavs KeyPair", "path:/ECDSA/.*KeyPair" ],
[ "PKV", "fips_ecdsavs PKV", "path:/ECDSA/.*PKV" ],
[ "SigGen", "fips_ecdsavs SigGen", "path:/ECDSA/.*SigGen" ],
[ "SigVer", "fips_ecdsavs SigVer", "path:/ECDSA/.*SigVer" ],
"ECDSA2",
[ "KeyPair", "fips_ecdsavs KeyPair", "path:/ECDSA2/.*KeyPair" ],
[ "PKV", "fips_ecdsavs PKV", "path:/ECDSA2/.*PKV" ],
[ "SigGen", "fips_ecdsavs SigGen", "path:/ECDSA2/.*SigGen" ],
[ "SigVer", "fips_ecdsavs SigVer", "path:/ECDSA2/.*SigVer" ],
);
# RSA tests
my @fips_rsa_test_list = (
"RSA",
[ "SigGen15", "fips_rsastest" ],
[ "SigVer15", "fips_rsavtest" ],
[ "SigVerRSA", "fips_rsavtest -x931" ],
[ "KeyGenRSA", "fips_rsagtest" ],
[ "SigGenRSA", "fips_rsastest -x931" ]
);
# Special cases for PSS. The filename itself is
# not sufficient to determine the test. Addditionally we
# need to examine the file contents to determine the salt length
# In these cases the test filename has (saltlen) appended.
# RSA PSS salt length 0 tests
my @fips_rsa_pss0_test_list = (
[ "SigGenPSS(0)", "fips_rsastest -saltlen 0",
'file:^\s*#\s*salt\s+len:\s+0\s*$' ],
[ "SigVerPSS(0)", "fips_rsavtest -saltlen 0",
'file:^\s*#\s*salt\s+len:\s+0\s*$' ],
);
# RSA PSS salt length 62 tests
my @fips_rsa_pss62_test_list = (
[ "SigGenPSS(62)", "fips_rsastest -saltlen 62",
'file:^\s*#\s*salt\s+len:\s+62\s*$' ],
[ "SigVerPSS(62)", "fips_rsavtest -saltlen 62",
'file:^\s*#\s*salt\s+len:\s+62\s*$' ],
);
# SHA tests
my @fips_sha_test_list = (
"SHA",
[ "SHA1LongMsg", "fips_shatest" ],
[ "SHA1Monte", "fips_shatest" ],
[ "SHA1ShortMsg",