2 * Copyright (C) 2014 Tobias Brunner
3 * Copyright (C) 2013 Martin Willi
5 * Copyright (C) secunet Security Networks AG
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>.
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
18 #include "test_suite.h"
20 #include <utils/test.h>
21 #include <threading/thread.h>
22 #include <crypto/transform.h>
24 static transform_type_t tfs
[] = {
29 PSEUDO_RANDOM_FUNCTION
,
30 EXTENDED_OUTPUT_FUNCTION
,
31 KEY_DERIVATION_FUNCTION
,
32 DETERMINISTIC_RANDOM_BIT_GENERATOR
,
33 RANDOM_NUMBER_GENERATOR
,
37 START_TEST(test_vectors
)
39 enumerator_t
*enumerator
;
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
))
48 ck_assert_msg(success
, "test vector for %N from '%s' plugin failed",
49 transform_get_enum_names(tfs
[_i
]), alg
, plugin
);
51 thread_cleanup_pop(TRUE
);
56 Suite
*vectors_suite_create()
61 s
= suite_create("vectors");
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
);