diff options
-rw-r--r-- | src/lib/libcrypto/x509/x509_internal.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_trs.c | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 49 |
3 files changed, 8 insertions, 64 deletions
diff --git a/src/lib/libcrypto/x509/x509_internal.h b/src/lib/libcrypto/x509/x509_internal.h index 9e80b2d2cf..472b417403 100644 --- a/src/lib/libcrypto/x509/x509_internal.h +++ b/src/lib/libcrypto/x509/x509_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_internal.h,v 1.21 2022/11/13 18:37:32 beck Exp $ */ | 1 | /* $OpenBSD: x509_internal.h,v 1.22 2022/11/17 00:42:12 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -134,7 +134,6 @@ int x509_constraints_check(struct x509_constraints_names *names, | |||
134 | struct x509_constraints_names *excluded, int *error); | 134 | struct x509_constraints_names *excluded, int *error); |
135 | int x509_constraints_chain(STACK_OF(X509) *chain, int *error, | 135 | int x509_constraints_chain(STACK_OF(X509) *chain, int *error, |
136 | int *depth); | 136 | int *depth); |
137 | int x509_check_trust_no_compat(X509 *x, int id, int flags); | ||
138 | void x509_verify_cert_info_populate(X509 *cert); | 137 | void x509_verify_cert_info_populate(X509 *cert); |
139 | int x509_vfy_check_security_level(X509_STORE_CTX *ctx); | 138 | int x509_vfy_check_security_level(X509_STORE_CTX *ctx); |
140 | 139 | ||
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c index b075d1b6c8..c4d371446c 100644 --- a/src/lib/libcrypto/x509/x509_trs.c +++ b/src/lib/libcrypto/x509/x509_trs.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_trs.c,v 1.28 2022/11/14 17:48:50 beck Exp $ */ | 1 | /* $OpenBSD: x509_trs.c,v 1.29 2022/11/17 00:42:12 beck Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -111,8 +111,8 @@ int | |||
111 | } | 111 | } |
112 | LCRYPTO_ALIAS(X509_TRUST_set_default) | 112 | LCRYPTO_ALIAS(X509_TRUST_set_default) |
113 | 113 | ||
114 | static int | 114 | int |
115 | X509_check_trust_internal(X509 *x, int id, int flags, int compat) | 115 | X509_check_trust(X509 *x, int id, int flags) |
116 | { | 116 | { |
117 | X509_TRUST *pt; | 117 | X509_TRUST *pt; |
118 | int idx; | 118 | int idx; |
@@ -133,7 +133,7 @@ X509_check_trust_internal(X509 *x, int id, int flags, int compat) | |||
133 | rv = obj_trust(NID_anyExtendedKeyUsage, x, 0); | 133 | rv = obj_trust(NID_anyExtendedKeyUsage, x, 0); |
134 | if (rv != X509_TRUST_UNTRUSTED) | 134 | if (rv != X509_TRUST_UNTRUSTED) |
135 | return rv; | 135 | return rv; |
136 | return compat && trust_compat(NULL, x, 0); | 136 | return trust_compat(NULL, x, 0); |
137 | } | 137 | } |
138 | idx = X509_TRUST_get_by_id(id); | 138 | idx = X509_TRUST_get_by_id(id); |
139 | if (idx == -1) | 139 | if (idx == -1) |
@@ -144,18 +144,6 @@ X509_check_trust_internal(X509 *x, int id, int flags, int compat) | |||
144 | LCRYPTO_ALIAS(X509_check_trust) | 144 | LCRYPTO_ALIAS(X509_check_trust) |
145 | 145 | ||
146 | int | 146 | int |
147 | X509_check_trust(X509 *x, int id, int flags) | ||
148 | { | ||
149 | return X509_check_trust_internal(x, id, flags, /*compat =*/1); | ||
150 | } | ||
151 | |||
152 | int | ||
153 | x509_check_trust_no_compat(X509 *x, int id, int flags) | ||
154 | { | ||
155 | return X509_check_trust_internal(x, id, flags, /*compat =*/0); | ||
156 | } | ||
157 | |||
158 | int | ||
159 | X509_TRUST_get_count(void) | 147 | X509_TRUST_get_count(void) |
160 | { | 148 | { |
161 | if (!trtable) | 149 | if (!trtable) |
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) || |