diff options
author | beck <> | 2023-04-28 09:02:04 +0000 |
---|---|---|
committer | beck <> | 2023-04-28 09:02:04 +0000 |
commit | aa9e472d9d72843ea797751bd80410137bf694ff (patch) | |
tree | 4fa8e0490130f093beec907baf0aa4745ece9148 /src/regress/lib | |
parent | ea474aeeb62acfb8478e77decfbe0e24b92352b8 (diff) | |
download | openbsd-aa9e472d9d72843ea797751bd80410137bf694ff.tar.gz openbsd-aa9e472d9d72843ea797751bd80410137bf694ff.tar.bz2 openbsd-aa9e472d9d72843ea797751bd80410137bf694ff.zip |
Fix copyright, convert boringssl comments to C style
Diffstat (limited to 'src/regress/lib')
-rw-r--r-- | src/regress/lib/libcrypto/x509/policy/policy.c | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/src/regress/lib/libcrypto/x509/policy/policy.c b/src/regress/lib/libcrypto/x509/policy/policy.c index 5524be2b05..bffc982f8a 100644 --- a/src/regress/lib/libcrypto/x509/policy/policy.c +++ b/src/regress/lib/libcrypto/x509/policy/policy.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* $OpenBSD: policy.c,v 1.7 2023/04/28 08:53:20 beck Exp $ */ | 1 | /* $OpenBSD: policy.c,v 1.8 2023/04/28 09:02:04 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2020-2021 Bob Beck <beck@openbsd.org> | 4 | * Copyright (c) 2020-2023 Bob Beck <beck@openbsd.org> |
5 | * | 5 | * |
6 | * Permission to use, copy, modify, and distribute this software for any | 6 | * Permission to use, copy, modify, and distribute this software for any |
7 | * purpose with or without fee is hereby granted, provided that the above | 7 | * purpose with or without fee is hereby granted, provided that the above |
@@ -212,8 +212,13 @@ struct verify_cert_test { | |||
212 | }; | 212 | }; |
213 | 213 | ||
214 | struct verify_cert_test verify_cert_tests[] = { | 214 | struct verify_cert_test verify_cert_tests[] = { |
215 | // Comments here are from boringssl/crypto/x509/x509_test.cc | 215 | /* |
216 | // The chain is good for |oid1| and |oid2|, but not |oid3|. | 216 | * Comments here are from boringssl/crypto/x509/x509_test.cc |
217 | * certs were generated by | ||
218 | * boringssl/crypto/x509/test/make_policy_certs.go | ||
219 | */ | ||
220 | |||
221 | /* The chain is good for |oid1| and |oid2|, but not |oid3|. */ | ||
217 | { | 222 | { |
218 | .id = "nothing in 1 and 2", | 223 | .id = "nothing in 1 and 2", |
219 | .root_file = CERTSDIR "/" "policy_root.pem", | 224 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -272,7 +277,7 @@ struct verify_cert_test verify_cert_tests[] = { | |||
272 | .policy_oid_to_check2 = OID3, | 277 | .policy_oid_to_check2 = OID3, |
273 | .want_chains = 1, | 278 | .want_chains = 1, |
274 | }, | 279 | }, |
275 | // The policy extension cannot be parsed. | 280 | /* The policy extension cannot be parsed. */ |
276 | { | 281 | { |
277 | .id = "1 in invalid intermediate poicy", | 282 | .id = "1 in invalid intermediate poicy", |
278 | .root_file = CERTSDIR "/" "policy_root.pem", | 283 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -323,7 +328,7 @@ struct verify_cert_test verify_cert_tests[] = { | |||
323 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, | 328 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, |
324 | .want_legacy_error_depth = 0, | 329 | .want_legacy_error_depth = 0, |
325 | }, | 330 | }, |
326 | // There is a duplicate policy in the leaf policy extension. | 331 | /* There is a duplicate policy in the leaf policy extension. */ |
327 | { | 332 | { |
328 | .id = "1 in duplicate policy extension in leaf", | 333 | .id = "1 in duplicate policy extension in leaf", |
329 | .root_file = CERTSDIR "/" "policy_root.pem", | 334 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -337,7 +342,7 @@ struct verify_cert_test verify_cert_tests[] = { | |||
337 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, | 342 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, |
338 | .want_legacy_error_depth = 0, | 343 | .want_legacy_error_depth = 0, |
339 | }, | 344 | }, |
340 | // There is a duplicate policy in the intermediate policy extension. | 345 | /* There is a duplicate policy in the intermediate policy extension. */ |
341 | { | 346 | { |
342 | .id = "1 in duplicate policy extension in intermediate", | 347 | .id = "1 in duplicate policy extension in intermediate", |
343 | .root_file = CERTSDIR "/" "policy_root.pem", | 348 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -351,9 +356,11 @@ struct verify_cert_test verify_cert_tests[] = { | |||
351 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, | 356 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, |
352 | .want_legacy_error_depth = 0, | 357 | .want_legacy_error_depth = 0, |
353 | }, | 358 | }, |
354 | // Without |X509_V_FLAG_EXPLICIT_POLICY|, the policy tree is built and | 359 | /* |
355 | // intersected with user-specified policies, but it is not required to result | 360 | * Without |X509_V_FLAG_EXPLICIT_POLICY|, the policy tree is built and |
356 | // in any valid policies. | 361 | * intersected with user-specified policies, but it is not required to result |
362 | * in any valid policies. | ||
363 | */ | ||
357 | { | 364 | { |
358 | .id = "nothing with explicit_policy unset", | 365 | .id = "nothing with explicit_policy unset", |
359 | .root_file = CERTSDIR "/" "policy_root.pem", | 366 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -369,7 +376,7 @@ struct verify_cert_test verify_cert_tests[] = { | |||
369 | .policy_oid_to_check = OID3, | 376 | .policy_oid_to_check = OID3, |
370 | .want_chains = 1, | 377 | .want_chains = 1, |
371 | }, | 378 | }, |
372 | // However, a CA with policy constraints can require an explicit policy. | 379 | /* However, a CA with policy constraints can require an explicit policy. */ |
373 | { | 380 | { |
374 | .id = "oid1 with explicit_policy unset, intermediate requiring policy", | 381 | .id = "oid1 with explicit_policy unset, intermediate requiring policy", |
375 | .root_file = CERTSDIR "/" "policy_root.pem", | 382 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -390,9 +397,11 @@ struct verify_cert_test verify_cert_tests[] = { | |||
390 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, | 397 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, |
391 | .want_legacy_error_depth = 0, | 398 | .want_legacy_error_depth = 0, |
392 | }, | 399 | }, |
393 | // requireExplicitPolicy applies even if the application does not configure a | 400 | /* |
394 | // user-initial-policy-set. If the validation results in no policies, the | 401 | * requireExplicitPolicy applies even if the application does not configure a |
395 | // chain is invalid. | 402 | * user-initial-policy-set. If the validation results in no policies, the |
403 | * chain is invalid. | ||
404 | */ | ||
396 | { | 405 | { |
397 | .id = "nothing explict_policy unset, with intermediate requiring policy", | 406 | .id = "nothing explict_policy unset, with intermediate requiring policy", |
398 | .root_file = CERTSDIR "/" "policy_root.pem", | 407 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -404,7 +413,7 @@ struct verify_cert_test verify_cert_tests[] = { | |||
404 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, | 413 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, |
405 | .want_legacy_error_depth = 0, | 414 | .want_legacy_error_depth = 0, |
406 | }, | 415 | }, |
407 | // A leaf can also set requireExplicitPolicy but should work with none | 416 | /* A leaf can also set requireExplicitPolicy but should work with none */ |
408 | { | 417 | { |
409 | .id = "nothing explicit_policy unset, with leaf requiring policy", | 418 | .id = "nothing explicit_policy unset, with leaf requiring policy", |
410 | .root_file = CERTSDIR "/" "policy_root.pem", | 419 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -412,7 +421,7 @@ struct verify_cert_test verify_cert_tests[] = { | |||
412 | .leaf_file = CERTSDIR "/" "policy_leaf_require.pem", | 421 | .leaf_file = CERTSDIR "/" "policy_leaf_require.pem", |
413 | .want_chains = 1, | 422 | .want_chains = 1, |
414 | }, | 423 | }, |
415 | // A leaf can also set requireExplicitPolicy but should fail with policy | 424 | /* A leaf can also set requireExplicitPolicy but should fail with policy */ |
416 | { | 425 | { |
417 | .id = "oid3, explicit policy unset, with leaf requiring policy", | 426 | .id = "oid3, explicit policy unset, with leaf requiring policy", |
418 | .root_file = CERTSDIR "/" "policy_root.pem", | 427 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -425,8 +434,10 @@ struct verify_cert_test verify_cert_tests[] = { | |||
425 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, | 434 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, |
426 | .want_legacy_error_depth = 0, | 435 | .want_legacy_error_depth = 0, |
427 | }, | 436 | }, |
428 | // requireExplicitPolicy is a count of certificates to skip. If the value is | 437 | /* |
429 | // not zero by the end of the chain, it doesn't count. | 438 | * requireExplicitPolicy is a count of certificates to skip. If the value is |
439 | * not zero by the end of the chain, it doesn't count. | ||
440 | */ | ||
430 | { | 441 | { |
431 | .id = "oid3, with intermediate requiring explicit depth 1", | 442 | .id = "oid3, with intermediate requiring explicit depth 1", |
432 | .root_file = CERTSDIR "/" "policy_root.pem", | 443 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -456,8 +467,10 @@ struct verify_cert_test verify_cert_tests[] = { | |||
456 | .policy_oid_to_check = OID3, | 467 | .policy_oid_to_check = OID3, |
457 | .want_chains = 1, | 468 | .want_chains = 1, |
458 | }, | 469 | }, |
459 | // If multiple certificates specify the constraint, the more constrained value | 470 | /* |
460 | // wins. | 471 | * If multiple certificates specify the constraint, the more constrained value |
472 | * wins. | ||
473 | */ | ||
461 | { | 474 | { |
462 | .id = "oid3, with leaf and intermediate requiring explicit depth 1", | 475 | .id = "oid3, with leaf and intermediate requiring explicit depth 1", |
463 | .root_file = CERTSDIR "/" "policy_root.pem", | 476 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -484,8 +497,10 @@ struct verify_cert_test verify_cert_tests[] = { | |||
484 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, | 497 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, |
485 | .want_legacy_error_depth = 0, | 498 | .want_legacy_error_depth = 0, |
486 | }, | 499 | }, |
487 | // An intermediate that requires an explicit policy, but then specifies no | 500 | /* |
488 | // policies should fail verification as a result. | 501 | * An intermediate that requires an explicit policy, but then specifies no |
502 | * policies should fail verification as a result. | ||
503 | */ | ||
489 | { | 504 | { |
490 | .id = "oid1 with explicit_policy unset, intermediate requiring policy but specifying none", | 505 | .id = "oid1 with explicit_policy unset, intermediate requiring policy but specifying none", |
491 | .root_file = CERTSDIR "/" "policy_root.pem", | 506 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -498,8 +513,10 @@ struct verify_cert_test verify_cert_tests[] = { | |||
498 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, | 513 | .want_legacy_error = X509_V_ERR_NO_EXPLICIT_POLICY, |
499 | .want_legacy_error_depth = 0, | 514 | .want_legacy_error_depth = 0, |
500 | }, | 515 | }, |
501 | // A constrained intermediate's policy extension has a duplicate policy, which | 516 | /* |
502 | // is invalid. Historically this, and the above case, leaked memory. | 517 | * A constrained intermediate's policy extension has a duplicate policy, which |
518 | * is invalid. Historically this, and the above case, leaked memory. | ||
519 | */ | ||
503 | { | 520 | { |
504 | .id = "oid1 with explicit_policy unset, intermediate requiring policy but has duplicate", | 521 | .id = "oid1 with explicit_policy unset, intermediate requiring policy but has duplicate", |
505 | .root_file = CERTSDIR "/" "policy_root.pem", | 522 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -512,9 +529,10 @@ struct verify_cert_test verify_cert_tests[] = { | |||
512 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, | 529 | .want_legacy_error = X509_V_ERR_INVALID_POLICY_EXTENSION, |
513 | .want_legacy_error_depth = 0, | 530 | .want_legacy_error_depth = 0, |
514 | }, | 531 | }, |
515 | // The leaf asserts anyPolicy, but the intermediate does not. The resulting | 532 | /* |
516 | // valid policies are the intersection. | 533 | * The leaf asserts anyPolicy, but the intermediate does not. The resulting |
517 | // (and vice versa) | 534 | * valid policies are the intersection.(and vice versa) |
535 | */ | ||
518 | { | 536 | { |
519 | .id = "oid1, with explicit_policy set, with leaf asserting any", | 537 | .id = "oid1, with explicit_policy set, with leaf asserting any", |
520 | .root_file = CERTSDIR "/" "policy_root.pem", | 538 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -533,7 +551,7 @@ struct verify_cert_test verify_cert_tests[] = { | |||
533 | .verify_flags = X509_V_FLAG_EXPLICIT_POLICY, | 551 | .verify_flags = X509_V_FLAG_EXPLICIT_POLICY, |
534 | .want_chains = 1, | 552 | .want_chains = 1, |
535 | }, | 553 | }, |
536 | // Both assert anyPolicy. All policies are valid. | 554 | /* Both assert anyPolicy. All policies are valid. */ |
537 | { | 555 | { |
538 | .id = "oid1, with explicit_policy set, with leaf and intermediate asserting any", | 556 | .id = "oid1, with explicit_policy set, with leaf and intermediate asserting any", |
539 | .root_file = CERTSDIR "/" "policy_root.pem", | 557 | .root_file = CERTSDIR "/" "policy_root.pem", |
@@ -552,8 +570,11 @@ struct verify_cert_test verify_cert_tests[] = { | |||
552 | .verify_flags = X509_V_FLAG_EXPLICIT_POLICY, | 570 | .verify_flags = X509_V_FLAG_EXPLICIT_POLICY, |
553 | .want_chains = 1, | 571 | .want_chains = 1, |
554 | }, | 572 | }, |
555 | // boring tests just a trust anchor but behaves differently in this corner case. | 573 | /* |
556 | // for reasons that have nothing to do wiht policy | 574 | * BoringSSL tests just a trust anchor but behaves differently in this corner case. |
575 | * than libressl for reasons that have nothing to do with policy (because parital | ||
576 | * chains and legacy verifier horror) | ||
577 | */ | ||
557 | }; | 578 | }; |
558 | 579 | ||
559 | #define N_VERIFY_CERT_TESTS \ | 580 | #define N_VERIFY_CERT_TESTS \ |