2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include "test_vectors_plugin.h"
18 #include <crypto/crypto_factory.h>
19 #include <crypto/crypto_tester.h>
21 /* define symbols of all test vectors */
22 #define TEST_VECTOR_CRYPTER(x) crypter_test_vector_t x;
23 #define TEST_VECTOR_SIGNER(x) signer_test_vector_t x;
24 #define TEST_VECTOR_HASHER(x) hasher_test_vector_t x;
25 #define TEST_VECTOR_PRF(x) prf_test_vector_t x;
26 #define TEST_VECTOR_RNG(x) rng_test_vector_t x;
28 #include "test_vectors.h"
30 #undef TEST_VECTOR_CRYPTER
31 #undef TEST_VECTOR_SIGNER
32 #undef TEST_VECTOR_HASHER
33 #undef TEST_VECTOR_PRF
34 #undef TEST_VECTOR_RNG
36 #define TEST_VECTOR_CRYPTER(x)
37 #define TEST_VECTOR_SIGNER(x)
38 #define TEST_VECTOR_HASHER(x)
39 #define TEST_VECTOR_PRF(x)
40 #define TEST_VECTOR_RNG(x)
42 /* create test vector arrays */
43 #undef TEST_VECTOR_CRYPTER
44 #define TEST_VECTOR_CRYPTER(x) &x,
45 static crypter_test_vector_t
*crypter
[] = {
46 #include "test_vectors.h"
48 #undef TEST_VECTOR_CRYPTER
49 #define TEST_VECTOR_CRYPTER(x)
51 #undef TEST_VECTOR_SIGNER
52 #define TEST_VECTOR_SIGNER(x) &x,
53 static signer_test_vector_t
*signer
[] = {
54 #include "test_vectors.h"
56 #undef TEST_VECTOR_SIGNER
57 #define TEST_VECTOR_SIGNER(x)
59 #undef TEST_VECTOR_HASHER
60 #define TEST_VECTOR_HASHER(x) &x,
61 static hasher_test_vector_t
*hasher
[] = {
62 #include "test_vectors.h"
64 #undef TEST_VECTOR_HASHER
65 #define TEST_VECTOR_HASHER(x)
67 #undef TEST_VECTOR_PRF
68 #define TEST_VECTOR_PRF(x) &x,
69 static prf_test_vector_t
*prf
[] = {
70 #include "test_vectors.h"
72 #undef TEST_VECTOR_PRF
73 #define TEST_VECTOR_PRF(x)
75 #undef TEST_VECTOR_RNG
76 #define TEST_VECTOR_RNG(x) &x,
77 static rng_test_vector_t
*rng
[] = {
78 #include "test_vectors.h"
80 #undef TEST_VECTOR_RNG
81 #define TEST_VECTOR_RNG(x)
83 typedef struct private_test_vectors_plugin_t private_test_vectors_plugin_t
;
86 * private data of test_vectors_plugin
88 struct private_test_vectors_plugin_t
{
93 test_vectors_plugin_t
public;
97 * Implementation of test_vectors_plugin_t.test_vectorstroy
99 static void destroy(private_test_vectors_plugin_t
*this)
107 plugin_t
*plugin_create()
109 private_test_vectors_plugin_t
*this = malloc_thing(private_test_vectors_plugin_t
);
112 this->public.plugin
.destroy
= (void(*)(plugin_t
*))destroy
;
114 for (i
= 0; i
< countof(crypter
); i
++)
116 lib
->crypto
->add_test_vector(lib
->crypto
,
117 ENCRYPTION_ALGORITHM
, crypter
[i
]);
119 for (i
= 0; i
< countof(signer
); i
++)
121 lib
->crypto
->add_test_vector(lib
->crypto
,
122 INTEGRITY_ALGORITHM
, signer
[i
]);
124 for (i
= 0; i
< countof(hasher
); i
++)
126 lib
->crypto
->add_test_vector(lib
->crypto
,
127 HASH_ALGORITHM
, hasher
[i
]);
129 for (i
= 0; i
< countof(prf
); i
++)
131 lib
->crypto
->add_test_vector(lib
->crypto
,
132 PSEUDO_RANDOM_FUNCTION
, prf
[i
]);
134 for (i
= 0; i
< countof(rng
); i
++)
136 lib
->crypto
->add_test_vector(lib
->crypto
,
137 RANDOM_NUMBER_GENERATOR
, rng
[i
]);
140 return &this->public.plugin
;