• Home
  • Raw
  • Download

Lines Matching refs:fixture

38 static void tear_down(CMP_PROTECT_TEST_FIXTURE *fixture)  in tear_down()  argument
40 OSSL_CMP_CTX_free(fixture->cmp_ctx); in tear_down()
41 OSSL_CMP_MSG_free(fixture->msg); in tear_down()
42 OSSL_CMP_PKISI_free(fixture->si); in tear_down()
44 OPENSSL_free(fixture->mem); in tear_down()
45 sk_X509_free(fixture->certs); in tear_down()
46 sk_X509_free(fixture->chain); in tear_down()
48 OPENSSL_free(fixture); in tear_down()
53 CMP_PROTECT_TEST_FIXTURE *fixture; in set_up() local
55 if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))) in set_up()
57 fixture->test_case_name = test_case_name; in set_up()
58 if (!TEST_ptr(fixture->cmp_ctx = OSSL_CMP_CTX_new(libctx, NULL))) { in set_up()
59 tear_down(fixture); in set_up()
62 return fixture; in set_up()
74 static int execute_calc_protection_fails_test(CMP_PROTECT_TEST_FIXTURE *fixture) in execute_calc_protection_fails_test() argument
77 ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg); in execute_calc_protection_fails_test()
84 static int execute_calc_protection_pbmac_test(CMP_PROTECT_TEST_FIXTURE *fixture) in execute_calc_protection_pbmac_test() argument
87 ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg); in execute_calc_protection_pbmac_test()
90 fixture->msg->protection) == 0); in execute_calc_protection_pbmac_test()
128 fixture) in execute_calc_protection_signature_test() argument
131 ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg); in execute_calc_protection_signature_test()
134 fixture->msg->protection) == 0) in execute_calc_protection_signature_test()
135 && TEST_true(verify_signature(fixture->msg, protection, in execute_calc_protection_signature_test()
136 fixture->pubkey, in execute_calc_protection_signature_test()
137 fixture->cmp_ctx->digest))); in execute_calc_protection_signature_test()
146 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_unprotected_f, libctx)) in test_cmp_calc_protection_no_key_no_secret()
147 || !TEST_ptr(fixture->msg->header->protectionAlg = in test_cmp_calc_protection_no_key_no_secret()
149 tear_down(fixture); in test_cmp_calc_protection_no_key_no_secret()
150 fixture = NULL; in test_cmp_calc_protection_no_key_no_secret()
160 fixture->pubkey = loadedpubkey; in test_cmp_calc_protection_pkey()
161 if (!TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, loadedprivkey)) in test_cmp_calc_protection_pkey()
162 || !TEST_ptr(fixture->msg = load_pkimsg(ir_protected_f, libctx))) { in test_cmp_calc_protection_pkey()
163 tear_down(fixture); in test_cmp_calc_protection_pkey()
164 fixture = NULL; in test_cmp_calc_protection_pkey()
175 if (!TEST_true(OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx, in test_cmp_calc_protection_pbmac()
177 || !TEST_ptr(fixture->msg = load_pkimsg(ip_PBM_f, libctx))) { in test_cmp_calc_protection_pbmac()
178 tear_down(fixture); in test_cmp_calc_protection_pbmac()
179 fixture = NULL; in test_cmp_calc_protection_pbmac()
184 static int execute_MSG_protect_test(CMP_PROTECT_TEST_FIXTURE *fixture) in execute_MSG_protect_test() argument
186 return TEST_int_eq(fixture->expected, in execute_MSG_protect_test()
187 ossl_cmp_msg_protect(fixture->cmp_ctx, fixture->msg)); in execute_MSG_protect_test()
196 fixture->expected = 1; in test_MSG_protect_unprotected_request()
197 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected)) in test_MSG_protect_unprotected_request()
198 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 1))) { in test_MSG_protect_unprotected_request()
199 tear_down(fixture); in test_MSG_protect_unprotected_request()
200 fixture = NULL; in test_MSG_protect_unprotected_request()
211 fixture->expected = 1; in test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key()
213 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected)) in test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key()
214 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0)) in test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key()
219 || !TEST_true(OSSL_CMP_CTX_set1_referenceValue(fixture->cmp_ctx, in test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key()
221 || !TEST_true(OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx, in test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key()
224 tear_down(fixture); in test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key()
225 fixture = NULL; in test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key()
234 fixture->expected = 1; in test_MSG_protect_with_certificate_and_key()
236 if (!TEST_ptr(fixture->msg = in test_MSG_protect_with_certificate_and_key()
238 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0)) in test_MSG_protect_with_certificate_and_key()
239 || !TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, loadedkey)) in test_MSG_protect_with_certificate_and_key()
240 || !TEST_true(OSSL_CMP_CTX_set1_cert(fixture->cmp_ctx, cert))) { in test_MSG_protect_with_certificate_and_key()
241 tear_down(fixture); in test_MSG_protect_with_certificate_and_key()
242 fixture = NULL; in test_MSG_protect_with_certificate_and_key()
253 ctx = fixture->cmp_ctx; in test_MSG_protect_certificate_based_without_cert()
254 fixture->expected = 0; in test_MSG_protect_certificate_based_without_cert()
255 if (!TEST_ptr(fixture->msg = in test_MSG_protect_certificate_based_without_cert()
259 tear_down(fixture); in test_MSG_protect_certificate_based_without_cert()
260 fixture = NULL; in test_MSG_protect_certificate_based_without_cert()
270 fixture->expected = 0; in test_MSG_protect_no_key_no_secret()
271 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected)) in test_MSG_protect_no_key_no_secret()
272 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))) { in test_MSG_protect_no_key_no_secret()
273 tear_down(fixture); in test_MSG_protect_no_key_no_secret()
274 fixture = NULL; in test_MSG_protect_no_key_no_secret()
286 fixture->expected = with_ref; in test_MSG_protect_pbmac_no_sender()
287 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected)) in test_MSG_protect_pbmac_no_sender()
288 || !SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0) in test_MSG_protect_pbmac_no_sender()
289 || !ossl_cmp_hdr_set1_sender(fixture->msg->header, NULL) in test_MSG_protect_pbmac_no_sender()
290 || !OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx, in test_MSG_protect_pbmac_no_sender()
292 || (!OSSL_CMP_CTX_set1_referenceValue(fixture->cmp_ctx, in test_MSG_protect_pbmac_no_sender()
295 tear_down(fixture); in test_MSG_protect_pbmac_no_sender()
296 fixture = NULL; in test_MSG_protect_pbmac_no_sender()
312 static int execute_MSG_add_extraCerts_test(CMP_PROTECT_TEST_FIXTURE *fixture) in execute_MSG_add_extraCerts_test() argument
314 return TEST_true(ossl_cmp_msg_add_extraCerts(fixture->cmp_ctx, in execute_MSG_add_extraCerts_test()
315 fixture->msg)); in execute_MSG_add_extraCerts_test()
321 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_protected))) { in test_MSG_add_extraCerts()
322 tear_down(fixture); in test_MSG_add_extraCerts()
323 fixture = NULL; in test_MSG_add_extraCerts()
331 static int execute_cmp_build_cert_chain_test(CMP_PROTECT_TEST_FIXTURE *fixture) in execute_cmp_build_cert_chain_test() argument
334 OSSL_CMP_CTX *ctx = fixture->cmp_ctx; in execute_cmp_build_cert_chain_test()
337 X509_build_chain(fixture->cert, fixture->certs, NULL, in execute_cmp_build_cert_chain_test()
338 fixture->with_ss, ctx->libctx, ctx->propq); in execute_cmp_build_cert_chain_test()
342 ret = TEST_int_eq(0, STACK_OF_X509_cmp(chain, fixture->chain)); in execute_cmp_build_cert_chain_test()
352 chain = X509_build_chain(fixture->cert, fixture->certs, store, in execute_cmp_build_cert_chain_test()
353 fixture->with_ss, ctx->libctx, ctx->propq); in execute_cmp_build_cert_chain_test()
354 ret = TEST_int_eq(fixture->expected, chain != NULL); in execute_cmp_build_cert_chain_test()
357 ret = TEST_int_eq(0, STACK_OF_X509_cmp(chain, fixture->chain)); in execute_cmp_build_cert_chain_test()
368 fixture->expected = 1; in test_cmp_build_cert_chain()
369 fixture->with_ss = 0; in test_cmp_build_cert_chain()
370 fixture->cert = endentity2; in test_cmp_build_cert_chain()
371 if (!TEST_ptr(fixture->certs = sk_X509_new_null()) in test_cmp_build_cert_chain()
372 || !TEST_ptr(fixture->chain = sk_X509_new_null()) in test_cmp_build_cert_chain()
373 || !TEST_true(sk_X509_push(fixture->certs, endentity1)) in test_cmp_build_cert_chain()
374 || !TEST_true(sk_X509_push(fixture->certs, root)) in test_cmp_build_cert_chain()
375 || !TEST_true(sk_X509_push(fixture->certs, intermediate)) in test_cmp_build_cert_chain()
376 || !TEST_true(sk_X509_push(fixture->chain, endentity2)) in test_cmp_build_cert_chain()
377 || !TEST_true(sk_X509_push(fixture->chain, intermediate))) { in test_cmp_build_cert_chain()
378 tear_down(fixture); in test_cmp_build_cert_chain()
379 fixture = NULL; in test_cmp_build_cert_chain()
381 if (fixture != NULL) { in test_cmp_build_cert_chain()
382 result = execute_cmp_build_cert_chain_test(fixture); in test_cmp_build_cert_chain()
383 fixture->with_ss = 1; in test_cmp_build_cert_chain()
384 if (result && TEST_true(sk_X509_push(fixture->chain, root))) in test_cmp_build_cert_chain()
385 result = execute_cmp_build_cert_chain_test(fixture); in test_cmp_build_cert_chain()
387 tear_down(fixture); in test_cmp_build_cert_chain()
394 fixture->expected = 0; in test_cmp_build_cert_chain_missing_intermediate()
395 fixture->with_ss = 0; in test_cmp_build_cert_chain_missing_intermediate()
396 fixture->cert = endentity2; in test_cmp_build_cert_chain_missing_intermediate()
397 if (!TEST_ptr(fixture->certs = sk_X509_new_null()) in test_cmp_build_cert_chain_missing_intermediate()
398 || !TEST_ptr(fixture->chain = sk_X509_new_null()) in test_cmp_build_cert_chain_missing_intermediate()
399 || !TEST_true(sk_X509_push(fixture->certs, endentity1)) in test_cmp_build_cert_chain_missing_intermediate()
400 || !TEST_true(sk_X509_push(fixture->certs, root)) in test_cmp_build_cert_chain_missing_intermediate()
401 || !TEST_true(sk_X509_push(fixture->chain, endentity2))) { in test_cmp_build_cert_chain_missing_intermediate()
402 tear_down(fixture); in test_cmp_build_cert_chain_missing_intermediate()
403 fixture = NULL; in test_cmp_build_cert_chain_missing_intermediate()
412 fixture->expected = 1; in test_cmp_build_cert_chain_no_root()
413 fixture->with_ss = 0; in test_cmp_build_cert_chain_no_root()
414 fixture->cert = endentity2; in test_cmp_build_cert_chain_no_root()
415 if (!TEST_ptr(fixture->certs = sk_X509_new_null()) in test_cmp_build_cert_chain_no_root()
416 || !TEST_ptr(fixture->chain = sk_X509_new_null()) in test_cmp_build_cert_chain_no_root()
417 || !TEST_true(sk_X509_push(fixture->certs, endentity1)) in test_cmp_build_cert_chain_no_root()
418 || !TEST_true(sk_X509_push(fixture->certs, intermediate)) in test_cmp_build_cert_chain_no_root()
419 || !TEST_true(sk_X509_push(fixture->chain, endentity2)) in test_cmp_build_cert_chain_no_root()
420 || !TEST_true(sk_X509_push(fixture->chain, intermediate))) { in test_cmp_build_cert_chain_no_root()
421 tear_down(fixture); in test_cmp_build_cert_chain_no_root()
422 fixture = NULL; in test_cmp_build_cert_chain_no_root()
431 fixture->expected = 1; in test_cmp_build_cert_chain_only_root()
432 fixture->with_ss = 0; /* still chain must include the only cert (root) */ in test_cmp_build_cert_chain_only_root()
433 fixture->cert = root; in test_cmp_build_cert_chain_only_root()
434 if (!TEST_ptr(fixture->certs = sk_X509_new_null()) in test_cmp_build_cert_chain_only_root()
435 || !TEST_ptr(fixture->chain = sk_X509_new_null()) in test_cmp_build_cert_chain_only_root()
436 || !TEST_true(sk_X509_push(fixture->certs, root)) in test_cmp_build_cert_chain_only_root()
437 || !TEST_true(sk_X509_push(fixture->chain, root))) { in test_cmp_build_cert_chain_only_root()
438 tear_down(fixture); in test_cmp_build_cert_chain_only_root()
439 fixture = NULL; in test_cmp_build_cert_chain_only_root()
448 fixture->expected = 0; in test_cmp_build_cert_chain_no_certs()
449 fixture->with_ss = 0; in test_cmp_build_cert_chain_no_certs()
450 fixture->cert = endentity2; in test_cmp_build_cert_chain_no_certs()
451 if (!TEST_ptr(fixture->certs = sk_X509_new_null()) in test_cmp_build_cert_chain_no_certs()
452 || !TEST_ptr(fixture->chain = sk_X509_new_null()) in test_cmp_build_cert_chain_no_certs()
453 || !TEST_true(sk_X509_push(fixture->chain, endentity2))) { in test_cmp_build_cert_chain_no_certs()
454 tear_down(fixture); in test_cmp_build_cert_chain_no_certs()
455 fixture = NULL; in test_cmp_build_cert_chain_no_certs()
462 static int execute_X509_STORE_test(CMP_PROTECT_TEST_FIXTURE *fixture) in execute_X509_STORE_test() argument
469 fixture->certs, in execute_X509_STORE_test()
470 fixture->callback_arg))) in execute_X509_STORE_test()
473 if (!TEST_int_eq(0, STACK_OF_X509_cmp(sk, fixture->chain))) in execute_X509_STORE_test()
486 fixture->callback_arg = 0; /* self-issued allowed */ in test_X509_STORE()
487 if (!TEST_ptr(fixture->certs = sk_X509_new_null()) in test_X509_STORE()
488 || !sk_X509_push(fixture->certs, endentity1) in test_X509_STORE()
489 || !sk_X509_push(fixture->certs, endentity2) in test_X509_STORE()
490 || !sk_X509_push(fixture->certs, root) in test_X509_STORE()
491 || !sk_X509_push(fixture->certs, intermediate) in test_X509_STORE()
492 || !TEST_ptr(fixture->chain = sk_X509_dup(fixture->certs))) { in test_X509_STORE()
493 tear_down(fixture); in test_X509_STORE()
494 fixture = NULL; in test_X509_STORE()
503 fixture->certs = sk_X509_new_null(); in test_X509_STORE_only_self_issued()
504 fixture->chain = sk_X509_new_null(); in test_X509_STORE_only_self_issued()
505 fixture->callback_arg = 1; /* only self-issued */ in test_X509_STORE_only_self_issued()
506 if (!TEST_true(sk_X509_push(fixture->certs, endentity1)) in test_X509_STORE_only_self_issued()
507 || !TEST_true(sk_X509_push(fixture->certs, endentity2)) in test_X509_STORE_only_self_issued()
508 || !TEST_true(sk_X509_push(fixture->certs, root)) in test_X509_STORE_only_self_issued()
509 || !TEST_true(sk_X509_push(fixture->certs, intermediate)) in test_X509_STORE_only_self_issued()
510 || !TEST_true(sk_X509_push(fixture->chain, root))) { in test_X509_STORE_only_self_issued()
511 tear_down(fixture); in test_X509_STORE_only_self_issued()
512 fixture = NULL; in test_X509_STORE_only_self_issued()