diff options
Diffstat (limited to 'src/lib/libcrypto/x509/x509_vfy.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 49 |
1 files changed, 3 insertions, 46 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 09c0b8105e..0a9965ae30 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_vfy.c,v 1.105 2022/11/14 17:48:50 beck Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.106 2022/11/17 00:42:12 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -725,43 +725,6 @@ get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x) | |||
725 | return 0; | 725 | return 0; |
726 | } | 726 | } |
727 | 727 | ||
728 | /* | ||
729 | * X509_check_purpose is special. | ||
730 | * 0 is bad, 1 is good, values > 1 are maybe good for web pki necromancy | ||
731 | * and certificates that were checked into software unit tests years ago | ||
732 | * that nobody knows how to change. (Netscape Server Gated Crypto Forever!) | ||
733 | */ | ||
734 | #define PURPOSE_GOOD(x) (x == 1) | ||
735 | #define PURPOSE_BAD(x) (x == 0) | ||
736 | static int | ||
737 | check_purpose(X509_STORE_CTX *ctx, X509 *x, int purpose, int depth, | ||
738 | int must_be_ca) | ||
739 | { | ||
740 | int purpose_check, trust; | ||
741 | |||
742 | purpose_check = X509_check_purpose(x, purpose, must_be_ca > 0); | ||
743 | trust = X509_TRUST_UNTRUSTED; | ||
744 | |||
745 | /* | ||
746 | * For trusted certificates we want to see whether any auxiliary trust | ||
747 | * settings for the desired purpose override the purpose constraints | ||
748 | * from the certificate EKU. | ||
749 | */ | ||
750 | if (depth >= ctx->num_untrusted && purpose == ctx->param->purpose) | ||
751 | trust = x509_check_trust_no_compat(x, ctx->param->trust, 0); | ||
752 | |||
753 | /* XXX STRICT should really be the default */ | ||
754 | if (trust != X509_TRUST_REJECTED && !PURPOSE_BAD(purpose_check)) { | ||
755 | return PURPOSE_GOOD(purpose_check) || | ||
756 | (ctx->param->flags & X509_V_FLAG_X509_STRICT) == 0; | ||
757 | } | ||
758 | |||
759 | ctx->error = X509_V_ERR_INVALID_PURPOSE; | ||
760 | ctx->error_depth = depth; | ||
761 | ctx->current_cert = x; | ||
762 | return ctx->verify_cb(0, ctx); | ||
763 | } | ||
764 | |||
765 | /* Check a certificate chains extensions for consistency | 728 | /* Check a certificate chains extensions for consistency |
766 | * with the supplied purpose | 729 | * with the supplied purpose |
767 | */ | 730 | */ |
@@ -778,7 +741,6 @@ x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx) | |||
778 | int proxy_path_length = 0; | 741 | int proxy_path_length = 0; |
779 | int purpose; | 742 | int purpose; |
780 | int allow_proxy_certs; | 743 | int allow_proxy_certs; |
781 | size_t chain_len; | ||
782 | 744 | ||
783 | cb = ctx->verify_cb; | 745 | cb = ctx->verify_cb; |
784 | 746 | ||
@@ -802,8 +764,8 @@ x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx) | |||
802 | purpose = ctx->param->purpose; | 764 | purpose = ctx->param->purpose; |
803 | } | 765 | } |
804 | 766 | ||
805 | chain_len = sk_X509_num(ctx->chain); | 767 | /* Check all untrusted certificates */ |
806 | for (i = 0; i < chain_len; i++) { | 768 | for (i = 0; i < ctx->num_untrusted; i++) { |
807 | int ret; | 769 | int ret; |
808 | x = sk_X509_value(ctx->chain, i); | 770 | x = sk_X509_value(ctx->chain, i); |
809 | if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL) && | 771 | if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL) && |
@@ -857,11 +819,6 @@ x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx) | |||
857 | if (!ok) | 819 | if (!ok) |
858 | goto end; | 820 | goto end; |
859 | } | 821 | } |
860 | if (purpose > 0) { | ||
861 | ok = check_purpose(ctx, x, purpose, i, must_be_ca); | ||
862 | if (!ok) | ||
863 | goto end; | ||
864 | } | ||
865 | if (ctx->param->purpose > 0) { | 822 | if (ctx->param->purpose > 0) { |
866 | ret = X509_check_purpose(x, purpose, must_be_ca > 0); | 823 | ret = X509_check_purpose(x, purpose, must_be_ca > 0); |
867 | if ((ret == 0) || | 824 | if ((ret == 0) || |