1 /* Copyright (c) 2017, Google Inc. 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 // cavp_main is a wrapper that invokes the main entry function of one of the 16 // CAVP validation suite binaries. 17 18 #include <stdlib.h> 19 #include <cstdio> 20 #include <string> 21 22 #include <openssl/crypto.h> 23 24 #include "cavp_test_util.h" 25 26 27 static int usage(char *arg) { 28 fprintf(stderr, "usage: %s <validation suite> <args ...>\n", arg); 29 return 1; 30 } 31 32 struct TestSuite { 33 std::string name; 34 int (*main_func)(int argc, char **argv); 35 }; 36 37 static TestSuite all_test_suites[] = { 38 {"aes", &cavp_aes_test_main}, 39 {"aes_gcm", &cavp_aes_gcm_test_main}, 40 {"ctr_drbg", &cavp_ctr_drbg_test_main}, 41 {"ecdsa2_keypair", &cavp_ecdsa2_keypair_test_main}, 42 {"ecdsa2_pkv", &cavp_ecdsa2_pkv_test_main}, 43 {"ecdsa2_siggen", &cavp_ecdsa2_siggen_test_main}, 44 {"ecdsa2_sigver", &cavp_ecdsa2_sigver_test_main}, 45 {"hmac", &cavp_hmac_test_main}, 46 {"kas", &cavp_kas_test_main}, 47 {"keywrap", &cavp_keywrap_test_main}, 48 {"rsa2_keygen", &cavp_rsa2_keygen_test_main}, 49 {"rsa2_siggen", &cavp_rsa2_siggen_test_main}, 50 {"rsa2_sigver", &cavp_rsa2_sigver_test_main}, 51 {"tlskdf", &cavp_tlskdf_test_main}, 52 {"sha", &cavp_sha_test_main}, 53 {"sha_monte", &cavp_sha_monte_test_main}, 54 {"tdes", &cavp_tdes_test_main} 55 }; 56 57 int main(int argc, char **argv) { 58 CRYPTO_library_init(); 59 60 if (argc < 3) { 61 return usage(argv[0]); 62 } 63 64 const std::string suite(argv[1]); 65 for (const TestSuite &s : all_test_suites) { 66 if (s.name == suite) { 67 return s.main_func(argc - 1, &argv[1]); 68 } 69 } 70 71 fprintf(stderr, "invalid test suite: %s\n\n", argv[1]); 72 return usage(argv[0]); 73 } 74