Implemented ntru_trits class
[strongswan.git] / src / libstrongswan / tests / suites / test_ntru.c
1 /*
2 * Copyright (C) 2013 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 #include "test_suite.h"
17
18 #include <tests/utils/test_rng.h>
19 #include <plugins/ntru/ntru_drbg.h>
20 #include <plugins/ntru/ntru_mgf1.h>
21 #include <plugins/ntru/ntru_trits.h>
22 #include <utils/test.h>
23
24 IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_drbg_create, ntru_drbg_t*,
25 u_int32_t strength, chunk_t pers_str, rng_t *entropy)
26
27 IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_mgf1_create, ntru_mgf1_t*,
28 hash_algorithm_t alg, chunk_t seed, bool hash_seed)
29
30 IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_trits_create, ntru_trits_t*,
31 size_t len, hash_algorithm_t alg, chunk_t seed)
32
33 /**
34 * NTRU parameter sets to test
35 */
36 static struct {
37 diffie_hellman_group_t group;
38 char *group_name;
39 } params[] = {
40 { NTRU_112_BIT, "NTRU_112" },
41 { NTRU_128_BIT, "NTRU_128" },
42 { NTRU_192_BIT, "NTRU_192" },
43 { NTRU_256_BIT, "NTRU_256" }
44 };
45
46 /**
47 * NTRU parameter set selection
48 */
49 char *parameter_sets[] = {
50 "x9_98_speed", "x9_98_bandwidth", "x9_98_balance", "optimum"
51 };
52
53 typedef struct {
54 u_int32_t requested;
55 u_int32_t standard;
56 }strength_t;
57
58 strength_t strengths[] = {
59 { 80, 112 },
60 { 112, 112 },
61 { 120, 128 },
62 { 128, 128 },
63 { 150, 192 },
64 { 192, 192 },
65 { 200, 256 },
66 { 256, 256 },
67 { 512, 0 }
68 };
69
70 START_TEST(test_ntru_drbg_strength)
71 {
72 ntru_drbg_t *drbg;
73 rng_t *entropy;
74
75 entropy = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
76 ck_assert(entropy != NULL);
77
78 drbg = ntru_drbg_create(strengths[_i].requested, chunk_empty, entropy);
79 if (strengths[_i].standard)
80 {
81 ck_assert(drbg != NULL);
82 ck_assert(drbg->get_strength(drbg) == strengths[_i].standard);
83 drbg->destroy(drbg);
84 }
85 else
86 {
87 ck_assert(drbg == NULL);
88 }
89 entropy->destroy(entropy);
90 }
91 END_TEST
92
93 typedef struct {
94 chunk_t pers_str;
95 chunk_t entropy;
96 chunk_t out;
97 } drbg_test_t;
98
99 /**
100 * NIST SP 800-90A Deterministic Random Generator Validation System (DRBGVS)
101 */
102 drbg_test_t drbg_tests[] = {
103 /* SHA-256 test case 1 - count 0 */
104 { { NULL, 0 },
105 chunk_from_chars(0x06, 0x03, 0x2c, 0xd5, 0xee, 0xd3, 0x3f, 0x39,
106 0x26, 0x5f, 0x49, 0xec, 0xb1, 0x42, 0xc5, 0x11,
107 0xda, 0x9a, 0xff, 0x2a, 0xf7, 0x12, 0x03, 0xbf,
108 0xfa, 0xf3, 0x4a, 0x9c, 0xa5, 0xbd, 0x9c, 0x0d,
109 0x0e, 0x66, 0xf7, 0x1e, 0xdc, 0x43, 0xe4, 0x2a,
110 0x45, 0xad, 0x3c, 0x6f, 0xc6, 0xcd, 0xc4, 0xdf,
111 0x01, 0x92, 0x0a, 0x4e, 0x66, 0x9e, 0xd3, 0xa8,
112 0x5a, 0xe8, 0xa3, 0x3b, 0x35, 0xa7, 0x4a, 0xd7,
113 0xfb, 0x2a, 0x6b, 0xb4, 0xcf, 0x39, 0x5c, 0xe0,
114 0x03, 0x34, 0xa9, 0xc9, 0xa5, 0xa5, 0xd5, 0x52),
115 chunk_from_chars(0x76, 0xfc, 0x79, 0xfe, 0x9b, 0x50, 0xbe, 0xcc,
116 0xc9, 0x91, 0xa1, 0x1b, 0x56, 0x35, 0x78, 0x3a,
117 0x83, 0x53, 0x6a, 0xdd, 0x03, 0xc1, 0x57, 0xfb,
118 0x30, 0x64, 0x5e, 0x61, 0x1c, 0x28, 0x98, 0xbb,
119 0x2b, 0x1b, 0xc2, 0x15, 0x00, 0x02, 0x09, 0x20,
120 0x8c, 0xd5, 0x06, 0xcb, 0x28, 0xda, 0x2a, 0x51,
121 0xbd, 0xb0, 0x38, 0x26, 0xaa, 0xf2, 0xbd, 0x23,
122 0x35, 0xd5, 0x76, 0xd5, 0x19, 0x16, 0x08, 0x42,
123 0xe7, 0x15, 0x8a, 0xd0, 0x94, 0x9d, 0x1a, 0x9e,
124 0xc3, 0xe6, 0x6e, 0xa1, 0xb1, 0xa0, 0x64, 0xb0,
125 0x05, 0xde, 0x91, 0x4e, 0xac, 0x2e, 0x9d, 0x4f,
126 0x2d, 0x72, 0xa8, 0x61, 0x6a, 0x80, 0x22, 0x54,
127 0x22, 0x91, 0x82, 0x50, 0xff, 0x66, 0xa4, 0x1b,
128 0xd2, 0xf8, 0x64, 0xa6, 0xa3, 0x8c, 0xc5, 0xb6,
129 0x49, 0x9d, 0xc4, 0x3f, 0x7f, 0x2b, 0xd0, 0x9e,
130 0x1e, 0x0f, 0x8f, 0x58, 0x85, 0x93, 0x51, 0x24)
131 },
132 /* SHA-256 test case 3 - count 0 */
133 { chunk_from_chars(0xf2, 0xe5, 0x8f, 0xe6, 0x0a, 0x3a, 0xfc, 0x59,
134 0xda, 0xd3, 0x75, 0x95, 0x41, 0x5f, 0xfd, 0x31,
135 0x8c, 0xcf, 0x69, 0xd6, 0x77, 0x80, 0xf6, 0xfa,
136 0x07, 0x97, 0xdc, 0x9a, 0xa4, 0x3e, 0x14, 0x4c),
137 chunk_from_chars(0xfa, 0x0e, 0xe1, 0xfe, 0x39, 0xc7, 0xc3, 0x90,
138 0xaa, 0x94, 0x15, 0x9d, 0x0d, 0xe9, 0x75, 0x64,
139 0x34, 0x2b, 0x59, 0x17, 0x77, 0xf3, 0xe5, 0xf6,
140 0xa4, 0xba, 0x2a, 0xea, 0x34, 0x2e, 0xc8, 0x40,
141 0xdd, 0x08, 0x20, 0x65, 0x5c, 0xb2, 0xff, 0xdb,
142 0x0d, 0xa9, 0xe9, 0x31, 0x0a, 0x67, 0xc9, 0xe5,
143 0xe0, 0x62, 0x9b, 0x6d, 0x79, 0x75, 0xdd, 0xfa,
144 0x96, 0xa3, 0x99, 0x64, 0x87, 0x40, 0xe6, 0x0f,
145 0x1f, 0x95, 0x57, 0xdc, 0x58, 0xb3, 0xd7, 0x41,
146 0x5f, 0x9b, 0xa9, 0xd4, 0xdb, 0xb5, 0x01, 0xf6),
147 chunk_from_chars(0xf9, 0x2d, 0x4c, 0xf9, 0x9a, 0x53, 0x5b, 0x20,
148 0x22, 0x2a, 0x52, 0xa6, 0x8d, 0xb0, 0x4c, 0x5a,
149 0xf6, 0xf5, 0xff, 0xc7, 0xb6, 0x6a, 0x47, 0x3a,
150 0x37, 0xa2, 0x56, 0xbd, 0x8d, 0x29, 0x8f, 0x9b,
151 0x4a, 0xa4, 0xaf, 0x7e, 0x8d, 0x18, 0x1e, 0x02,
152 0x36, 0x79, 0x03, 0xf9, 0x3b, 0xdb, 0x74, 0x4c,
153 0x6c, 0x2f, 0x3f, 0x34, 0x72, 0x62, 0x6b, 0x40,
154 0xce, 0x9b, 0xd6, 0xa7, 0x0e, 0x7b, 0x8f, 0x93,
155 0x99, 0x2a, 0x16, 0xa7, 0x6f, 0xab, 0x6b, 0x5f,
156 0x16, 0x25, 0x68, 0xe0, 0x8e, 0xe6, 0xc3, 0xe8,
157 0x04, 0xae, 0xfd, 0x95, 0x2d, 0xdd, 0x3a, 0xcb,
158 0x79, 0x1c, 0x50, 0xf2, 0xad, 0x69, 0xe9, 0xa0,
159 0x40, 0x28, 0xa0, 0x6a, 0x9c, 0x01, 0xd3, 0xa6,
160 0x2a, 0xca, 0x2a, 0xaf, 0x6e, 0xfe, 0x69, 0xed,
161 0x97, 0xa0, 0x16, 0x21, 0x3a, 0x2d, 0xd6, 0x42,
162 0xb4, 0x88, 0x67, 0x64, 0x07, 0x2d, 0x9c, 0xbe)
163 },
164 /* SHA-256 test case 5 - count 0 */
165 { { NULL, 0 },
166 chunk_from_chars(0xff, 0x0c, 0xdd, 0x55, 0x5c, 0x60, 0x46, 0x47,
167 0x60, 0xb2, 0x89, 0xb7, 0xbc, 0x1f, 0x81, 0x1a,
168 0x41, 0xff, 0xf7, 0x2d, 0xe5, 0x90, 0x83, 0x85,
169 0x8c, 0x02, 0x0a, 0x10, 0x53, 0xbd, 0xc7, 0x4a,
170 0x7b, 0xc0, 0x99, 0x28, 0x5a, 0xd5, 0x62, 0x19,
171 0x93, 0xb6, 0x39, 0xc4, 0xa9, 0x4c, 0x37, 0x6b,
172 0x14, 0xfc, 0x6c, 0x9b, 0x17, 0x8d, 0xb6, 0x44,
173 0xa8, 0xcd, 0x71, 0x30, 0xa4, 0xcf, 0x05, 0x16,
174 0x78, 0xc8, 0xf4, 0xfa, 0x8f, 0x24, 0xc2, 0x7b,
175 0x0a, 0x53, 0x13, 0x38, 0xa5, 0xce, 0x85, 0x89),
176 chunk_from_chars(0x2f, 0x26, 0x20, 0x34, 0x7b, 0xdd, 0xca, 0xa2,
177 0x94, 0x36, 0x85, 0x34, 0x6b, 0xbf, 0x31, 0xc4,
178 0x40, 0x81, 0xf8, 0x66, 0x5f, 0x3d, 0xdb, 0x2b,
179 0x42, 0xae, 0x14, 0x16, 0xa7, 0x4c, 0x4b, 0x77,
180 0xfa, 0xb3, 0xfa, 0x19, 0xae, 0xec, 0xc5, 0x47,
181 0xe7, 0x6c, 0x8c, 0xbe, 0x6a, 0xd1, 0xf1, 0x00,
182 0xa3, 0xfc, 0x8b, 0x2c, 0xe2, 0xa1, 0xea, 0x3a,
183 0x3d, 0xd7, 0xcf, 0xad, 0x46, 0xc1, 0xb2, 0x78,
184 0x30, 0xb9, 0x40, 0xba, 0x18, 0xd0, 0x9e, 0x9b,
185 0x7f, 0xa9, 0x02, 0xbb, 0x76, 0x06, 0x69, 0xb1,
186 0x73, 0x5c, 0xc7, 0xb7, 0xbd, 0x39, 0x05, 0x2d,
187 0xa7, 0xf2, 0x62, 0x6f, 0xa8, 0x70, 0x00, 0xcf,
188 0xfa, 0xda, 0x41, 0x00, 0x19, 0xd0, 0x53, 0x38,
189 0x6a, 0xd8, 0x08, 0xbd, 0x3c, 0x0c, 0xfc, 0xf5,
190 0x6b, 0x91, 0x87, 0x9e, 0xb8, 0xd3, 0xf9, 0x32,
191 0xee, 0x2d, 0x18, 0x5e, 0x54, 0xf3, 0x1b, 0x74)
192 },
193 /* SHA-256 test case 7 - count 0 */
194 { chunk_from_chars(0x40, 0x93, 0x3f, 0xdc, 0xce, 0x41, 0x59, 0xb0,
195 0x95, 0x51, 0x11, 0xf8, 0x44, 0x47, 0x1b, 0x0d,
196 0xb8, 0x5b, 0x73, 0xbd, 0xd2, 0xb7, 0x8c, 0x46,
197 0x8d, 0xd3, 0x9e, 0x2a, 0x9b, 0x29, 0xae, 0xf2),
198 chunk_from_chars(0x28, 0xba, 0x1a, 0x66, 0x16, 0x32, 0xef, 0xc8,
199 0xec, 0xce, 0xd5, 0xf5, 0x1b, 0x79, 0x13, 0x00,
200 0xfb, 0x3b, 0x55, 0xb0, 0x5d, 0x04, 0x17, 0x08,
201 0x63, 0x8d, 0xe4, 0xbe, 0xb7, 0x57, 0xa9, 0xe5,
202 0x76, 0x82, 0x87, 0x96, 0xaf, 0xf0, 0x7f, 0x55,
203 0x79, 0x5c, 0xb5, 0x47, 0x13, 0xc7, 0x7e, 0xd4,
204 0xa5, 0xf5, 0x42, 0xb0, 0x4a, 0xaa, 0x5d, 0xbc,
205 0x93, 0x1e, 0x47, 0x01, 0x9f, 0xeb, 0x38, 0x96,
206 0x26, 0x16, 0xc5, 0x7a, 0xf0, 0x9b, 0x7c, 0x1d,
207 0xf8, 0x3f, 0x2b, 0x86, 0x0f, 0xf7, 0x65, 0x86),
208 chunk_from_chars(0x65, 0xe5, 0xaa, 0x47, 0xb3, 0x85, 0xf1, 0xea,
209 0x42, 0xb2, 0x31, 0xb9, 0xfe, 0x74, 0x42, 0x53,
210 0xb8, 0x59, 0x88, 0x59, 0xd7, 0x01, 0x1e, 0x52,
211 0x5f, 0x5a, 0x2a, 0x1a, 0xd3, 0x2a, 0x97, 0x2a,
212 0x85, 0x08, 0x02, 0xc6, 0x0a, 0x2b, 0xe1, 0x9b,
213 0xe2, 0x70, 0x06, 0x3a, 0x3c, 0xfb, 0xea, 0xae,
214 0x95, 0x4f, 0x10, 0xb1, 0x22, 0x35, 0x2d, 0xe6,
215 0xa0, 0x8a, 0xc4, 0x10, 0xe0, 0x99, 0x16, 0x53,
216 0xaa, 0xb2, 0x71, 0xb3, 0x60, 0xfe, 0x91, 0x91,
217 0xcf, 0x5a, 0xdd, 0xcc, 0xcc, 0xed, 0x8c, 0x4a,
218 0xcf, 0xb6, 0x14, 0x57, 0x04, 0x99, 0x92, 0x98,
219 0x8f, 0xd7, 0xa9, 0xac, 0xca, 0x1f, 0x1b, 0xca,
220 0x35, 0xf1, 0x47, 0x58, 0x13, 0x69, 0x4a, 0x39,
221 0x98, 0x8e, 0x5f, 0xac, 0x9f, 0x4a, 0xc0, 0x57,
222 0x22, 0x86, 0xbc, 0x46, 0x25, 0x82, 0xad, 0x0a,
223 0xf7, 0x8a, 0xb3, 0xb8, 0x5e, 0xc1, 0x7a, 0x25)
224 }
225 };
226
227 START_TEST(test_ntru_drbg)
228 {
229 ntru_drbg_t *drbg;
230 rng_t *entropy;
231 chunk_t out;
232
233 out = chunk_alloc(128);
234 entropy = test_rng_create(drbg_tests[_i].entropy);
235 drbg = ntru_drbg_create(256, drbg_tests[_i].pers_str, entropy);
236 ck_assert(drbg != NULL);
237 ck_assert(drbg->reseed(drbg));
238 ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
239 ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
240 ck_assert(chunk_equals(out, drbg_tests[_i].out));
241 drbg->destroy(drbg);
242 entropy->destroy(entropy);
243 chunk_free(&out);
244 }
245 END_TEST
246
247 START_TEST(test_ntru_drbg_reseed)
248 {
249 ntru_drbg_t *drbg;
250 rng_t *entropy;
251 chunk_t out;
252
253 lib->settings->set_int(lib->settings,
254 "libstrongswan.plugins.ntru.max_drbg_requests", 2);
255 out = chunk_alloc(128);
256 entropy = test_rng_create(drbg_tests[0].entropy);
257 drbg = ntru_drbg_create(256, chunk_empty, entropy);
258
259 /* bad output parameters */
260 ck_assert(!drbg->generate(drbg, 256, 0, out.ptr));
261 ck_assert(!drbg->generate(drbg, 256, 128, NULL));
262
263 /* no reseeding occurs */
264 ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
265 ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
266
267 /* consuming remaining entropy */
268 ck_assert(entropy->get_bytes(entropy, 32, out.ptr));
269
270 /* no entropy available for automatic reseeding */
271 ck_assert(!drbg->generate(drbg, 256, 128, out.ptr));
272 drbg->destroy(drbg);
273
274 /* no entropy available for DRBG instantiation */
275 drbg = ntru_drbg_create(256, chunk_empty, entropy);
276 ck_assert(drbg == NULL);
277 entropy->destroy(entropy);
278
279 /* one automatic reseeding occurs */
280 entropy = test_rng_create(drbg_tests[0].entropy);
281 drbg = ntru_drbg_create(256, chunk_empty, entropy);
282 ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
283 ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
284 ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
285
286 /* no entropy left */
287 ck_assert(!entropy->get_bytes(entropy, 32, out.ptr));
288
289 drbg->destroy(drbg);
290 entropy->destroy(entropy);
291 chunk_free(&out);
292 lib->settings->set_int(lib->settings,
293 "libstrongswan.plugins.ntru.max_drbg_requests", 2000);
294 }
295 END_TEST
296
297 typedef struct {
298 hash_algorithm_t alg;
299 size_t hash_size;
300 size_t ml1, ml2, ml3;
301 chunk_t seed;
302 chunk_t hashed_seed;
303 chunk_t mask;
304 chunk_t trits;
305 } mgf1_test_t;
306
307 /**
308 * MGF1 Mask Generation Function Test Vectors
309 */
310 mgf1_test_t mgf1_tests[] = {
311 { HASH_SHA1, 20, 60, 20, 15,
312 chunk_from_chars(
313 0xED, 0xA5, 0xC3, 0xBC, 0xAF, 0xB3, 0x20, 0x7D,
314 0x14, 0xA1, 0x54, 0xF7, 0x8B, 0x37, 0xF2, 0x8D,
315 0x8C, 0x9B, 0xD5, 0x63, 0x57, 0x38, 0x11, 0xC2,
316 0xB5, 0xCA, 0xBF, 0x06, 0x43, 0x45, 0x19, 0xD5,
317 0xE7, 0x36, 0xD0, 0x29, 0x21, 0xDA, 0x02, 0x20,
318 0x45, 0xF6, 0x5F, 0x0F, 0x10, 0x04, 0x2A, 0xE3,
319 0x6A, 0x1D, 0xD5, 0x9F, 0x1D, 0x66, 0x44, 0x8F,
320 0xFA, 0xC6, 0xCA, 0xA4, 0x6E, 0x3B, 0x00, 0x66,
321 0xA6, 0xC9, 0x80, 0x5C, 0xF5, 0x2D, 0xD7, 0x72,
322 0xC6, 0xD4, 0x4F, 0x30, 0x72, 0xA2, 0xAD, 0xE0,
323 0x33, 0xE8, 0x55, 0xD5, 0xE6, 0xD6, 0x00, 0x1D,
324 0xA8, 0x68, 0xFF, 0x97, 0x36, 0x8A, 0xF4, 0xD6,
325 0xF1, 0xB6, 0x7E, 0x1F, 0x06, 0xCB, 0x57, 0xCB,
326 0x35, 0x38, 0xF2, 0x2D, 0xF6, 0x20),
327 chunk_from_chars(
328 0xF3, 0x9B, 0x0B, 0xB4, 0x97, 0x50, 0xB5, 0xA7,
329 0xE6, 0xBD, 0xDA, 0xD0, 0x9A, 0x52, 0xBE, 0xA0,
330 0x21, 0xC4, 0x90, 0xB6),
331 chunk_from_chars(
332 0x10, 0x43, 0x76, 0x72, 0x6C, 0xDE, 0xA0, 0x0E,
333 0x77, 0x51, 0xFB, 0x58, 0x39, 0x8A, 0x36, 0xE1,
334 0x63, 0x2B, 0xC9, 0x17, 0x56, 0x0C, 0x4B, 0x46,
335 0xA4, 0x07, 0xA4, 0x3B, 0x8E, 0x33, 0x4D, 0xD1,
336 0x65, 0xF1, 0xAC, 0xC8, 0x59, 0x21, 0x32, 0x16,
337 0x44, 0x2B, 0x7F, 0xB2, 0xA8, 0xA7, 0x26, 0x5D,
338 0xE8, 0x02, 0xBE, 0x8E, 0xDC, 0x34, 0xEB, 0x10,
339 0x76, 0x16, 0x8C, 0xDD, 0x90, 0x92, 0x3D, 0x29,
340 0x90, 0x98, 0x46, 0x11, 0x73, 0x53, 0x47, 0xB1,
341 0x2C, 0xD4, 0x83, 0x78, 0x9B, 0x93, 0x2F, 0x5B,
342 0xFC, 0x26, 0xFF, 0x42, 0x08, 0x1F, 0x70, 0x66,
343 0x40, 0x4B, 0xE7, 0x22, 0x3A, 0x56, 0x10, 0x6D,
344 0x4D, 0x29, 0x0B, 0xCE, 0xA6, 0x21, 0xB5, 0x5C,
345 0x71, 0x66, 0x2F, 0x70, 0x35, 0xD8, 0x8A, 0x92,
346 0x33, 0xF0, 0x16, 0xD4, 0x0E, 0x43, 0x8A, 0x14),
347 chunk_from_chars(
348 1, 2, 1, 0, 0, 1, 1, 1, 2, 0, 1, 0, 1, 1, 1, 0, 2, 0, 1, 1,
349 0, 0, 0, 1, 1, 0, 2, 0, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 0, 0,
350 2, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0, 1, 0, 1, 0, 2, 0,
351 0, 1, 0, 2, 1, 0, 0, 0, 2, 0, 0, 0, 1, 2, 2, 0, 0, 2, 0, 1,
352 1, 2, 1, 1, 0, 0, 1, 1, 1, 2, 2, 1, 2, 0, 0, 2, 1, 0, 0, 1,
353 0, 1, 1, 0, 0, 0, 1, 2, 2, 0, 1, 2, 1, 2, 0, 2, 0, 0, 0, 2,
354 1, 2, 0, 0, 0, 2, 0, 0, 0, 2, 2, 1, 0, 2, 0, 1, 2, 0, 2, 1,
355 0, 2, 2, 1, 0, 2, 1, 2, 2, 0, 2, 0, 2, 1, 2, 2, 0, 2, 0, 1,
356 1, 2, 2, 2, 2, 1, 0, 1, 0, 2, 2, 0, 1, 1, 2, 2, 2, 0, 0, 1,
357 0, 2, 0, 1, 0, 2, 1, 2, 1, 0, 1, 1, 2, 0, 0, 2, 1, 1, 2, 0,
358 1, 2, 1, 1, 0, 1, 0, 2, 1, 1, 1, 2, 1, 0, 2, 0, 2, 0, 0, 2,
359 2, 1, 0, 0, 2, 2, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2,
360 2, 0, 0, 0, 0, 1, 0, 0, 1, 2, 1, 2, 0, 2, 1, 1, 1, 0, 2, 2,
361 1, 2, 2, 1, 0, 1, 0, 2, 2, 2, 1, 2, 1, 0, 0, 1, 0, 1, 1, 1,
362 1, 1, 2, 0, 0, 2, 1, 0, 2, 1, 2, 1, 0, 2, 2, 0, 0, 1, 2, 1,
363 2, 0, 1, 2, 1, 1, 2, 0, 2, 0, 2, 1, 1, 1, 0, 0, 0, 1, 2, 1,
364 2, 2, 1, 2, 1, 1, 2, 1, 2, 0, 2, 2, 1, 0, 0, 1, 2, 0, 1, 1,
365 2, 0, 0, 0, 1, 2, 2, 1, 2, 0, 0, 2, 1, 0, 2, 2, 2, 1, 1, 0,
366 2, 1, 2, 1, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 0, 2, 2, 1,
367 0, 1, 1, 2, 1, 2, 0, 2, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 1, 0,
368 0, 1, 1, 2, 0, 2, 2, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1,
369 0, 1, 2, 0, 1, 1, 0, 1, 2, 0, 0, 1, 2, 2, 0, 0, 2, 1, 2)
370 },
371 { HASH_SHA256, 32, 64, 32, 33,
372 chunk_from_chars(
373 0x52, 0xC5, 0xDD, 0x1E, 0xEF, 0x76, 0x1B, 0x53,
374 0x08, 0xE4, 0x86, 0x3F, 0x91, 0x12, 0x98, 0x69,
375 0xC5, 0x9D, 0xDE, 0xF6, 0xFC, 0xFA, 0x93, 0xCE,
376 0x32, 0x52, 0x66, 0xF9, 0xC9, 0x97, 0xF6, 0x42,
377 0x00, 0x2C, 0x64, 0xED, 0x1A, 0x6B, 0x14, 0x0A,
378 0x4B, 0x04, 0xCF, 0x6D, 0x2D, 0x82, 0x0A, 0x07,
379 0xA2, 0x3B, 0xDE, 0xCE, 0x19, 0x8A, 0x39, 0x43,
380 0x16, 0x61, 0x29, 0x98, 0x68, 0xEA, 0xE5, 0xCC,
381 0x0A, 0xF8, 0xE9, 0x71, 0x26, 0xF1, 0x07, 0x36,
382 0x2C, 0x07, 0x1E, 0xEB, 0xE4, 0x28, 0xA2, 0xF4,
383 0xA8, 0x12, 0xC0, 0xC8, 0x20, 0x37, 0xF8, 0xF2,
384 0x6C, 0xAF, 0xDC, 0x6F, 0x2E, 0xD0, 0x62, 0x58,
385 0xD2, 0x37, 0x03, 0x6D, 0xFA, 0x6E, 0x1A, 0xAC,
386 0x9F, 0xCA, 0x56, 0xC6, 0xA4, 0x52, 0x41, 0xE8,
387 0x0F, 0x1B, 0x0C, 0xB9, 0xE6, 0xBA, 0xDE, 0xE1,
388 0x03, 0x5E, 0xC2, 0xE5, 0xF8, 0xF4, 0xF3, 0x46,
389 0x3A, 0x12, 0xC0, 0x1F, 0x3A, 0x00, 0xD0, 0x91,
390 0x18, 0xDD, 0x53, 0xE4, 0x22, 0xF5, 0x26, 0xA4,
391 0x54, 0xEE, 0x20, 0xF0, 0x80),
392 chunk_from_chars(
393 0x76, 0x89, 0x8B, 0x1B, 0x60, 0xEC, 0x10, 0x9D,
394 0x8F, 0x13, 0xF2, 0xFE, 0xD9, 0x85, 0xC1, 0xAB,
395 0x7E, 0xEE, 0xB1, 0x31, 0xDD, 0xF7, 0x7F, 0x0C,
396 0x7D, 0xF9, 0x6B, 0x7B, 0x19, 0x80, 0xBD, 0x28),
397 chunk_from_chars(
398 0xF1, 0x19, 0x02, 0x4F, 0xDA, 0x58, 0x05, 0x9A,
399 0x07, 0xDF, 0x61, 0x81, 0x22, 0x0E, 0x15, 0x46,
400 0xCB, 0x35, 0x3C, 0xDC, 0xAD, 0x20, 0xD9, 0x3F,
401 0x0D, 0xD1, 0xAA, 0x64, 0x66, 0x5C, 0xFA, 0x4A,
402 0xFE, 0xD6, 0x8F, 0x55, 0x57, 0x15, 0xB2, 0xA6,
403 0xA0, 0xE6, 0xA8, 0xC6, 0xBD, 0x28, 0xB4, 0xD5,
404 0x6E, 0x5B, 0x4B, 0xB0, 0x97, 0x09, 0xF5, 0xAC,
405 0x57, 0x65, 0x13, 0x97, 0x71, 0x2C, 0x45, 0x13,
406 0x3D, 0xEE, 0xFB, 0xBF, 0xFE, 0xAF, 0xBB, 0x4B,
407 0x0D, 0x5C, 0x45, 0xD4, 0x2F, 0x17, 0x92, 0x07,
408 0x66, 0x11, 0xF5, 0x46, 0xF8, 0x0C, 0x03, 0x92,
409 0xF5, 0xF5, 0xFF, 0xA4, 0xF3, 0x52, 0xF4, 0x08,
410 0x2C, 0x49, 0x32, 0x1A, 0x93, 0x51, 0x98, 0xB6,
411 0x94, 0x83, 0x39, 0xCF, 0x6B, 0x1F, 0x2F, 0xFC,
412 0x2B, 0xFF, 0x10, 0x71, 0x7D, 0x35, 0x6C, 0xEA,
413 0xC5, 0x66, 0xC7, 0x26, 0x7D, 0x9E, 0xAC, 0xDD,
414 0x35, 0xD7, 0x06, 0x3F, 0x40, 0x82, 0xDA, 0xC3,
415 0x2B, 0x3C, 0x91, 0x3A, 0x32, 0xF8, 0xB2, 0xC6,
416 0x44, 0x4D, 0xCD, 0xB6, 0x54, 0x5F, 0x81, 0x95,
417 0x59, 0xA1, 0xE5, 0x4E, 0xA5, 0x0A, 0x4A, 0x42),
418 chunk_from_chars(
419 1, 2, 2, 2, 2, 1, 2, 2, 0, 0, 2, 0, 0, 0, 0, 1, 2, 2, 2, 0,
420 2, 0, 0, 2, 2, 1, 2, 0, 0, 1, 2, 1, 0, 0, 0, 1, 0, 2, 2, 1,
421 1, 2, 0, 0, 0, 1, 2, 0, 2, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 1,
422 1, 2, 0, 1, 0, 2, 1, 1, 0, 0, 0, 1, 2, 0, 0, 1, 2, 1, 2, 0,
423 2, 1, 1, 1, 2, 2, 2, 2, 1, 0, 0, 2, 0, 2, 0, 1, 1, 0, 2, 2,
424 2, 0, 1, 0, 2, 2, 1, 0, 1, 0, 1, 0, 0, 2, 2, 0, 0, 1, 2, 0,
425 1, 1, 1, 0, 0, 2, 0, 2, 1, 2, 2, 2, 0, 0, 2, 1, 0, 2, 0, 1,
426 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 2, 0, 2, 2, 0, 1, 2, 2, 1, 2,
427 2, 2, 0, 2, 1, 1, 1, 0, 0, 1, 0, 2, 0, 0, 1, 0, 1, 2, 0, 0,
428 1, 2, 1, 0, 2, 1, 1, 0, 0, 2, 1, 2, 2, 2, 1, 2, 1, 1, 2, 2,
429 0, 2, 0, 0, 2, 0, 0, 1, 1, 2, 0, 0, 0, 1, 2, 1, 1, 1, 1, 0,
430 0, 0, 2, 0, 2, 0, 2, 2, 1, 2, 2, 0, 0, 1, 1, 1, 0, 1, 0, 1,
431 0, 1, 2, 2, 0, 2, 1, 1, 0, 2, 1, 2, 1, 2, 1, 0, 0, 1, 0, 0,
432 1, 0, 1, 0, 2, 0, 2, 0, 0, 1, 2, 0, 2, 0, 1, 1, 0, 2, 0, 0,
433 1, 2, 1, 2, 1, 2, 1, 0, 1, 1, 2, 2, 1, 1, 0, 0, 2, 1, 2, 0,
434 1, 0, 2, 0, 0, 1, 2, 0, 2, 0, 1, 1, 2, 2, 2, 2, 0, 0, 1, 2,
435 1, 1, 1, 0, 2, 1, 2, 2, 0, 2, 0, 1, 2, 2, 0, 1, 1, 1, 0, 0,
436 2, 0, 1, 0, 1, 0, 2, 1, 2, 0, 2, 1, 2, 1, 2, 2, 0, 2, 1, 0,
437 2, 1, 2, 0, 0, 2, 0, 1, 2, 1, 1, 2, 0, 0, 0, 0, 1, 2, 0, 1,
438 2, 2, 1, 0, 0, 1, 2, 1, 2, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0,
439 2, 0, 1, 2, 1, 2, 0, 0, 0, 2, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0,
440 2, 2, 1, 1, 0, 1, 0, 2, 2, 0, 2, 1, 2, 1, 0, 2, 2, 2, 0, 0,
441 0, 1, 1, 2, 1, 0, 0, 0, 0, 1, 2, 2, 1, 2, 1, 2, 0, 2, 0, 2,
442 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2,
443 2, 2, 2, 0, 1, 1, 1, 0, 1, 0, 2, 0, 2, 1, 0, 1, 2, 1, 1, 0,
444 1, 2, 1, 0, 0, 2, 1, 0, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0,
445 0, 0, 0, 1, 1, 0, 0, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1,
446 1, 0, 1, 1, 2, 2, 0, 1, 1, 0, 2, 2, 1, 1, 1, 2, 1, 2, 2, 1,
447 1, 0, 1, 0, 2, 2, 1, 0, 2, 2, 2, 2, 2, 1, 0, 2, 2, 2, 1, 2,
448 0, 2, 0, 0, 0, 0, 0, 1, 2, 0, 1, 0, 1)
449 }
450 };
451
452 START_TEST(test_ntru_mgf1)
453 {
454 ntru_mgf1_t *mgf1;
455 chunk_t mask, mask1, mask2, mask3;
456
457 mask1 = mgf1_tests[_i].mask;
458 mask2 = chunk_skip(mask1, mgf1_tests[_i].ml1);
459 mask3 = chunk_skip(mask2, mgf1_tests[_i].ml2);
460 mask1.len = mgf1_tests[_i].ml1;
461 mask2.len = mgf1_tests[_i].ml2;
462 mask3.len = mgf1_tests[_i].ml3;
463
464 mgf1 = ntru_mgf1_create(HASH_UNKNOWN, mgf1_tests[_i].seed, TRUE);
465 ck_assert(mgf1 == NULL);
466
467 mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, chunk_empty, TRUE);
468 ck_assert(mgf1 == NULL);
469
470 /* return mask in allocated chunk */
471 mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE);
472 ck_assert(mgf1);
473
474 /* check hash size */
475 ck_assert(mgf1->get_hash_size(mgf1) == mgf1_tests[_i].hash_size);
476
477 /* get zero number of octets */
478 ck_assert(mgf1->allocate_mask(mgf1, 0, &mask));
479 ck_assert(mask.len == 0 && mask.ptr == NULL);
480
481 /* get non-zero number of octets */
482 ck_assert(mgf1->allocate_mask(mgf1, mgf1_tests[_i].mask.len, &mask));
483 ck_assert(chunk_equals(mask, mgf1_tests[_i].mask));
484 mgf1->destroy(mgf1);
485
486 /* copy mask to pre-allocated buffer */
487 mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE);
488 ck_assert(mgf1);
489 ck_assert(mgf1->get_mask(mgf1, mgf1_tests[_i].mask.len, mask.ptr));
490 ck_assert(chunk_equals(mask, mgf1_tests[_i].mask));
491 mgf1->destroy(mgf1);
492
493 /* get mask in batches without hashing the seed */
494 mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].hashed_seed, FALSE);
495 ck_assert(mgf1);
496
497 /* first batch */
498 ck_assert(mgf1->get_mask(mgf1, mask1.len, mask.ptr));
499 mask.len = mask1.len;
500 ck_assert(chunk_equals(mask, mask1));
501
502 /* second batch */
503 ck_assert(mgf1->get_mask(mgf1, mask2.len, mask.ptr));
504 mask.len = mask2.len;
505 ck_assert(chunk_equals(mask, mask2));
506
507 /* third batch */
508 ck_assert(mgf1->get_mask(mgf1, mask3.len, mask.ptr));
509 mask.len = mask3.len;
510 ck_assert(chunk_equals(mask, mask3));
511
512 mgf1->destroy(mgf1);
513 chunk_free(&mask);
514 }
515 END_TEST
516
517 START_TEST(test_ntru_trits)
518 {
519 ntru_trits_t *mask;
520 chunk_t trits;
521
522 mask = ntru_trits_create(mgf1_tests[_i].trits.len, HASH_UNKNOWN,
523 mgf1_tests[_i].seed);
524 ck_assert(mask == NULL);
525
526 mask = ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg,
527 chunk_empty);
528 ck_assert(mask == NULL);
529
530 mask = ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg,
531 mgf1_tests[_i].seed);
532 ck_assert(mask);
533
534 trits = chunk_create(mask->get_trits(mask), mask->get_size(mask));
535 ck_assert(chunk_equals(trits, mgf1_tests[_i].trits));
536
537 mask->destroy(mask);
538 }
539 END_TEST
540
541 START_TEST(test_ntru_ke)
542 {
543 chunk_t pub_key, cipher_text, i_shared_secret, r_shared_secret;
544 diffie_hellman_t *i_ntru, *r_ntru;
545 char buf[10];
546 int n, len;
547 status_t status;
548
549 len = snprintf(buf, sizeof(buf), "%N", diffie_hellman_group_names,
550 params[_i].group);
551 ck_assert(len == 8);
552 ck_assert(streq(buf, params[_i].group_name));
553
554 for (n = 0; n < countof(parameter_sets); n++)
555 {
556 lib->settings->set_str(lib->settings,
557 "libstrongswan.plugins.ntru.parameter_set",
558 parameter_sets[n]);
559
560 i_ntru = lib->crypto->create_dh(lib->crypto, params[_i].group);
561 ck_assert(i_ntru != NULL);
562 ck_assert(i_ntru->get_dh_group(i_ntru) == params[_i].group);
563
564 i_ntru->get_my_public_value(i_ntru, &pub_key);
565 ck_assert(pub_key.len > 0);
566
567 r_ntru = lib->crypto->create_dh(lib->crypto, params[_i].group);
568 ck_assert(r_ntru != NULL);
569
570 r_ntru->set_other_public_value(r_ntru, pub_key);
571 r_ntru->get_my_public_value(r_ntru, &cipher_text);
572 ck_assert(cipher_text.len > 0);
573
574 status = r_ntru->get_shared_secret(r_ntru, &r_shared_secret);
575 ck_assert(status == SUCCESS);
576 ck_assert(r_shared_secret.len > 0);
577
578 i_ntru->set_other_public_value(i_ntru, cipher_text);
579 status = i_ntru->get_shared_secret(i_ntru, &i_shared_secret);
580
581 if (status == SUCCESS)
582 {
583 ck_assert(chunk_equals(i_shared_secret, r_shared_secret));
584 }
585 else
586 {
587 ck_assert(i_shared_secret.len == 0);
588 }
589
590 chunk_clear(&i_shared_secret);
591 chunk_clear(&r_shared_secret);
592 chunk_free(&pub_key);
593 chunk_free(&cipher_text);
594 i_ntru->destroy(i_ntru);
595 r_ntru->destroy(r_ntru);
596 }
597 }
598 END_TEST
599
600 START_TEST(test_ntru_retransmission)
601 {
602 diffie_hellman_t *i_ntru;
603 chunk_t pub_key1, pub_key2;
604
605 i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_256_BIT);
606 i_ntru->get_my_public_value(i_ntru, &pub_key1);
607 i_ntru->get_my_public_value(i_ntru, &pub_key2);
608 ck_assert(chunk_equals(pub_key1, pub_key2));
609
610 chunk_free(&pub_key1);
611 chunk_free(&pub_key2);
612 i_ntru->destroy(i_ntru);
613 }
614 END_TEST
615
616 chunk_t oid_tests[] = {
617 { NULL, 0 },
618 chunk_from_chars(0x00),
619 chunk_from_chars(0x01),
620 chunk_from_chars(0x02),
621 chunk_from_chars(0x02, 0x03, 0x00, 0x03, 0x10),
622 chunk_from_chars(0x01, 0x04, 0x00, 0x03, 0x10),
623 chunk_from_chars(0x01, 0x03, 0x00, 0x03, 0x10),
624 chunk_from_chars(0x01, 0x03, 0xff, 0x03, 0x10),
625 };
626
627 START_TEST(test_ntru_pubkey_oid)
628 {
629 diffie_hellman_t *r_ntru;
630 chunk_t cipher_text;
631
632 r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
633 r_ntru->set_other_public_value(r_ntru, oid_tests[_i]);
634 r_ntru->get_my_public_value(r_ntru, &cipher_text);
635 ck_assert(cipher_text.len == 0);
636 r_ntru->destroy(r_ntru);
637 }
638 END_TEST
639
640 START_TEST(test_ntru_wrong_set)
641 {
642 diffie_hellman_t *i_ntru, *r_ntru;
643 chunk_t pub_key, cipher_text;
644
645 lib->settings->set_str(lib->settings,
646 "libstrongswan.plugins.ntru.parameter_set",
647 "x9_98_bandwidth");
648 i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT);
649 i_ntru->get_my_public_value(i_ntru, &pub_key);
650
651 lib->settings->set_str(lib->settings,
652 "libstrongswan.plugins.ntru.parameter_set",
653 "optimum");
654 r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT);
655 r_ntru->set_other_public_value(r_ntru, pub_key);
656 r_ntru->get_my_public_value(r_ntru, &cipher_text);
657 ck_assert(cipher_text.len == 0);
658
659 chunk_free(&pub_key);
660 chunk_free(&cipher_text);
661 i_ntru->destroy(i_ntru);
662 r_ntru->destroy(r_ntru);
663 }
664 END_TEST
665
666 START_TEST(test_ntru_ciphertext)
667 {
668 char buf_00[604], buf_ff[604];
669
670 chunk_t test[] = {
671 chunk_empty,
672 chunk_from_chars(0x00),
673 chunk_create(buf_00, sizeof(buf_00)),
674 chunk_create(buf_ff, sizeof(buf_ff)),
675 };
676
677 diffie_hellman_t *i_ntru;
678 chunk_t pub_key, shared_secret;
679 int i;
680
681 memset(buf_00, 0x00, sizeof(buf_00));
682 memset(buf_ff, 0xff, sizeof(buf_ff));
683
684 for (i = 0; i < countof(test); i++)
685 {
686 i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
687 i_ntru->get_my_public_value(i_ntru, &pub_key);
688 i_ntru->set_other_public_value(i_ntru, test[i]);
689 ck_assert(i_ntru->get_shared_secret(i_ntru, &shared_secret) != SUCCESS);
690 ck_assert(shared_secret.len == 0);
691
692 chunk_free(&pub_key);
693 i_ntru->destroy(i_ntru);
694 }
695 }
696 END_TEST
697
698 START_TEST(test_ntru_wrong_ciphertext)
699 {
700 diffie_hellman_t *i_ntru, *r_ntru, *m_ntru;
701 chunk_t pub_key_i, pub_key_m, cipher_text, shared_secret;
702
703 i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
704 r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
705 m_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
706
707 i_ntru->get_my_public_value(i_ntru, &pub_key_i);
708 m_ntru->get_my_public_value(m_ntru, &pub_key_m);
709 r_ntru->set_other_public_value(r_ntru, pub_key_m);
710 r_ntru->get_my_public_value(r_ntru, &cipher_text);
711 i_ntru->set_other_public_value(i_ntru, cipher_text);
712 ck_assert(i_ntru->get_shared_secret(i_ntru, &shared_secret) != SUCCESS);
713 ck_assert(shared_secret.len == 0);
714
715 chunk_free(&pub_key_i);
716 chunk_free(&pub_key_m);
717 chunk_free(&cipher_text);
718 i_ntru->destroy(i_ntru);
719 m_ntru->destroy(m_ntru);
720 r_ntru->destroy(r_ntru);
721 }
722 END_TEST
723
724 Suite *ntru_suite_create()
725 {
726 Suite *s;
727 TCase *tc;
728
729 s = suite_create("ntru");
730
731 tc = tcase_create("drbg_strength");
732 tcase_add_loop_test(tc, test_ntru_drbg_strength, 0, countof(strengths));
733 suite_add_tcase(s, tc);
734
735 tc = tcase_create("drbg");
736 tcase_add_loop_test(tc, test_ntru_drbg, 0, countof(drbg_tests));
737 suite_add_tcase(s, tc);
738
739 tc = tcase_create("drgb_reseed");
740 tcase_add_test(tc, test_ntru_drbg_reseed);
741 suite_add_tcase(s, tc);
742
743 tc = tcase_create("mgf1");
744 tcase_add_loop_test(tc, test_ntru_mgf1, 0, countof(mgf1_tests));
745 suite_add_tcase(s, tc);
746
747 tc = tcase_create("trits");
748 tcase_add_loop_test(tc, test_ntru_trits, 0, countof(mgf1_tests));
749 suite_add_tcase(s, tc);
750
751 tc = tcase_create("ke");
752 tcase_add_loop_test(tc, test_ntru_ke, 0, countof(params));
753 suite_add_tcase(s, tc);
754
755 tc = tcase_create("retransmission");
756 tcase_add_test(tc, test_ntru_retransmission);
757 suite_add_tcase(s, tc);
758
759 tc = tcase_create("pubkey_oid");
760 tcase_add_loop_test(tc, test_ntru_pubkey_oid, 0, countof(oid_tests));
761 suite_add_tcase(s, tc);
762
763 tc = tcase_create("wrong_set");
764 tcase_add_test(tc, test_ntru_wrong_set);
765 suite_add_tcase(s, tc);
766
767 tc = tcase_create("ciphertext");
768 tcase_add_test(tc, test_ntru_ciphertext);
769 suite_add_tcase(s, tc);
770
771 tc = tcase_create("wrong_ciphertext");
772 tcase_add_test(tc, test_ntru_wrong_ciphertext);
773 suite_add_tcase(s, tc);
774 return s;
775 }