diff options
author | beck <> | 2023-04-26 19:11:33 +0000 |
---|---|---|
committer | beck <> | 2023-04-26 19:11:33 +0000 |
commit | d2576ff178ab71d730ed11f6d244e0035b9203c2 (patch) | |
tree | 75b208133b3a7fbeb57237a5639552556d1bc38e /src | |
parent | 044e73e94f288a201e6ef15bb65075250510d821 (diff) | |
download | openbsd-d2576ff178ab71d730ed11f6d244e0035b9203c2.tar.gz openbsd-d2576ff178ab71d730ed11f6d244e0035b9203c2.tar.bz2 openbsd-d2576ff178ab71d730ed11f6d244e0035b9203c2.zip |
Make the new policy code in x509_policy.c to be selectable at compile time.
The old policy codes remains the default, with the new policy code
selectable by defining LIBRESSL_HAS_POLICY_DAG.
ok tb@ jsing@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/asn1/x_x509.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/pcy_cache.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/pcy_data.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/pcy_int.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/pcy_lib.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/pcy_map.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/pcy_node.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/pcy_tree.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_cpols.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_local.h | 21 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_policy.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 42 |
12 files changed, 106 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c index df66153c45..5a769abdff 100644 --- a/src/lib/libcrypto/asn1/x_x509.c +++ b/src/lib/libcrypto/asn1/x_x509.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x_x509.c,v 1.33 2023/04/24 08:09:29 job Exp $ */ | 1 | /* $OpenBSD: x_x509.c,v 1.34 2023/04/26 19:11:32 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 | * |
@@ -169,7 +169,9 @@ X509_CINF_free(X509_CINF *a) | |||
169 | } | 169 | } |
170 | /* X509 top level structure needs a bit of customisation */ | 170 | /* X509 top level structure needs a bit of customisation */ |
171 | 171 | ||
172 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
172 | extern void policy_cache_free(X509_POLICY_CACHE *cache); | 173 | extern void policy_cache_free(X509_POLICY_CACHE *cache); |
174 | #endif | ||
173 | 175 | ||
174 | static int | 176 | static int |
175 | x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | 177 | x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) |
@@ -205,7 +207,9 @@ x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
205 | ASN1_OCTET_STRING_free(ret->skid); | 207 | ASN1_OCTET_STRING_free(ret->skid); |
206 | AUTHORITY_KEYID_free(ret->akid); | 208 | AUTHORITY_KEYID_free(ret->akid); |
207 | CRL_DIST_POINTS_free(ret->crldp); | 209 | CRL_DIST_POINTS_free(ret->crldp); |
210 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
208 | policy_cache_free(ret->policy_cache); | 211 | policy_cache_free(ret->policy_cache); |
212 | #endif | ||
209 | GENERAL_NAMES_free(ret->altname); | 213 | GENERAL_NAMES_free(ret->altname); |
210 | NAME_CONSTRAINTS_free(ret->nc); | 214 | NAME_CONSTRAINTS_free(ret->nc); |
211 | #ifndef OPENSSL_NO_RFC3779 | 215 | #ifndef OPENSSL_NO_RFC3779 |
diff --git a/src/lib/libcrypto/x509/pcy_cache.c b/src/lib/libcrypto/x509/pcy_cache.c index 6424160db8..10cefd7f34 100644 --- a/src/lib/libcrypto/x509/pcy_cache.c +++ b/src/lib/libcrypto/x509/pcy_cache.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_cache.c,v 1.3 2022/11/26 16:08:54 tb Exp $ */ | 1 | /* $OpenBSD: pcy_cache.c,v 1.4 2023/04/26 19:11:32 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 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -59,6 +59,8 @@ | |||
59 | #include <openssl/x509.h> | 59 | #include <openssl/x509.h> |
60 | #include <openssl/x509v3.h> | 60 | #include <openssl/x509v3.h> |
61 | 61 | ||
62 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
63 | |||
62 | #include "pcy_int.h" | 64 | #include "pcy_int.h" |
63 | #include "x509_local.h" | 65 | #include "x509_local.h" |
64 | 66 | ||
@@ -270,3 +272,5 @@ policy_cache_set_int(long *out, ASN1_INTEGER *value) | |||
270 | *out = ASN1_INTEGER_get(value); | 272 | *out = ASN1_INTEGER_get(value); |
271 | return 1; | 273 | return 1; |
272 | } | 274 | } |
275 | |||
276 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/pcy_data.c b/src/lib/libcrypto/x509/pcy_data.c index dadacb5266..f0fdfe18ef 100644 --- a/src/lib/libcrypto/x509/pcy_data.c +++ b/src/lib/libcrypto/x509/pcy_data.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_data.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ | 1 | /* $OpenBSD: pcy_data.c,v 1.2 2023/04/26 19:11:32 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 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -59,6 +59,8 @@ | |||
59 | #include <openssl/x509.h> | 59 | #include <openssl/x509.h> |
60 | #include <openssl/x509v3.h> | 60 | #include <openssl/x509v3.h> |
61 | 61 | ||
62 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
63 | |||
62 | #include "pcy_int.h" | 64 | #include "pcy_int.h" |
63 | 65 | ||
64 | /* Policy Node routines */ | 66 | /* Policy Node routines */ |
@@ -127,3 +129,5 @@ err: | |||
127 | ASN1_OBJECT_free(id); | 129 | ASN1_OBJECT_free(id); |
128 | return NULL; | 130 | return NULL; |
129 | } | 131 | } |
132 | |||
133 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/pcy_int.h b/src/lib/libcrypto/x509/pcy_int.h index b183979d87..43bd548f66 100644 --- a/src/lib/libcrypto/x509/pcy_int.h +++ b/src/lib/libcrypto/x509/pcy_int.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_int.h,v 1.4 2023/04/25 18:53:42 tb Exp $ */ | 1 | /* $OpenBSD: pcy_int.h,v 1.5 2023/04/26 19:11:32 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 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -56,6 +56,8 @@ | |||
56 | * | 56 | * |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
60 | |||
59 | /* Needed to pull in the typedefs for X509_POLICY_* */ | 61 | /* Needed to pull in the typedefs for X509_POLICY_* */ |
60 | #include "x509_local.h" | 62 | #include "x509_local.h" |
61 | 63 | ||
@@ -275,3 +277,5 @@ const X509_POLICY_NODE * | |||
275 | 277 | ||
276 | 278 | ||
277 | __END_HIDDEN_DECLS | 279 | __END_HIDDEN_DECLS |
280 | |||
281 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/pcy_lib.c b/src/lib/libcrypto/x509/pcy_lib.c index e4d3fd9fa8..0c8978bd70 100644 --- a/src/lib/libcrypto/x509/pcy_lib.c +++ b/src/lib/libcrypto/x509/pcy_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_lib.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ | 1 | /* $OpenBSD: pcy_lib.c,v 1.4 2023/04/26 19:11:33 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 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -59,6 +59,8 @@ | |||
59 | #include <openssl/x509.h> | 59 | #include <openssl/x509.h> |
60 | #include <openssl/x509v3.h> | 60 | #include <openssl/x509v3.h> |
61 | 61 | ||
62 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
63 | |||
62 | #include "pcy_int.h" | 64 | #include "pcy_int.h" |
63 | 65 | ||
64 | /* accessor functions */ | 66 | /* accessor functions */ |
@@ -164,3 +166,5 @@ X509_policy_node_get0_parent(const X509_POLICY_NODE *node) | |||
164 | return node->parent; | 166 | return node->parent; |
165 | } | 167 | } |
166 | LCRYPTO_ALIAS(X509_policy_node_get0_parent); | 168 | LCRYPTO_ALIAS(X509_policy_node_get0_parent); |
169 | |||
170 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/pcy_map.c b/src/lib/libcrypto/x509/pcy_map.c index fe21ba14d1..ffbc6f75f0 100644 --- a/src/lib/libcrypto/x509/pcy_map.c +++ b/src/lib/libcrypto/x509/pcy_map.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_map.c,v 1.3 2022/11/26 16:08:54 tb Exp $ */ | 1 | /* $OpenBSD: pcy_map.c,v 1.4 2023/04/26 19:11:33 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 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -59,6 +59,8 @@ | |||
59 | #include <openssl/x509.h> | 59 | #include <openssl/x509.h> |
60 | #include <openssl/x509v3.h> | 60 | #include <openssl/x509v3.h> |
61 | 61 | ||
62 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
63 | |||
62 | #include "pcy_int.h" | 64 | #include "pcy_int.h" |
63 | #include "x509_local.h" | 65 | #include "x509_local.h" |
64 | 66 | ||
@@ -125,3 +127,5 @@ bad_mapping: | |||
125 | sk_POLICY_MAPPING_pop_free(maps, POLICY_MAPPING_free); | 127 | sk_POLICY_MAPPING_pop_free(maps, POLICY_MAPPING_free); |
126 | return ret; | 128 | return ret; |
127 | } | 129 | } |
130 | |||
131 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/pcy_node.c b/src/lib/libcrypto/x509/pcy_node.c index 3a0f230bb3..1daf7e2aff 100644 --- a/src/lib/libcrypto/x509/pcy_node.c +++ b/src/lib/libcrypto/x509/pcy_node.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_node.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ | 1 | /* $OpenBSD: pcy_node.c,v 1.2 2023/04/26 19:11:33 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 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -60,6 +60,8 @@ | |||
60 | #include <openssl/x509.h> | 60 | #include <openssl/x509.h> |
61 | #include <openssl/x509v3.h> | 61 | #include <openssl/x509v3.h> |
62 | 62 | ||
63 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
64 | |||
63 | #include "pcy_int.h" | 65 | #include "pcy_int.h" |
64 | 66 | ||
65 | static int | 67 | static int |
@@ -198,3 +200,5 @@ policy_node_match(const X509_POLICY_LEVEL *lvl, const X509_POLICY_NODE *node, | |||
198 | } | 200 | } |
199 | return 0; | 201 | return 0; |
200 | } | 202 | } |
203 | |||
204 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/pcy_tree.c b/src/lib/libcrypto/x509/pcy_tree.c index 56e05910cd..eb3c427a3a 100644 --- a/src/lib/libcrypto/x509/pcy_tree.c +++ b/src/lib/libcrypto/x509/pcy_tree.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_tree.c,v 1.6 2023/02/16 08:38:17 tb Exp $ */ | 1 | /* $OpenBSD: pcy_tree.c,v 1.7 2023/04/26 19:11:33 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 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -59,6 +59,8 @@ | |||
59 | #include <openssl/x509.h> | 59 | #include <openssl/x509.h> |
60 | #include <openssl/x509v3.h> | 60 | #include <openssl/x509v3.h> |
61 | 61 | ||
62 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
63 | |||
62 | #include "pcy_int.h" | 64 | #include "pcy_int.h" |
63 | #include "x509_local.h" | 65 | #include "x509_local.h" |
64 | 66 | ||
@@ -771,3 +773,5 @@ error: | |||
771 | return 0; | 773 | return 0; |
772 | } | 774 | } |
773 | LCRYPTO_ALIAS(X509_policy_check); | 775 | LCRYPTO_ALIAS(X509_policy_check); |
776 | |||
777 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/x509_cpols.c b/src/lib/libcrypto/x509/x509_cpols.c index af8f16c9b0..bac0209371 100644 --- a/src/lib/libcrypto/x509/x509_cpols.c +++ b/src/lib/libcrypto/x509/x509_cpols.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_cpols.c,v 1.8 2023/04/20 18:29:08 tb Exp $ */ | 1 | /* $OpenBSD: x509_cpols.c,v 1.9 2023/04/26 19:11:33 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 | */ |
@@ -65,7 +65,9 @@ | |||
65 | #include <openssl/err.h> | 65 | #include <openssl/err.h> |
66 | #include <openssl/x509v3.h> | 66 | #include <openssl/x509v3.h> |
67 | 67 | ||
68 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
68 | #include "pcy_int.h" | 69 | #include "pcy_int.h" |
70 | #endif | ||
69 | #include "x509_local.h" | 71 | #include "x509_local.h" |
70 | 72 | ||
71 | /* Certificate policies extension support: this one is a bit complex... */ | 73 | /* Certificate policies extension support: this one is a bit complex... */ |
@@ -766,6 +768,7 @@ print_notice(BIO *out, USERNOTICE *notice, int indent) | |||
766 | notice->exptext->length, notice->exptext->data); | 768 | notice->exptext->length, notice->exptext->data); |
767 | } | 769 | } |
768 | 770 | ||
771 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
769 | void | 772 | void |
770 | X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) | 773 | X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) |
771 | { | 774 | { |
@@ -783,3 +786,4 @@ X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) | |||
783 | BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); | 786 | BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); |
784 | } | 787 | } |
785 | LCRYPTO_ALIAS(X509_POLICY_NODE_print); | 788 | LCRYPTO_ALIAS(X509_POLICY_NODE_print); |
789 | #endif | ||
diff --git a/src/lib/libcrypto/x509/x509_local.h b/src/lib/libcrypto/x509/x509_local.h index 6f711fe3e1..1aa66d2440 100644 --- a/src/lib/libcrypto/x509/x509_local.h +++ b/src/lib/libcrypto/x509/x509_local.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_local.h,v 1.5 2023/04/25 18:28:05 tb Exp $ */ | 1 | /* $OpenBSD: x509_local.h,v 1.6 2023/04/26 19:11:33 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 2013. | 3 | * project 2013. |
4 | */ | 4 | */ |
@@ -69,10 +69,12 @@ __BEGIN_HIDDEN_DECLS | |||
69 | #define X509_CRL_HASH_EVP EVP_sha512() | 69 | #define X509_CRL_HASH_EVP EVP_sha512() |
70 | #define X509_CRL_HASH_LEN SHA512_DIGEST_LENGTH | 70 | #define X509_CRL_HASH_LEN SHA512_DIGEST_LENGTH |
71 | 71 | ||
72 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
72 | typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; | 73 | typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; |
73 | typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; | 74 | typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; |
74 | typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; | 75 | typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; |
75 | typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; | 76 | typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; |
77 | #endif | ||
76 | 78 | ||
77 | struct X509_pubkey_st { | 79 | struct X509_pubkey_st { |
78 | X509_ALGOR *algor; | 80 | X509_ALGOR *algor; |
@@ -176,7 +178,9 @@ struct x509_st { | |||
176 | unsigned long ex_nscert; | 178 | unsigned long ex_nscert; |
177 | ASN1_OCTET_STRING *skid; | 179 | ASN1_OCTET_STRING *skid; |
178 | AUTHORITY_KEYID *akid; | 180 | AUTHORITY_KEYID *akid; |
181 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
179 | X509_POLICY_CACHE *policy_cache; | 182 | X509_POLICY_CACHE *policy_cache; |
183 | #endif | ||
180 | STACK_OF(DIST_POINT) *crldp; | 184 | STACK_OF(DIST_POINT) *crldp; |
181 | STACK_OF(GENERAL_NAME) *altname; | 185 | STACK_OF(GENERAL_NAME) *altname; |
182 | NAME_CONSTRAINTS *nc; | 186 | NAME_CONSTRAINTS *nc; |
@@ -356,7 +360,9 @@ struct x509_store_ctx_st { | |||
356 | int valid; /* if 0, rebuild chain */ | 360 | int valid; /* if 0, rebuild chain */ |
357 | int num_untrusted; /* number of untrusted certs in chain */ | 361 | int num_untrusted; /* number of untrusted certs in chain */ |
358 | STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ | 362 | STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ |
359 | X509_POLICY_TREE *tree; /* Valid policy tree */ | 363 | #ifndef LIBRESSL_HAS_POLICY_DAG |
364 | X509_POLICY_TREE *tree; /* Valid policy tree */ | ||
365 | #endif | ||
360 | 366 | ||
361 | int explicit_policy; /* Require explicit policy value */ | 367 | int explicit_policy; /* Require explicit policy value */ |
362 | 368 | ||
@@ -390,12 +396,17 @@ int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int quiet); | |||
390 | 396 | ||
391 | int name_cmp(const char *name, const char *cmp); | 397 | int name_cmp(const char *name, const char *cmp); |
392 | 398 | ||
399 | #ifdef LIBRESSL_HAS_POLICY_DAG | ||
400 | int X509_policy_check(const STACK_OF(X509) *certs, | ||
401 | const STACK_OF(ASN1_OBJECT) *user_policies, unsigned long flags, | ||
402 | X509 **out_current_cert); | ||
403 | #else | ||
393 | int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, | 404 | int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, |
394 | STACK_OF(X509) *certs, | 405 | STACK_OF(X509) *certs, STACK_OF(ASN1_OBJECT) *policy_oids, |
395 | STACK_OF(ASN1_OBJECT) *policy_oids, | 406 | unsigned int flags); |
396 | unsigned int flags); | ||
397 | 407 | ||
398 | void X509_policy_tree_free(X509_POLICY_TREE *tree); | 408 | void X509_policy_tree_free(X509_POLICY_TREE *tree); |
409 | #endif | ||
399 | 410 | ||
400 | __END_HIDDEN_DECLS | 411 | __END_HIDDEN_DECLS |
401 | 412 | ||
diff --git a/src/lib/libcrypto/x509/x509_policy.c b/src/lib/libcrypto/x509/x509_policy.c index c9618dbf23..d49d86856c 100644 --- a/src/lib/libcrypto/x509/x509_policy.c +++ b/src/lib/libcrypto/x509/x509_policy.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include "x509_internal.h" | 25 | #include "x509_internal.h" |
26 | #include "x509_local.h" | 26 | #include "x509_local.h" |
27 | 27 | ||
28 | #ifdef LIBRESSL_HAS_POLICY_DAG | ||
29 | |||
28 | /* XXX move to proper place */ | 30 | /* XXX move to proper place */ |
29 | #define X509_R_INVALID_POLICY_EXTENSION 201 | 31 | #define X509_R_INVALID_POLICY_EXTENSION 201 |
30 | 32 | ||
@@ -856,3 +858,5 @@ err: | |||
856 | sk_X509_POLICY_LEVEL_pop_free(levels, x509_policy_level_free); | 858 | sk_X509_POLICY_LEVEL_pop_free(levels, x509_policy_level_free); |
857 | return ret; | 859 | return ret; |
858 | } | 860 | } |
861 | |||
862 | #endif /* LIBRESSL_HAS_POLICY_DAG */ | ||
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 4b042e0b26..76847e7224 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.115 2023/04/25 18:37:56 tb Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.116 2023/04/26 19:11:33 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 | * |
@@ -1743,6 +1743,43 @@ cert_crl(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x) | |||
1743 | return 1; | 1743 | return 1; |
1744 | } | 1744 | } |
1745 | 1745 | ||
1746 | |||
1747 | #ifdef LIBRESSL_HAS_POLICY_DAG | ||
1748 | int | ||
1749 | x509_vfy_check_policy(X509_STORE_CTX *ctx) | ||
1750 | { | ||
1751 | X509 *current_cert = NULL; | ||
1752 | int ret; | ||
1753 | |||
1754 | if (ctx->parent != NULL) | ||
1755 | return 1; | ||
1756 | |||
1757 | ret = X509_policy_check(ctx->chain, ctx->param->policies, | ||
1758 | ctx->param->flags, ¤t_cert); | ||
1759 | if (ret != X509_V_OK) { | ||
1760 | ctx->current_cert = current_cert; | ||
1761 | ctx->error = ret; | ||
1762 | if (ret == X509_V_ERR_OUT_OF_MEM) | ||
1763 | return 0; | ||
1764 | return ctx->verify_cb(0, ctx); | ||
1765 | } | ||
1766 | |||
1767 | if (ctx->param->flags & X509_V_FLAG_NOTIFY_POLICY) { | ||
1768 | ctx->current_cert = NULL; | ||
1769 | /* | ||
1770 | * Verification errors need to be "sticky", a callback may have | ||
1771 | * allowed an SSL handshake to continue despite an error, and | ||
1772 | * we must then remain in an error state. Therefore, we MUST | ||
1773 | * NOT clear earlier verification errors by setting the error | ||
1774 | * to X509_V_OK. | ||
1775 | */ | ||
1776 | if (!ctx->verify_cb(2, ctx)) | ||
1777 | return 0; | ||
1778 | } | ||
1779 | |||
1780 | return 1; | ||
1781 | } | ||
1782 | #else | ||
1746 | int | 1783 | int |
1747 | x509_vfy_check_policy(X509_STORE_CTX *ctx) | 1784 | x509_vfy_check_policy(X509_STORE_CTX *ctx) |
1748 | { | 1785 | { |
@@ -1794,6 +1831,7 @@ x509_vfy_check_policy(X509_STORE_CTX *ctx) | |||
1794 | 1831 | ||
1795 | return 1; | 1832 | return 1; |
1796 | } | 1833 | } |
1834 | #endif | ||
1797 | 1835 | ||
1798 | static int | 1836 | static int |
1799 | check_policy(X509_STORE_CTX *ctx) | 1837 | check_policy(X509_STORE_CTX *ctx) |
@@ -2486,10 +2524,12 @@ X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx) | |||
2486 | X509_VERIFY_PARAM_free(ctx->param); | 2524 | X509_VERIFY_PARAM_free(ctx->param); |
2487 | ctx->param = NULL; | 2525 | ctx->param = NULL; |
2488 | } | 2526 | } |
2527 | #ifndef LIBRESSL_HAS_POLICY_DAG | ||
2489 | if (ctx->tree != NULL) { | 2528 | if (ctx->tree != NULL) { |
2490 | X509_policy_tree_free(ctx->tree); | 2529 | X509_policy_tree_free(ctx->tree); |
2491 | ctx->tree = NULL; | 2530 | ctx->tree = NULL; |
2492 | } | 2531 | } |
2532 | #endif | ||
2493 | if (ctx->chain != NULL) { | 2533 | if (ctx->chain != NULL) { |
2494 | sk_X509_pop_free(ctx->chain, X509_free); | 2534 | sk_X509_pop_free(ctx->chain, X509_free); |
2495 | ctx->chain = NULL; | 2535 | ctx->chain = NULL; |