Home | History | Annotate | Download | only in test

Lines Matching refs:fixture

39 static void tear_down(CMP_PROTECT_TEST_FIXTURE *fixture)
41 if (fixture != NULL) {
42 OSSL_CMP_CTX_free(fixture->cmp_ctx);
43 OSSL_CMP_MSG_free(fixture->msg);
44 OSSL_CMP_PKISI_free(fixture->si);
46 OPENSSL_free(fixture->mem);
47 sk_X509_free(fixture->certs);
48 sk_X509_free(fixture->chain);
50 OPENSSL_free(fixture);
56 CMP_PROTECT_TEST_FIXTURE *fixture;
58 if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
60 fixture->test_case_name = test_case_name;
61 if (!TEST_ptr(fixture->cmp_ctx = OSSL_CMP_CTX_new(libctx, NULL))) {
62 tear_down(fixture);
65 return fixture;
80 static int execute_calc_protection_fails_test(CMP_PROTECT_TEST_FIXTURE *fixture)
82 ASN1_BIT_STRING *protection = ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg);
89 static int execute_calc_protection_pbmac_test(CMP_PROTECT_TEST_FIXTURE *fixture)
91 ASN1_BIT_STRING *protection = ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg);
94 fixture->msg->protection)
121 fixture)
123 ASN1_BIT_STRING *protection = ossl_cmp_calc_protection(fixture->cmp_ctx, fixture->msg);
125 && TEST_true(verify_signature(fixture->msg, protection,
126 fixture->pubkey,
127 fixture->cmp_ctx->digest)));
136 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_unprotected_f, libctx))
137 || !TEST_ptr(fixture->msg->header->protectionAlg = X509_ALGOR_new() /* no specific alg needed here */)) {
138 tear_down(fixture);
139 fixture = NULL;
149 fixture->pubkey = prot_RSA_key;
150 if (!TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, prot_RSA_key))
151 || !TEST_ptr(fixture->msg = load_pkimsg(ir_protected_f, libctx))) {
152 tear_down(fixture);
153 fixture = NULL;
163 fixture->pubkey = prot_Ed_key;
164 if (!TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, prot_Ed_key))
165 || !TEST_ptr(fixture->msg = load_pkimsg(genm_prot_Ed_f, libctx))) {
166 tear_down(fixture);
167 fixture = NULL;
179 if (!TEST_true(OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx,
181 || !TEST_ptr(fixture->msg = load_pkimsg(ip_PBM_f, libctx))) {
182 tear_down(fixture);
183 fixture = NULL;
188 static int execute_MSG_protect_test(CMP_PROTECT_TEST_FIXTURE *fixture)
190 return TEST_int_eq(fixture->expected,
191 ossl_cmp_msg_protect(fixture->cmp_ctx, fixture->msg));
200 fixture->expected = 1;
201 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
202 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 1))) {
203 tear_down(fixture);
204 fixture = NULL;
215 fixture->expected = 1;
217 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
218 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))
223 || !TEST_true(OSSL_CMP_CTX_set1_referenceValue(fixture->cmp_ctx,
225 || !TEST_true(OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx,
228 tear_down(fixture);
229 fixture = NULL;
238 fixture->expected = 1;
240 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
241 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))
242 || !TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, server_key))
243 || !TEST_true(OSSL_CMP_CTX_set1_cert(fixture->cmp_ctx,
245 tear_down(fixture);
246 fixture = NULL;
257 ctx = fixture->cmp_ctx;
258 fixture->expected = 0;
259 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
263 tear_down(fixture);
264 fixture = NULL;
273 fixture->expected = 0;
274 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
275 || !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))) {
276 tear_down(fixture);
277 fixture = NULL;
289 fixture->expected = with_ref;
290 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
291 || !SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0)
292 || !ossl_cmp_hdr_set1_sender(fixture->msg->header, NULL)
293 || !OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx,
295 || (!OSSL_CMP_CTX_set1_referenceValue(fixture->cmp_ctx,
298 tear_down(fixture);
299 fixture = NULL;
315 static int execute_MSG_add_extraCerts_test(CMP_PROTECT_TEST_FIXTURE *fixture)
317 return TEST_true(ossl_cmp_msg_add_extraCerts(fixture->cmp_ctx,
318 fixture->msg));
324 if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_protected))) {
325 tear_down(fixture);
326 fixture = NULL;
334 static int execute_cmp_build_cert_chain_test(CMP_PROTECT_TEST_FIXTURE *fixture)
337 OSSL_CMP_CTX *ctx = fixture->cmp_ctx;
339 STACK_OF(X509) *chain = X509_build_chain(fixture->cert, fixture->certs, NULL,
340 fixture->with_ss, ctx->libctx, ctx->propq);
344 ret = TEST_int_eq(0, STACK_OF_X509_cmp(chain, fixture->chain));
354 chain = X509_build_chain(fixture->cert, fixture->certs, store,
355 fixture->with_ss, ctx->libctx, ctx->propq);
356 ret = TEST_int_eq(fixture->expected, chain != NULL);
359 ret = TEST_int_eq(0, STACK_OF_X509_cmp(chain, fixture->chain));
370 fixture->expected = 1;
371 fixture->with_ss = 0;
372 fixture->cert = endentity2;
373 if (!TEST_ptr(fixture->certs = sk_X509_new_null())
374 || !TEST_ptr(fixture->chain = sk_X509_new_null())
375 || !TEST_true(sk_X509_push(fixture->certs, endentity1))
376 || !TEST_true(sk_X509_push(fixture->certs, root))
377 || !TEST_true(sk_X509_push(fixture->certs, intermediate))
378 || !TEST_true(sk_X509_push(fixture->chain, endentity2))
379 || !TEST_true(sk_X509_push(fixture->chain, intermediate))) {
380 tear_down(fixture);
381 fixture = NULL;
383 if (fixture != NULL) {
384 result = execute_cmp_build_cert_chain_test(fixture);
385 fixture->with_ss = 1;
386 if (result && TEST_true(sk_X509_push(fixture->chain, root)))
387 result = execute_cmp_build_cert_chain_test(fixture);
389 tear_down(fixture);
396 fixture->expected = 0;
397 fixture->with_ss = 0;
398 fixture->cert = endentity2;
399 if (!TEST_ptr(fixture->certs = sk_X509_new_null())
400 || !TEST_ptr(fixture->chain = sk_X509_new_null())
401 || !TEST_true(sk_X509_push(fixture->certs, endentity1))
402 || !TEST_true(sk_X509_push(fixture->certs, root))
403 || !TEST_true(sk_X509_push(fixture->chain, endentity2))) {
404 tear_down(fixture);
405 fixture = NULL;
414 fixture->expected = 1;
415 fixture->with_ss = 0;
416 fixture->cert = endentity2;
417 if (!TEST_ptr(fixture->certs = sk_X509_new_null())
418 || !TEST_ptr(fixture->chain = sk_X509_new_null())
419 || !TEST_true(sk_X509_push(fixture->certs, endentity1))
420 || !TEST_true(sk_X509_push(fixture->certs, intermediate))
421 || !TEST_true(sk_X509_push(fixture->chain, endentity2))
422 || !TEST_true(sk_X509_push(fixture->chain, intermediate))) {
423 tear_down(fixture);
424 fixture = NULL;
433 fixture->expected = 1;
434 fixture->with_ss = 0; /* still chain must include the only cert (root) */
435 fixture->cert = root;
436 if (!TEST_ptr(fixture->certs = sk_X509_new_null())
437 || !TEST_ptr(fixture->chain = sk_X509_new_null())
438 || !TEST_true(sk_X509_push(fixture->certs, root))
439 || !TEST_true(sk_X509_push(fixture->chain, root))) {
440 tear_down(fixture);
441 fixture = NULL;
450 fixture->expected = 0;
451 fixture->with_ss = 0;
452 fixture->cert = endentity2;
453 if (!TEST_ptr(fixture->certs = sk_X509_new_null())
454 || !TEST_ptr(fixture->chain = sk_X509_new_null())
455 || !TEST_true(sk_X509_push(fixture->chain, endentity2))) {
456 tear_down(fixture);
457 fixture = NULL;
464 static int execute_X509_STORE_test(CMP_PROTECT_TEST_FIXTURE *fixture)
471 fixture->certs,
472 fixture->callback_arg)))
475 if (!TEST_int_eq(0, STACK_OF_X509_cmp(sk, fixture->chain)))
487 fixture->callback_arg = 0; /* self-issued allowed */
488 if (!TEST_ptr(fixture->certs = sk_X509_new_null())
489 || !sk_X509_push(fixture->certs, endentity1)
490 || !sk_X509_push(fixture->certs, endentity2)
491 || !sk_X509_push(fixture->certs, root)
492 || !sk_X509_push(fixture->certs, intermediate)
493 || !TEST_ptr(fixturefixture->certs))) {
494 tear_down(fixture);
495 fixture = NULL;
504 fixture->certs = sk_X509_new_null();
505 fixture->chain = sk_X509_new_null();
506 fixture->callback_arg = 1; /* only self-issued */
507 if (!TEST_true(sk_X509_push(fixture->certs, endentity1))
508 || !TEST_true(sk_X509_push(fixture->certs, endentity2))
509 || !TEST_true(sk_X509_push(fixture->certs, root))
510 || !TEST_true(sk_X509_push(fixture->certs, intermediate))
511 || !TEST_true(sk_X509_push(fixture->chain, root))) {
512 tear_down(fixture);
513 fixture = NULL;