#!/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
my @fips_dsa_pqgver_test_list = (
"DSA",
[ "PQGVer", "fips_dssvs 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", "file:L\\s*=.*N\\s*=" ]
);
# ECDSA2 tests
my @fips_ecdsa2_test_list = (
"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" ],
[ "SigVer(X9.31)", "fips_rsavtest -x931", 'file:9\.31' ],
[ "KeyGenRSA", "fips_rsagtest" ],
[ "SigGen(X9.31)", "fips_rsastest -x931" , 'file:9\.31']
);
# 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 = (
"RSA",
[ "SigGenPSS(0)", "fips_rsastest -saltlen 0",
'file:salt\s+len:\s+0' ],
[ "SigVerPSS(0)", "fips_rsavtest -saltlen 0",
'file:salt\s+len:\s+0' ],
);
# RSA PSS salt length 62 tests
my @fips_rsa_pss62_test_list = (
"RSA",
[ "SigGenPSS(62)", "fips_rsastest -saltlen 62",
'file:salt\s+len:\s+62' ],
[ "SigVerPSS(62)", "fips_rsavtest -saltlen 62",
'file:salt\s+len:\s+62' ],
);
# SHA tests
my @fips_sha_test_list = (
"SHA",
[ "SHA1LongMsg", "fips_shatest" ],
[ "SHA1Monte", "fips_shatest" ],
[ "SHA1ShortMsg", "fips_shatest" ],
[ "SHA224LongMsg", "fips_shatest" ],
[ "SHA224Monte", "fips_shatest" ],
[ "SHA224ShortMsg", "fips_shatest" ],
[ "SHA256LongMsg", "fips_shatest" ],
[ "SHA256Monte", "fips_shatest" ],
[ "SHA256ShortMsg", "fips_shatest" ],
[ "SHA384LongMsg", "fips_shatest" ],