]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/tests/suites/test_vectors.c
Merge branch 'tkm-multi-ke'
[thirdparty/strongswan.git] / src / libstrongswan / tests / suites / test_vectors.c
1 /*
2 * Copyright (C) 2014 Tobias Brunner
3 * Copyright (C) 2013 Martin Willi
4 *
5 * Copyright (C) secunet Security Networks AG
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 #include "test_suite.h"
19
20 #include <utils/test.h>
21 #include <threading/thread.h>
22 #include <crypto/transform.h>
23
24 static transform_type_t tfs[] = {
25 ENCRYPTION_ALGORITHM,
26 AEAD_ALGORITHM,
27 INTEGRITY_ALGORITHM,
28 HASH_ALGORITHM,
29 PSEUDO_RANDOM_FUNCTION,
30 EXTENDED_OUTPUT_FUNCTION,
31 KEY_DERIVATION_FUNCTION,
32 DETERMINISTIC_RANDOM_BIT_GENERATOR,
33 RANDOM_NUMBER_GENERATOR,
34 KEY_EXCHANGE_METHOD,
35 };
36
37 START_TEST(test_vectors)
38 {
39 enumerator_t *enumerator;
40 char *plugin;
41 bool success;
42 u_int alg;
43
44 enumerator = lib->crypto->create_verify_enumerator(lib->crypto, tfs[_i]);
45 thread_cleanup_push((void*)enumerator->destroy, enumerator);
46 while (enumerator->enumerate(enumerator, &alg, &plugin, &success))
47 {
48 ck_assert_msg(success, "test vector for %N from '%s' plugin failed",
49 transform_get_enum_names(tfs[_i]), alg, plugin);
50 }
51 thread_cleanup_pop(TRUE);
52 }
53 END_TEST
54
55
56 Suite *vectors_suite_create()
57 {
58 Suite *s;
59 TCase *tc;
60
61 s = suite_create("vectors");
62
63 tc = tcase_create("transforms");
64 tcase_add_loop_test(tc, test_vectors, 0, countof(tfs));
65 tcase_set_timeout(tc, 30);
66 suite_add_tcase(s, tc);
67
68 return s;
69 }