blob: e7bbfb41380c2d7417be099b8a9464f2584cc386 [file] [log] [blame]
Robert Sloan8ff03552017-06-14 12:40:58 -07001/* 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
27static int usage(char *arg) {
28 fprintf(stderr, "usage: %s <validation suite> <args ...>\n", arg);
29 return 1;
30}
31
32struct TestSuite {
33 std::string name;
34 int (*main_func)(int argc, char **argv);
35};
36
37static 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 {"keywrap", &cavp_keywrap_test_main},
47 {"rsa2_keygen", &cavp_rsa2_keygen_test_main},
48 {"rsa2_siggen", &cavp_rsa2_siggen_test_main},
49 {"rsa2_sigver", &cavp_rsa2_sigver_test_main},
50 {"sha", &cavp_sha_test_main},
51 {"sha_monte", &cavp_sha_monte_test_main},
52 {"tdes", &cavp_tdes_test_main}
53};
54
55int main(int argc, char **argv) {
56 CRYPTO_library_init();
57
58 if (argc < 3) {
59 return usage(argv[0]);
60 }
61
62 const std::string suite(argv[1]);
63 for (const TestSuite &s : all_test_suites) {
64 if (s.name == suite) {
65 return s.main_func(argc - 1, &argv[1]);
66 }
67 }
68
69 fprintf(stderr, "invalid test suite: %s\n\n", argv[1]);
70 return usage(argv[0]);
71}