]>
Commit | Line | Data |
---|---|---|
7960dbec DDO |
1 | /* |
2 | * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. | |
3 | * Copyright Nokia 2007-2019 | |
4 | * Copyright Siemens AG 2015-2019 | |
5 | * | |
6 | * Licensed under the Apache License 2.0 (the "License"). You may not use | |
7 | * this file except in compliance with the License. You can obtain a copy | |
8 | * in the file LICENSE in the source distribution or at | |
9 | * https://www.openssl.org/source/license.html | |
10 | */ | |
11 | ||
12 | #include "cmp_testlib.h" | |
13 | ||
14 | #include <openssl/x509_vfy.h> | |
15 | ||
16 | typedef struct test_fixture { | |
17 | const char *test_case_name; | |
18 | OSSL_CMP_CTX *ctx; | |
19 | } OSSL_CMP_CTX_TEST_FIXTURE; | |
20 | ||
21 | static void tear_down(OSSL_CMP_CTX_TEST_FIXTURE *fixture) | |
22 | { | |
23 | if (fixture != NULL) | |
24 | OSSL_CMP_CTX_free(fixture->ctx); | |
25 | OPENSSL_free(fixture); | |
26 | } | |
27 | ||
28 | static OSSL_CMP_CTX_TEST_FIXTURE *set_up(const char *const test_case_name) | |
29 | { | |
30 | OSSL_CMP_CTX_TEST_FIXTURE *fixture; | |
31 | ||
4dde554c DDO |
32 | if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))) |
33 | return NULL; | |
34 | if (!TEST_ptr(fixture->ctx = OSSL_CMP_CTX_new())) { | |
7960dbec DDO |
35 | tear_down(fixture); |
36 | return NULL; | |
37 | } | |
38 | fixture->test_case_name = test_case_name; | |
39 | return fixture; | |
40 | } | |
41 | ||
3dbc5156 DDO |
42 | static STACK_OF(X509) *sk_X509_new_1(void) |
43 | { | |
7960dbec DDO |
44 | STACK_OF(X509) *sk = sk_X509_new_null(); |
45 | X509 *x = X509_new(); | |
46 | ||
47 | if (x == NULL || !sk_X509_push(sk, x)) { | |
48 | sk_X509_free(sk); | |
49 | X509_free(x); | |
50 | sk = NULL; | |
51 | } | |
52 | return sk; | |
53 | } | |
54 | ||
3dbc5156 DDO |
55 | static void sk_X509_pop_X509_free(STACK_OF(X509) *sk) |
56 | { | |
7960dbec DDO |
57 | sk_X509_pop_free(sk, X509_free); |
58 | } | |
59 | ||
60 | static int execute_CTX_reinit_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture) | |
61 | { | |
62 | OSSL_CMP_CTX *ctx = fixture->ctx; | |
63 | ASN1_OCTET_STRING *bytes = NULL; | |
64 | STACK_OF(X509) *certs = NULL; | |
65 | int res = 0; | |
66 | ||
67 | /* set non-default values in all relevant fields */ | |
68 | ctx->status = 1; | |
69 | ctx->failInfoCode = 1; | |
70 | if (!ossl_cmp_ctx_set0_statusString(ctx, sk_ASN1_UTF8STRING_new_null()) | |
71 | || !ossl_cmp_ctx_set0_newCert(ctx, X509_new()) | |
72 | || !TEST_ptr(certs = sk_X509_new_1()) | |
73 | || !ossl_cmp_ctx_set1_caPubs(ctx, certs) | |
74 | || !ossl_cmp_ctx_set1_extraCertsIn(ctx, certs) | |
75 | || !ossl_cmp_ctx_set0_validatedSrvCert(ctx, X509_new()) | |
76 | || !TEST_ptr(bytes = ASN1_OCTET_STRING_new()) | |
77 | || !OSSL_CMP_CTX_set1_transactionID(ctx, bytes) | |
78 | || !OSSL_CMP_CTX_set1_senderNonce(ctx, bytes) | |
79 | || !ossl_cmp_ctx_set1_recipNonce(ctx, bytes)) | |
7960dbec DDO |
80 | goto err; |
81 | ||
82 | if (!TEST_true(OSSL_CMP_CTX_reinit(ctx))) | |
83 | goto err; | |
84 | ||
85 | /* check whether values have been reset to default in all relevant fields */ | |
86 | if (!TEST_true(ctx->status == -1 | |
87 | && ctx->failInfoCode == -1 | |
88 | && ctx->statusString == NULL | |
89 | && ctx->newCert == NULL | |
90 | && ctx->caPubs == NULL | |
91 | && ctx->extraCertsIn == NULL | |
92 | && ctx->validatedSrvCert == NULL | |
93 | && ctx->transactionID == NULL | |
94 | && ctx->senderNonce == NULL | |
95 | && ctx->recipNonce == NULL)) | |
96 | goto err; | |
97 | ||
98 | /* this does not check that all remaining fields are untouched */ | |
99 | res = 1; | |
100 | ||
101 | err: | |
102 | sk_X509_pop_X509_free(certs); | |
103 | ASN1_OCTET_STRING_free(bytes); | |
104 | return res; | |
105 | } | |
106 | ||
107 | static int test_CTX_reinit(void) | |
108 | { | |
109 | SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); | |
110 | EXECUTE_TEST(execute_CTX_reinit_test, tear_down); | |
111 | return result; | |
112 | } | |
113 | ||
8e1a1582 | 114 | #if !defined(OPENSSL_NO_ERR) && !defined(OPENSSL_NO_AUTOERRINIT) |
85870311 | 115 | |
7960dbec DDO |
116 | static int msg_total_size = 0; |
117 | static int msg_total_size_log_cb(const char *func, const char *file, int line, | |
118 | OSSL_CMP_severity level, const char *msg) | |
119 | { | |
120 | msg_total_size += strlen(msg); | |
0acaa795 | 121 | TEST_note("total=%d len=%zu msg='%s'\n", msg_total_size, strlen(msg), msg); |
7960dbec DDO |
122 | return 1; |
123 | } | |
124 | ||
85870311 | 125 | # define STR64 "This is a 64 bytes looooooooooooooooooooooooooooooooong string.\n" |
7960dbec | 126 | /* max string length ISO C90 compilers are required to support is 509. */ |
85870311 | 127 | # define STR509 STR64 STR64 STR64 STR64 STR64 STR64 STR64 \ |
7960dbec DDO |
128 | "This is a 61 bytes loooooooooooooooooooooooooooooong string.\n" |
129 | static const char *const max_str_literal = STR509; | |
85870311 | 130 | # define STR_SEP "<SEP>" |
7960dbec DDO |
131 | |
132 | static int execute_CTX_print_errors_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture) | |
133 | { | |
134 | OSSL_CMP_CTX *ctx = fixture->ctx; | |
135 | int base_err_msg_size, expected_size; | |
136 | int res = 1; | |
137 | ||
138 | if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, NULL))) | |
139 | res = 0; | |
140 | if (!TEST_true(ctx->log_cb == NULL)) | |
141 | res = 0; | |
142 | ||
85870311 | 143 | # ifndef OPENSSL_NO_STDIO |
7960dbec DDO |
144 | CMPerr(0, CMP_R_MULTIPLE_SAN_SOURCES); |
145 | OSSL_CMP_CTX_print_errors(ctx); /* should print above error to STDERR */ | |
85870311 | 146 | # endif |
7960dbec DDO |
147 | |
148 | /* this should work regardless of OPENSSL_NO_STDIO and OPENSSL_NO_TRACE: */ | |
149 | if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, msg_total_size_log_cb))) | |
150 | res = 0; | |
151 | if (!TEST_true(ctx->log_cb == msg_total_size_log_cb)) { | |
152 | res = 0; | |
153 | } else { | |
154 | CMPerr(0, CMP_R_INVALID_ARGS); | |
155 | base_err_msg_size = strlen("INVALID_ARGS"); | |
156 | CMPerr(0, CMP_R_NULL_ARGUMENT); | |
157 | base_err_msg_size += strlen("NULL_ARGUMENT"); | |
158 | expected_size = base_err_msg_size; | |
159 | ossl_cmp_add_error_data("data1"); /* should prepend separator " : " */ | |
160 | expected_size += strlen(" : " "data1"); | |
161 | ossl_cmp_add_error_data("data2"); /* should prepend separator " : " */ | |
162 | expected_size += strlen(" : " "data2"); | |
163 | ossl_cmp_add_error_line("new line"); /* should prepend separator "\n" */ | |
164 | expected_size += strlen("\n" "new line"); | |
165 | OSSL_CMP_CTX_print_errors(ctx); | |
166 | if (!TEST_int_eq(msg_total_size, expected_size)) | |
167 | res = 0; | |
168 | ||
169 | CMPerr(0, CMP_R_INVALID_ARGS); | |
170 | base_err_msg_size = strlen("INVALID_ARGS") + strlen(" : "); | |
171 | expected_size = base_err_msg_size; | |
172 | while (expected_size < 4096) { /* force split */ | |
31b28ad9 | 173 | ERR_add_error_txt(STR_SEP, max_str_literal); |
7960dbec DDO |
174 | expected_size += strlen(STR_SEP) + strlen(max_str_literal); |
175 | } | |
176 | expected_size += base_err_msg_size - 2 * strlen(STR_SEP); | |
177 | msg_total_size = 0; | |
178 | OSSL_CMP_CTX_print_errors(ctx); | |
179 | if (!TEST_int_eq(msg_total_size, expected_size)) | |
180 | res = 0; | |
181 | } | |
182 | ||
183 | return res; | |
184 | } | |
185 | ||
186 | static int test_CTX_print_errors(void) | |
187 | { | |
188 | SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); | |
189 | EXECUTE_TEST(execute_CTX_print_errors_test, tear_down); | |
190 | return result; | |
191 | } | |
85870311 | 192 | #endif |
7960dbec | 193 | |
235595c4 DDO |
194 | static |
195 | int execute_CTX_reqExtensions_have_SAN_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture) | |
7960dbec DDO |
196 | { |
197 | OSSL_CMP_CTX *ctx = fixture->ctx; | |
198 | const int len = 16; | |
ebf30069 | 199 | unsigned char str[16 /* = len */]; |
7960dbec DDO |
200 | ASN1_OCTET_STRING *data = NULL; |
201 | X509_EXTENSION *ext = NULL; | |
202 | X509_EXTENSIONS *exts = NULL; | |
203 | int res = 0; | |
204 | ||
205 | if (!TEST_false(OSSL_CMP_CTX_reqExtensions_have_SAN(ctx))) | |
206 | return 0; | |
207 | ||
208 | if (!TEST_int_eq(1, RAND_bytes(str, len)) | |
209 | || !TEST_ptr(data = ASN1_OCTET_STRING_new()) | |
210 | || !TEST_true(ASN1_OCTET_STRING_set(data, str, len))) | |
211 | goto err; | |
212 | ext = X509_EXTENSION_create_by_NID(NULL, NID_subject_alt_name, 0, data); | |
213 | if (!TEST_ptr(ext) | |
214 | || !TEST_ptr(exts = sk_X509_EXTENSION_new_null()) | |
215 | || !TEST_true(sk_X509_EXTENSION_push(exts, ext)) | |
216 | || !TEST_true(OSSL_CMP_CTX_set0_reqExtensions(ctx, exts))) { | |
217 | X509_EXTENSION_free(ext); | |
218 | sk_X509_EXTENSION_free(exts); | |
219 | goto err; | |
220 | } | |
221 | if (TEST_int_eq(OSSL_CMP_CTX_reqExtensions_have_SAN(ctx), 1)) { | |
222 | ext = sk_X509_EXTENSION_pop(exts); | |
223 | res = TEST_false(OSSL_CMP_CTX_reqExtensions_have_SAN(ctx)); | |
224 | X509_EXTENSION_free(ext); | |
225 | } | |
226 | err: | |
227 | ASN1_OCTET_STRING_free(data); | |
228 | return res; | |
229 | } | |
230 | ||
231 | static int test_CTX_reqExtensions_have_SAN(void) | |
232 | { | |
233 | SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); | |
234 | EXECUTE_TEST(execute_CTX_reqExtensions_have_SAN_test, tear_down); | |
235 | return result; | |
236 | } | |
237 | ||
7960dbec DDO |
238 | static int test_log_line; |
239 | static int test_log_cb_res = 0; | |
240 | static int test_log_cb(const char *func, const char *file, int line, | |
241 | OSSL_CMP_severity level, const char *msg) | |
242 | { | |
243 | test_log_cb_res = | |
235595c4 | 244 | #ifndef PEDANTIC |
ebf30069 DDO |
245 | (TEST_str_eq(func, "execute_cmp_ctx_log_cb_test") |
246 | || TEST_str_eq(func, "(unknown function)")) && | |
235595c4 | 247 | #endif |
ebf30069 DDO |
248 | (TEST_str_eq(file, OPENSSL_FILE) |
249 | || TEST_str_eq(file, "(no file)")) | |
250 | && (TEST_int_eq(line, test_log_line) || TEST_int_eq(line, 0)) | |
251 | && (TEST_int_eq(level, OSSL_CMP_LOG_INFO) || TEST_int_eq(level, -1)) | |
252 | && TEST_str_eq(msg, "ok"); | |
7960dbec DDO |
253 | return 1; |
254 | } | |
7960dbec DDO |
255 | |
256 | static int execute_cmp_ctx_log_cb_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture) | |
257 | { | |
258 | int res = 1; | |
7960dbec DDO |
259 | OSSL_CMP_CTX *ctx = fixture->ctx; |
260 | ||
261 | OSSL_TRACE(ALL, "this general trace message is not shown by default\n"); | |
262 | ||
263 | OSSL_CMP_log_open(); | |
264 | OSSL_CMP_log_open(); /* multiple calls should be harmless */ | |
265 | ||
266 | if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, NULL))) { | |
267 | res = 0; | |
268 | } else { | |
ebf30069 DDO |
269 | ossl_cmp_err(ctx, "this should be printed as CMP error message"); |
270 | ossl_cmp_warn(ctx, "this should be printed as CMP warning message"); | |
271 | ossl_cmp_debug(ctx, "this should not be printed"); | |
7960dbec | 272 | TEST_true(OSSL_CMP_CTX_set_log_verbosity(ctx, OSSL_CMP_LOG_DEBUG)); |
ebf30069 | 273 | ossl_cmp_debug(ctx, "this should be printed as CMP debug message"); |
7960dbec DDO |
274 | TEST_true(OSSL_CMP_CTX_set_log_verbosity(ctx, OSSL_CMP_LOG_INFO)); |
275 | } | |
276 | if (!TEST_true(OSSL_CMP_CTX_set_log_cb(ctx, test_log_cb))) { | |
277 | res = 0; | |
278 | } else { | |
279 | test_log_line = OPENSSL_LINE + 1; | |
ebf30069 | 280 | ossl_cmp_log2(INFO, ctx, "%s%c", "o", 'k'); |
7960dbec DDO |
281 | if (!TEST_int_eq(test_log_cb_res, 1)) |
282 | res = 0; | |
283 | OSSL_CMP_CTX_set_log_verbosity(ctx, OSSL_CMP_LOG_ERR); | |
284 | test_log_cb_res = -1; /* callback should not be called at all */ | |
285 | test_log_line = OPENSSL_LINE + 1; | |
ebf30069 | 286 | ossl_cmp_log2(INFO, ctx, "%s%c", "o", 'k'); |
7960dbec DDO |
287 | if (!TEST_int_eq(test_log_cb_res, -1)) |
288 | res = 0; | |
289 | } | |
290 | OSSL_CMP_log_close(); | |
291 | OSSL_CMP_log_close(); /* multiple calls should be harmless */ | |
7960dbec DDO |
292 | return res; |
293 | } | |
294 | ||
295 | static int test_cmp_ctx_log_cb(void) | |
296 | { | |
297 | SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); | |
298 | EXECUTE_TEST(execute_cmp_ctx_log_cb_test, tear_down); | |
299 | return result; | |
300 | } | |
301 | ||
29f178bd | 302 | static BIO *test_http_cb(BIO *bio, void *arg, int use_ssl, int detail) |
7960dbec DDO |
303 | { |
304 | return NULL; | |
305 | } | |
306 | ||
29f178bd DDO |
307 | static OSSL_CMP_MSG *test_transfer_cb(OSSL_CMP_CTX *ctx, |
308 | const OSSL_CMP_MSG *req) | |
7960dbec | 309 | { |
29f178bd | 310 | return NULL; |
7960dbec DDO |
311 | } |
312 | ||
313 | static int test_certConf_cb(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info, | |
314 | const char **txt) | |
315 | { | |
316 | return 0; | |
317 | } | |
318 | ||
319 | typedef OSSL_CMP_CTX CMP_CTX; /* prevents rewriting type name by below macro */ | |
320 | #define OSSL_CMP_CTX 1 /* name prefix for exported setter functions */ | |
321 | #define ossl_cmp_ctx 0 /* name prefix for internal setter functions */ | |
322 | #define set 0 | |
323 | #define set0 0 | |
324 | #define set1 1 | |
325 | #define get 0 | |
326 | #define get0 0 | |
327 | #define get1 1 | |
328 | ||
329 | #define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \ | |
330 | DEFAULT, NEW, FREE) \ | |
235595c4 DDO |
331 | static int \ |
332 | execute_CTX_##SETN##_##GETN##_##FIELD(OSSL_CMP_CTX_TEST_FIXTURE *fixture) \ | |
7960dbec DDO |
333 | { \ |
334 | CMP_CTX *ctx = fixture->ctx; \ | |
335 | int (*set_fn)(CMP_CTX *ctx, TYPE) = \ | |
336 | (int (*)(CMP_CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \ | |
235595c4 | 337 | /* need type cast in above assignment as TYPE arg sometimes is const */ \ |
7960dbec DDO |
338 | TYPE (*get_fn)(const CMP_CTX *ctx) = OSSL_CMP_CTX_##GETN##_##FIELD; \ |
339 | TYPE val1_to_free = NEW; \ | |
340 | TYPE val1 = val1_to_free; \ | |
341 | TYPE val1_read = 0; /* 0 works for any type */ \ | |
342 | TYPE val2_to_free = NEW; \ | |
343 | TYPE val2 = val2_to_free; \ | |
344 | TYPE val2_read = 0; \ | |
345 | TYPE val3_read = 0; \ | |
346 | int res = 1; \ | |
347 | \ | |
348 | if (!TEST_int_eq(ERR_peek_error(), 0)) \ | |
349 | res = 0; \ | |
350 | if (PREFIX == 1) { /* exported setter functions must test ctx == NULL */ \ | |
351 | if ((*set_fn)(NULL, val1) || ERR_peek_error() == 0) { \ | |
352 | TEST_error("setter did not return error on ctx == NULL"); \ | |
353 | res = 0; \ | |
354 | } \ | |
355 | } \ | |
356 | ERR_clear_error(); \ | |
357 | \ | |
358 | if ((*get_fn)(NULL) != ERR || ERR_peek_error() == 0) { \ | |
359 | TEST_error("getter did not return error on ctx == NULL"); \ | |
360 | res = 0; \ | |
361 | } \ | |
362 | ERR_clear_error(); \ | |
363 | \ | |
364 | val1_read = (*get_fn)(ctx); \ | |
365 | if (!DEFAULT(val1_read)) { \ | |
366 | TEST_error("did not get default value"); \ | |
367 | res = 0; \ | |
368 | } \ | |
369 | if (!(*set_fn)(ctx, val1)) { \ | |
370 | TEST_error("setting first value failed"); \ | |
371 | res = 0; \ | |
372 | } \ | |
373 | if (SETN == 0) \ | |
374 | val1_to_free = 0; /* 0 works for any type */ \ | |
375 | \ | |
376 | if (GETN == 1) \ | |
377 | FREE(val1_read); \ | |
378 | val1_read = (*get_fn)(ctx); \ | |
379 | if (SETN == 0) { \ | |
380 | if (val1_read != val1) { \ | |
381 | TEST_error("set/get first value did not match"); \ | |
382 | res = 0; \ | |
383 | } \ | |
384 | } else { \ | |
385 | if (DUP && val1_read == val1) { \ | |
386 | TEST_error("first set did not dup the value"); \ | |
387 | res = 0; \ | |
388 | } \ | |
389 | if (DEFAULT(val1_read)) { \ | |
390 | TEST_error("first set had no effect"); \ | |
391 | res = 0; \ | |
392 | } \ | |
393 | } \ | |
394 | \ | |
395 | if (!(*set_fn)(ctx, val2)) { \ | |
396 | TEST_error("setting second value failed"); \ | |
397 | res = 0; \ | |
398 | } \ | |
399 | if (SETN == 0) \ | |
400 | val2_to_free = 0; \ | |
401 | \ | |
402 | val2_read = (*get_fn)(ctx); \ | |
403 | if (DEFAULT(val2_read)) { \ | |
404 | TEST_error("second set reset the value"); \ | |
405 | res = 0; \ | |
406 | } \ | |
407 | if (SETN == 0 && GETN == 0) { \ | |
408 | if (val2_read != val2) { \ | |
409 | TEST_error("set/get second value did not match"); \ | |
410 | res = 0; \ | |
411 | } \ | |
412 | } else { \ | |
413 | if (DUP && val2_read == val2) { \ | |
414 | TEST_error("second set did not dup the value"); \ | |
415 | res = 0; \ | |
416 | } \ | |
417 | if (val2 == val1) { \ | |
418 | TEST_error("second value is same as first value"); \ | |
419 | res = 0; \ | |
420 | } \ | |
421 | if (GETN == 1 && val2_read == val1_read) { \ | |
422 | /* \ | |
423 | * Note that if GETN == 0 then possibly val2_read == val1_read \ | |
424 | * because set1 may allocate the new copy at the same location. \ | |
425 | */ \ | |
426 | TEST_error("second get returned same as first get"); \ | |
427 | res = 0; \ | |
428 | } \ | |
429 | } \ | |
430 | \ | |
431 | val3_read = (*get_fn)(ctx); \ | |
432 | if (DEFAULT(val3_read)) { \ | |
433 | TEST_error("third set reset the value"); \ | |
434 | res = 0; \ | |
435 | } \ | |
436 | if (GETN == 0) { \ | |
437 | if (val3_read != val2_read) { \ | |
438 | TEST_error("third get gave different value"); \ | |
439 | res = 0; \ | |
440 | } \ | |
235595c4 | 441 | } else { \ |
7960dbec DDO |
442 | if (DUP && val3_read == val2_read) { \ |
443 | TEST_error("third get did not create a new dup"); \ | |
444 | res = 0; \ | |
445 | } \ | |
446 | } \ | |
447 | /* this does not check that all remaining fields are untouched */ \ | |
448 | \ | |
449 | if (!TEST_int_eq(ERR_peek_error(), 0)) \ | |
450 | res = 0; \ | |
451 | \ | |
452 | FREE(val1_to_free); \ | |
453 | FREE(val2_to_free); \ | |
454 | if (GETN == 1) { \ | |
455 | FREE(val1_read); \ | |
456 | FREE(val2_read); \ | |
457 | FREE(val3_read); \ | |
458 | } \ | |
459 | return TEST_true(res); \ | |
460 | } \ | |
461 | \ | |
462 | static int test_CTX_##SETN##_##GETN##_##FIELD(void) \ | |
463 | { \ | |
464 | SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); \ | |
465 | EXECUTE_TEST(execute_CTX_##SETN##_##GETN##_##FIELD, tear_down); \ | |
466 | return result; \ | |
467 | } | |
468 | ||
3dbc5156 DDO |
469 | static char *char_new(void) |
470 | { | |
7960dbec DDO |
471 | return OPENSSL_strdup("test"); |
472 | } | |
473 | ||
3dbc5156 DDO |
474 | static void char_free(char *val) |
475 | { | |
7960dbec DDO |
476 | OPENSSL_free(val); |
477 | } | |
478 | ||
479 | #define EMPTY_SK_X509(x) ((x) == NULL || sk_X509_num(x) == 0) | |
480 | ||
3dbc5156 DDO |
481 | static X509_STORE *X509_STORE_new_1(void) |
482 | { | |
7960dbec DDO |
483 | X509_STORE *store = X509_STORE_new(); |
484 | ||
485 | if (store != NULL) | |
486 | X509_VERIFY_PARAM_set_flags(X509_STORE_get0_param(store), 1); | |
487 | return store; | |
488 | } | |
489 | ||
235595c4 DDO |
490 | #define DEFAULT_STORE(x) \ |
491 | ((x) == NULL || X509_VERIFY_PARAM_get_flags(X509_STORE_get0_param(x)) == 0) | |
7960dbec DDO |
492 | |
493 | #define IS_NEG(x) ((x) < 0) | |
494 | #define IS_0(x) ((x) == 0) /* for any type */ | |
495 | #define IS_DEFAULT_PORT(x) ((x) == OSSL_CMP_DEFAULT_PORT) | |
496 | #define DROP(x) (void)(x) /* dummy free() for non-pointer and function types */ | |
497 | ||
498 | #define ERR(x) (CMPerr(0, CMP_R_NULL_ARGUMENT), x) | |
499 | ||
500 | #define DEFINE_SET_GET_TEST(OSSL_CMP, CTX, N, M, DUP, FIELD, TYPE) \ | |
501 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get##M, DUP, FIELD, \ | |
235595c4 | 502 | TYPE *, NULL, IS_0, TYPE##_new(), TYPE##_free) |
7960dbec DDO |
503 | |
504 | #define DEFINE_SET_GET_SK_TEST_DEFAULT(OSSL_CMP, CTX, N, M, FIELD, ELEM_TYPE, \ | |
505 | DEFAULT, NEW, FREE) \ | |
506 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get##M, 1, FIELD, \ | |
3dbc5156 | 507 | STACK_OF(ELEM_TYPE)*, NULL, DEFAULT, NEW, FREE) |
7960dbec DDO |
508 | #define DEFINE_SET_GET_SK_TEST(OSSL_CMP, CTX, N, M, FIELD, T) \ |
509 | DEFINE_SET_GET_SK_TEST_DEFAULT(OSSL_CMP, CTX, N, M, FIELD, T, \ | |
3dbc5156 | 510 | IS_0, sk_##T##_new_null(), sk_##T##_free) |
7960dbec DDO |
511 | #define DEFINE_SET_GET_SK_X509_TEST(OSSL_CMP, CTX, N, M, FNAME) \ |
512 | DEFINE_SET_GET_SK_TEST_DEFAULT(OSSL_CMP, CTX, N, M, FNAME, X509, \ | |
3dbc5156 DDO |
513 | EMPTY_SK_X509, \ |
514 | sk_X509_new_1(), sk_X509_pop_X509_free) | |
7960dbec DDO |
515 | |
516 | #define DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, N, M, DUP, FIELD, TYPE, \ | |
517 | DEFAULT) \ | |
518 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get##M, DUP, FIELD, \ | |
235595c4 | 519 | TYPE *, NULL, DEFAULT, TYPE##_new(), TYPE##_free) |
7960dbec DDO |
520 | #define DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, N, DUP, FIELD, TYPE, DEFAULT) \ |
521 | static TYPE *OSSL_CMP_CTX_get0_##FIELD(const CMP_CTX *ctx) \ | |
522 | { \ | |
8cc86b81 | 523 | return ctx == NULL ? ERR(NULL) : (TYPE *)ctx->FIELD; \ |
7960dbec DDO |
524 | } \ |
525 | DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, N, 0, DUP, FIELD, TYPE, DEFAULT) | |
526 | #define DEFINE_SET_TEST(OSSL_CMP, CTX, N, DUP, FIELD, TYPE) \ | |
527 | DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, N, DUP, FIELD, TYPE, IS_0) | |
528 | ||
529 | #define DEFINE_SET_SK_TEST(OSSL_CMP, CTX, N, FIELD, TYPE) \ | |
530 | static STACK_OF(TYPE) *OSSL_CMP_CTX_get0_##FIELD(const CMP_CTX *ctx) \ | |
531 | { \ | |
532 | return ctx == NULL ? ERR(NULL) : ctx->FIELD; \ | |
533 | } \ | |
534 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set##N, get0, 1, FIELD, \ | |
3dbc5156 DDO |
535 | STACK_OF(TYPE)*, NULL, IS_0, \ |
536 | sk_##TYPE##_new_null(), sk_##TYPE##_free) | |
7960dbec | 537 | |
29f178bd | 538 | typedef OSSL_HTTP_bio_cb_t OSSL_cmp_http_cb_t; |
7960dbec | 539 | #define DEFINE_SET_CB_TEST(FIELD) \ |
3dbc5156 | 540 | static OSSL_cmp_##FIELD##_t OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \ |
7960dbec DDO |
541 | { \ |
542 | if (ctx == NULL) \ | |
543 | CMPerr(0, CMP_R_NULL_ARGUMENT); \ | |
544 | return ctx == NULL ? NULL /* cannot use ERR(NULL) here */ : ctx->FIELD;\ | |
545 | } \ | |
546 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, FIELD, \ | |
3dbc5156 DDO |
547 | OSSL_cmp_##FIELD##_t, NULL, IS_0, \ |
548 | test_##FIELD, DROP) | |
7960dbec | 549 | #define DEFINE_SET_GET_P_VOID_TEST(FIELD) \ |
235595c4 | 550 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, FIELD, void *, \ |
3dbc5156 | 551 | NULL, IS_0, ((void *)1), DROP) |
7960dbec DDO |
552 | |
553 | #define DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, DEFAULT) \ | |
554 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP##_##CTX, set, get, 0, FIELD, int, -1, \ | |
3dbc5156 | 555 | DEFAULT, 1, DROP) |
7960dbec DDO |
556 | #define DEFINE_SET_GET_INT_TEST(OSSL_CMP, CTX, FIELD) \ |
557 | DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_NEG) | |
558 | #define DEFINE_SET_PORT_TEST(FIELD) \ | |
559 | static int OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \ | |
560 | { \ | |
561 | return ctx == NULL ? ERR(-1) : ctx->FIELD; \ | |
562 | } \ | |
563 | DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_DEFAULT_PORT) | |
564 | ||
565 | #define DEFINE_SET_GET_ARG_FN(SETN, GETN, FIELD, ARG, T) \ | |
566 | static int OSSL_CMP_CTX_##SETN##_##FIELD##_##ARG(CMP_CTX *ctx, T val) \ | |
567 | { \ | |
568 | return OSSL_CMP_CTX_##SETN##_##FIELD(ctx, ARG, val); \ | |
569 | } \ | |
570 | \ | |
571 | static T OSSL_CMP_CTX_##GETN##_##FIELD##_##ARG(const CMP_CTX *ctx) \ | |
572 | { \ | |
573 | return OSSL_CMP_CTX_##GETN##_##FIELD(ctx, ARG); \ | |
574 | } | |
575 | ||
576 | #define DEFINE_SET_GET1_STR_FN(SETN, FIELD) \ | |
577 | static int OSSL_CMP_CTX_##SETN##_##FIELD##_str(CMP_CTX *ctx, char *val)\ | |
578 | { \ | |
579 | return OSSL_CMP_CTX_##SETN##_##FIELD(ctx, (unsigned char *)val, \ | |
235595c4 | 580 | strlen(val)); \ |
7960dbec DDO |
581 | } \ |
582 | \ | |
583 | static char *OSSL_CMP_CTX_get1_##FIELD##_str(const CMP_CTX *ctx) \ | |
584 | { \ | |
585 | const ASN1_OCTET_STRING *bytes = ctx == NULL ? ERR(NULL) : ctx->FIELD; \ | |
586 | \ | |
587 | return bytes == NULL ? NULL : \ | |
588 | OPENSSL_strndup((char *)bytes->data, bytes->length); \ | |
589 | } | |
590 | ||
591 | #define push 0 | |
592 | #define push0 0 | |
593 | #define push1 1 | |
594 | #define DEFINE_PUSH_BASE_TEST(PUSHN, DUP, FIELD, ELEM, TYPE, T, \ | |
3dbc5156 DDO |
595 | DEFAULT, NEW, FREE) \ |
596 | static TYPE sk_top_##FIELD(const CMP_CTX *ctx) \ | |
597 | { \ | |
7960dbec DDO |
598 | return sk_##T##_value(ctx->FIELD, sk_##T##_num(ctx->FIELD) - 1); \ |
599 | } \ | |
600 | \ | |
601 | static int execute_CTX_##PUSHN##_##ELEM(OSSL_CMP_CTX_TEST_FIXTURE *fixture) \ | |
602 | { \ | |
603 | CMP_CTX *ctx = fixture->ctx; \ | |
604 | int (*push_fn)(CMP_CTX *ctx, TYPE) = \ | |
605 | (int (*)(CMP_CTX *ctx, TYPE))OSSL_CMP_CTX_##PUSHN##_##ELEM; \ | |
3dbc5156 DDO |
606 | /* \ |
607 | * need type cast in above assignment because TYPE arg sometimes is const \ | |
608 | */ \ | |
7960dbec DDO |
609 | int n_elem = sk_##T##_num(ctx->FIELD); \ |
610 | STACK_OF(TYPE) field_read; \ | |
611 | TYPE val1_to_free = NEW; \ | |
612 | TYPE val1 = val1_to_free; \ | |
613 | TYPE val1_read = 0; /* 0 works for any type */ \ | |
614 | TYPE val2_to_free = NEW; \ | |
615 | TYPE val2 = val2_to_free; \ | |
616 | TYPE val2_read = 0; \ | |
617 | int res = 1; \ | |
618 | \ | |
619 | if (!TEST_int_eq(ERR_peek_error(), 0)) \ | |
620 | res = 0; \ | |
621 | if ((*push_fn)(NULL, val1) || ERR_peek_error() == 0) { \ | |
622 | TEST_error("pusher did not return error on ctx == NULL"); \ | |
623 | res = 0; \ | |
624 | } \ | |
625 | ERR_clear_error(); \ | |
626 | \ | |
627 | if (n_elem < 0) /* can happen for NULL stack */ \ | |
628 | n_elem = 0; \ | |
629 | field_read = ctx->FIELD; \ | |
630 | if (!DEFAULT(field_read)) { \ | |
631 | TEST_error("did not get default value for stack field"); \ | |
632 | res = 0; \ | |
633 | } \ | |
634 | if (!(*push_fn)(ctx, val1)) { \ | |
635 | TEST_error("pushing first value failed"); \ | |
636 | res = 0; \ | |
637 | } \ | |
638 | if (PUSHN == 0) \ | |
639 | val1_to_free = 0; /* 0 works for any type */ \ | |
640 | \ | |
641 | if (sk_##T##_num(ctx->FIELD) != ++n_elem) { \ | |
642 | TEST_error("pushing first value did not increment number"); \ | |
643 | res = 0; \ | |
644 | } \ | |
645 | val1_read = sk_top_##FIELD(ctx); \ | |
646 | if (PUSHN == 0) { \ | |
647 | if (val1_read != val1) { \ | |
648 | TEST_error("push/sk_top first value did not match"); \ | |
649 | res = 0; \ | |
650 | } \ | |
651 | } else { \ | |
652 | if (DUP && val1_read == val1) { \ | |
653 | TEST_error("first push did not dup the value"); \ | |
654 | res = 0; \ | |
655 | } \ | |
656 | } \ | |
657 | \ | |
658 | if (!(*push_fn)(ctx, val2)) { \ | |
659 | TEST_error("pushting second value failed"); \ | |
660 | res = 0; \ | |
661 | } \ | |
662 | if (PUSHN == 0) \ | |
663 | val2_to_free = 0; \ | |
664 | \ | |
665 | if (sk_##T##_num(ctx->FIELD) != ++n_elem) { \ | |
666 | TEST_error("pushing second value did not increment number"); \ | |
667 | res = 0; \ | |
668 | } \ | |
669 | val2_read = sk_top_##FIELD(ctx); \ | |
670 | if (PUSHN == 0) { \ | |
671 | if (val2_read != val2) { \ | |
672 | TEST_error("push/sk_top second value did not match"); \ | |
673 | res = 0; \ | |
674 | } \ | |
675 | } else { \ | |
676 | if (DUP && val2_read == val2) { \ | |
677 | TEST_error("second push did not dup the value"); \ | |
678 | res = 0; \ | |
679 | } \ | |
680 | if (val2 == val1) { \ | |
681 | TEST_error("second value is same as first value"); \ | |
682 | res = 0; \ | |
683 | } \ | |
684 | } \ | |
235595c4 | 685 | /* this does not check if all remaining fields and elems are untouched */ \ |
7960dbec DDO |
686 | \ |
687 | if (!TEST_int_eq(ERR_peek_error(), 0)) \ | |
688 | res = 0; \ | |
689 | \ | |
690 | FREE(val1_to_free); \ | |
691 | FREE(val2_to_free); \ | |
692 | return TEST_true(res); \ | |
693 | } \ | |
694 | \ | |
695 | static int test_CTX_##PUSHN##_##ELEM(void) \ | |
696 | { \ | |
697 | SETUP_TEST_FIXTURE(OSSL_CMP_CTX_TEST_FIXTURE, set_up); \ | |
698 | EXECUTE_TEST(execute_CTX_##PUSHN##_##ELEM, tear_down); \ | |
699 | return result; \ | |
700 | } \ | |
701 | ||
702 | #define DEFINE_PUSH_TEST(N, DUP, FIELD, ELEM, TYPE) \ | |
235595c4 | 703 | DEFINE_PUSH_BASE_TEST(push##N, DUP, FIELD, ELEM, TYPE *, TYPE, \ |
3dbc5156 | 704 | IS_0, TYPE##_new(), TYPE##_free) |
7960dbec DDO |
705 | |
706 | void cleanup_tests(void) | |
707 | { | |
708 | return; | |
709 | } | |
710 | ||
711 | DEFINE_SET_GET_ARG_FN(set, get, option, 16, int) | |
3dbc5156 | 712 | /* option == OSSL_CMP_OPT_IGNORE_KEYUSAGE */ |
7960dbec | 713 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, option_16, int, -1, IS_0, \ |
3dbc5156 | 714 | 1 /* true */, DROP) |
7960dbec | 715 | |
7960dbec | 716 | DEFINE_SET_CB_TEST(log_cb) |
7960dbec DDO |
717 | |
718 | DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, serverPath, char, IS_0) | |
719 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, serverName, char) | |
720 | DEFINE_SET_PORT_TEST(serverPort) | |
721 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, proxyName, char) | |
722 | DEFINE_SET_PORT_TEST(proxyPort) | |
723 | DEFINE_SET_CB_TEST(http_cb) | |
724 | DEFINE_SET_GET_P_VOID_TEST(http_cb_arg) | |
725 | DEFINE_SET_CB_TEST(transfer_cb) | |
726 | DEFINE_SET_GET_P_VOID_TEST(transfer_cb_arg) | |
727 | ||
728 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, srvCert, X509) | |
729 | DEFINE_SET_TEST(ossl_cmp, ctx, 0, 0, validatedSrvCert, X509) | |
730 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, expected_sender, X509_NAME) | |
731 | DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set0, get0, 0, trustedStore, | |
235595c4 | 732 | X509_STORE *, NULL, |
3dbc5156 | 733 | DEFAULT_STORE, X509_STORE_new_1(), X509_STORE_free) |
7960dbec DDO |
734 | DEFINE_SET_GET_SK_X509_TEST(OSSL_CMP, CTX, 1, 0, untrusted_certs) |
735 | ||
736 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, clCert, X509) | |
737 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, pkey, EVP_PKEY) | |
738 | ||
739 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, recipient, X509_NAME) | |
740 | DEFINE_PUSH_TEST(0, 0, geninfo_ITAVs, geninfo_ITAV, OSSL_CMP_ITAV) | |
741 | DEFINE_SET_SK_TEST(OSSL_CMP, CTX, 1, extraCertsOut, X509) | |
235595c4 | 742 | DEFINE_SET_GET_ARG_FN(set0, get0, newPkey, 1, EVP_PKEY *) /* priv == 1 */ |
7960dbec | 743 | DEFINE_SET_GET_TEST(OSSL_CMP, CTX, 0, 0, 0, newPkey_1, EVP_PKEY) |
235595c4 | 744 | DEFINE_SET_GET_ARG_FN(set0, get0, newPkey, 0, EVP_PKEY *) /* priv == 0 */ |
7960dbec DDO |
745 | DEFINE_SET_GET_TEST(OSSL_CMP, CTX, 0, 0, 0, newPkey_0, EVP_PKEY) |
746 | DEFINE_SET_GET1_STR_FN(set1, referenceValue) | |
3dbc5156 DDO |
747 | DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, 1, referenceValue_str, char, |
748 | IS_0) | |
7960dbec | 749 | DEFINE_SET_GET1_STR_FN(set1, secretValue) |
3dbc5156 | 750 | DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, 1, secretValue_str, char, IS_0) |
7960dbec DDO |
751 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, issuer, X509_NAME) |
752 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, subjectName, X509_NAME) | |
753 | #ifdef ISSUE_9504_RESOLVED | |
754 | DEFINE_PUSH_TEST(1, 1, subjectAltNames, subjectAltName, GENERAL_NAME) | |
755 | #endif | |
756 | DEFINE_SET_SK_TEST(OSSL_CMP, CTX, 0, reqExtensions, X509_EXTENSION) | |
757 | DEFINE_PUSH_TEST(0, 0, policies, policy, POLICYINFO) | |
758 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 0, oldCert, X509) | |
759 | #ifdef ISSUE_9504_RESOLVED | |
760 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, p10CSR, X509_REQ) | |
761 | #endif | |
762 | DEFINE_PUSH_TEST(0, 0, genm_ITAVs, genm_ITAV, OSSL_CMP_ITAV) | |
763 | DEFINE_SET_CB_TEST(certConf_cb) | |
764 | DEFINE_SET_GET_P_VOID_TEST(certConf_cb_arg) | |
765 | ||
766 | DEFINE_SET_GET_INT_TEST(ossl_cmp, ctx, status) | |
767 | DEFINE_SET_GET_SK_TEST(ossl_cmp, ctx, 0, 0, statusString, ASN1_UTF8STRING) | |
768 | DEFINE_SET_GET_INT_TEST(ossl_cmp, ctx, failInfoCode) | |
769 | DEFINE_SET_GET_TEST(ossl_cmp, ctx, 0, 0, 0, newCert, X509) | |
770 | DEFINE_SET_GET_SK_X509_TEST(ossl_cmp, ctx, 1, 1, caPubs) | |
771 | DEFINE_SET_GET_SK_X509_TEST(ossl_cmp, ctx, 1, 1, extraCertsIn) | |
772 | ||
3dbc5156 DDO |
773 | DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, transactionID, ASN1_OCTET_STRING, |
774 | IS_0) | |
7960dbec DDO |
775 | DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, senderNonce, ASN1_OCTET_STRING) |
776 | DEFINE_SET_TEST(ossl_cmp, ctx, 1, 1, recipNonce, ASN1_OCTET_STRING) | |
777 | ||
778 | int setup_tests(void) | |
779 | { | |
780 | /* OSSL_CMP_CTX_new() is tested by set_up() */ | |
781 | /* OSSL_CMP_CTX_free() is tested by tear_down() */ | |
782 | ADD_TEST(test_CTX_reinit); | |
783 | ||
3dbc5156 | 784 | /* various CMP options: */ |
7960dbec | 785 | ADD_TEST(test_CTX_set_get_option_16); |
3dbc5156 | 786 | /* CMP-specific callback for logging and outputting the error queue: */ |
7960dbec | 787 | ADD_TEST(test_CTX_set_get_log_cb); |
7960dbec DDO |
788 | /* |
789 | * also tests OSSL_CMP_log_open(), OSSL_CMP_CTX_set_log_verbosity(), | |
ebf30069 DDO |
790 | * ossl_cmp_err(), ossl_cmp_warn(), * ossl_cmp_debug(), |
791 | * ossl_cmp_log2(), ossl_cmp_log_parse_metadata(), and OSSL_CMP_log_close() | |
7960dbec DDO |
792 | * with OSSL_CMP_severity OSSL_CMP_LOG_ERR/WARNING/DEBUG/INFO: |
793 | */ | |
794 | ADD_TEST(test_cmp_ctx_log_cb); | |
8e1a1582 | 795 | #if !defined(OPENSSL_NO_ERR) && !defined(OPENSSL_NO_AUTOERRINIT) |
3dbc5156 DDO |
796 | /* |
797 | * also tests OSSL_CMP_CTX_set_log_cb(), OSSL_CMP_print_errors_cb(), | |
31b28ad9 | 798 | * and the macros ossl_cmp_add_error_data and ossl_cmp_add_error_line: |
3dbc5156 | 799 | */ |
7960dbec | 800 | ADD_TEST(test_CTX_print_errors); |
85870311 | 801 | #endif |
3dbc5156 | 802 | /* message transfer: */ |
7960dbec DDO |
803 | ADD_TEST(test_CTX_set1_get0_serverPath); |
804 | ADD_TEST(test_CTX_set1_get0_serverName); | |
805 | ADD_TEST(test_CTX_set_get_serverPort); | |
806 | ADD_TEST(test_CTX_set1_get0_proxyName); | |
807 | ADD_TEST(test_CTX_set_get_proxyPort); | |
808 | ADD_TEST(test_CTX_set_get_http_cb); | |
809 | ADD_TEST(test_CTX_set_get_http_cb_arg); | |
810 | ADD_TEST(test_CTX_set_get_transfer_cb); | |
811 | ADD_TEST(test_CTX_set_get_transfer_cb_arg); | |
3dbc5156 | 812 | /* server authentication: */ |
7960dbec DDO |
813 | ADD_TEST(test_CTX_set1_get0_srvCert); |
814 | ADD_TEST(test_CTX_set0_get0_validatedSrvCert); | |
815 | ADD_TEST(test_CTX_set1_get0_expected_sender); | |
816 | ADD_TEST(test_CTX_set0_get0_trustedStore); | |
817 | ADD_TEST(test_CTX_set1_get0_untrusted_certs); | |
3dbc5156 | 818 | /* client authentication: */ |
7960dbec DDO |
819 | ADD_TEST(test_CTX_set1_get0_clCert); |
820 | ADD_TEST(test_CTX_set1_get0_pkey); | |
821 | /* the following two also test ossl_cmp_asn1_octet_string_set1_bytes(): */ | |
822 | ADD_TEST(test_CTX_set1_get1_referenceValue_str); | |
823 | ADD_TEST(test_CTX_set1_get1_secretValue_str); | |
3dbc5156 | 824 | /* CMP message header and extra certificates: */ |
7960dbec DDO |
825 | ADD_TEST(test_CTX_set1_get0_recipient); |
826 | ADD_TEST(test_CTX_push0_geninfo_ITAV); | |
827 | ADD_TEST(test_CTX_set1_get0_extraCertsOut); | |
3dbc5156 | 828 | /* certificate template: */ |
7960dbec DDO |
829 | ADD_TEST(test_CTX_set0_get0_newPkey_1); |
830 | ADD_TEST(test_CTX_set0_get0_newPkey_0); | |
831 | ADD_TEST(test_CTX_set1_get0_issuer); | |
832 | ADD_TEST(test_CTX_set1_get0_subjectName); | |
833 | #ifdef ISSUE_9504_RESOLVED | |
3dbc5156 DDO |
834 | /* |
835 | * test currently fails, see https://github.com/openssl/openssl/issues/9504 | |
836 | */ | |
7960dbec DDO |
837 | ADD_TEST(test_CTX_push1_subjectAltName); |
838 | #endif | |
839 | ADD_TEST(test_CTX_set0_get0_reqExtensions); | |
840 | ADD_TEST(test_CTX_reqExtensions_have_SAN); | |
841 | ADD_TEST(test_CTX_push0_policy); | |
842 | ADD_TEST(test_CTX_set1_get0_oldCert); | |
843 | #ifdef ISSUE_9504_RESOLVED | |
3dbc5156 DDO |
844 | /* |
845 | * test currently fails, see https://github.com/openssl/openssl/issues/9504 | |
846 | */ | |
7960dbec DDO |
847 | ADD_TEST(test_CTX_set1_get0_p10CSR); |
848 | #endif | |
3dbc5156 | 849 | /* misc body contents: */ |
7960dbec | 850 | ADD_TEST(test_CTX_push0_genm_ITAV); |
3dbc5156 | 851 | /* certificate confirmation: */ |
7960dbec DDO |
852 | ADD_TEST(test_CTX_set_get_certConf_cb); |
853 | ADD_TEST(test_CTX_set_get_certConf_cb_arg); | |
3dbc5156 | 854 | /* result fetching: */ |
7960dbec DDO |
855 | ADD_TEST(test_CTX_set_get_status); |
856 | ADD_TEST(test_CTX_set0_get0_statusString); | |
857 | ADD_TEST(test_CTX_set_get_failInfoCode); | |
858 | ADD_TEST(test_CTX_set0_get0_newCert); | |
859 | ADD_TEST(test_CTX_set1_get1_caPubs); | |
860 | ADD_TEST(test_CTX_set1_get1_extraCertsIn); | |
3dbc5156 | 861 | /* exported for testing and debugging purposes: */ |
7960dbec DDO |
862 | /* the following three also test ossl_cmp_asn1_octet_string_set1(): */ |
863 | ADD_TEST(test_CTX_set1_get0_transactionID); | |
864 | ADD_TEST(test_CTX_set1_get0_senderNonce); | |
865 | ADD_TEST(test_CTX_set1_get0_recipNonce); | |
3dbc5156 | 866 | /* ossl_cmp_build_cert_chain() is tested in cmp_protect.c */ |
7960dbec DDO |
867 | return 1; |
868 | } |