| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-04-08 20:04:41 +08:00
										 |  |  |  * Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2016-05-18 02:51:26 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-12-06 21:00:54 +08:00
										 |  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-05-18 02:51:26 +08:00
										 |  |  |  * this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  |  * in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  |  * https://www.openssl.org/source/license.html
 | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-05-18 02:51:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-16 01:15:26 +08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This file is dual-licensed and is also available under the following | 
					
						
							|  |  |  |  * terms: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2004 Kungliga Tekniska Högskolan | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  |  * (Royal Institute of Technology, Stockholm, Sweden). | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Redistribution and use in source and binary forms, with or without | 
					
						
							|  |  |  |  * modification, are permitted provided that the following conditions | 
					
						
							|  |  |  |  * are met: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 1. Redistributions of source code must retain the above copyright | 
					
						
							|  |  |  |  *    notice, this list of conditions and the following disclaimer. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 2. Redistributions in binary form must reproduce the above copyright | 
					
						
							|  |  |  |  *    notice, this list of conditions and the following disclaimer in the | 
					
						
							|  |  |  |  *    documentation and/or other materials provided with the distribution. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 3. Neither the name of the Institute nor the names of its contributors | 
					
						
							|  |  |  |  *    may be used to endorse or promote products derived from this software | 
					
						
							|  |  |  |  *    without specific prior written permission. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND | 
					
						
							|  |  |  |  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
					
						
							|  |  |  |  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
					
						
							|  |  |  |  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE | 
					
						
							|  |  |  |  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
					
						
							|  |  |  |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
					
						
							|  |  |  |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
					
						
							|  |  |  |  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
					
						
							|  |  |  |  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
					
						
							|  |  |  |  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
					
						
							|  |  |  |  * SUCH DAMAGE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2015-05-14 22:56:48 +08:00
										 |  |  | #include "internal/cryptlib.h"
 | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | #include <openssl/conf.h>
 | 
					
						
							|  |  |  | #include <openssl/x509v3.h>
 | 
					
						
							| 
									
										
										
										
											2015-09-05 20:32:58 +08:00
										 |  |  | #include "ext_dat.h"
 | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *ext, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                    BIO *out, int indent); | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | static PROXY_CERT_INFO_EXTENSION *r2i_pci(X509V3_EXT_METHOD *method, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                                           X509V3_CTX *ctx, char *str); | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-09 08:52:15 +08:00
										 |  |  | const X509V3_EXT_METHOD ossl_v3_pci = | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     { NID_proxyCertInfo, 0, ASN1_ITEM_ref(PROXY_CERT_INFO_EXTENSION), | 
					
						
							|  |  |  |     0, 0, 0, 0, | 
					
						
							|  |  |  |     0, 0, | 
					
						
							|  |  |  |     NULL, NULL, | 
					
						
							|  |  |  |     (X509V3_EXT_I2R)i2r_pci, | 
					
						
							|  |  |  |     (X509V3_EXT_R2I)r2i_pci, | 
					
						
							|  |  |  |     NULL, | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                    BIO *out, int indent) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     BIO_printf(out, "%*sPath Length Constraint: ", indent, ""); | 
					
						
							|  |  |  |     if (pci->pcPathLengthConstraint) | 
					
						
							|  |  |  |         i2a_ASN1_INTEGER(out, pci->pcPathLengthConstraint); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         BIO_printf(out, "infinite"); | 
					
						
							|  |  |  |     BIO_puts(out, "\n"); | 
					
						
							|  |  |  |     BIO_printf(out, "%*sPolicy Language: ", indent, ""); | 
					
						
							|  |  |  |     i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); | 
					
						
							|  |  |  |     if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) | 
					
						
							| 
									
										
										
										
											2021-08-18 21:02:40 +08:00
										 |  |  |         BIO_printf(out, "\n%*sPolicy Text: %.*s", indent, "", | 
					
						
							|  |  |  |                    pci->proxyPolicy->policy->length, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                    pci->proxyPolicy->policy->data); | 
					
						
							|  |  |  |     return 1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int process_pci_value(CONF_VALUE *val, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                              ASN1_OBJECT **language, ASN1_INTEGER **pathlen, | 
					
						
							|  |  |  |                              ASN1_OCTET_STRING **policy) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int free_policy = 0; | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     if (strcmp(val->name, "language") == 0) { | 
					
						
							|  |  |  |         if (*language) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |             ERR_raise(ERR_LIB_X509V3, X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             X509V3_conf_err(val); | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-07 01:43:59 +08:00
										 |  |  |         if ((*language = OBJ_txt2obj(val->value, 0)) == NULL) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |             ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             X509V3_conf_err(val); | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else if (strcmp(val->name, "pathlen") == 0) { | 
					
						
							|  |  |  |         if (*pathlen) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |             ERR_raise(ERR_LIB_X509V3, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                       X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED); | 
					
						
							|  |  |  |             X509V3_conf_err(val); | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!X509V3_get_value_int(val, pathlen)) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |             ERR_raise(ERR_LIB_X509V3, X509V3_R_POLICY_PATH_LENGTH); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             X509V3_conf_err(val); | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else if (strcmp(val->name, "policy") == 0) { | 
					
						
							| 
									
										
										
										
											2021-06-21 14:55:50 +08:00
										 |  |  |         char *valp = val->value; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         unsigned char *tmp_data = NULL; | 
					
						
							|  |  |  |         long val_len; | 
					
						
							| 
									
										
										
										
											2019-09-17 03:28:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (*policy == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             *policy = ASN1_OCTET_STRING_new(); | 
					
						
							| 
									
										
										
										
											2015-10-30 19:12:26 +08:00
										 |  |  |             if (*policy == NULL) { | 
					
						
							| 
									
										
										
										
											2022-09-29 19:57:34 +08:00
										 |  |  |                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 X509V3_conf_err(val); | 
					
						
							|  |  |  |                 return 0; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             free_policy = 1; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-06-21 14:55:50 +08:00
										 |  |  |         if (CHECK_AND_SKIP_PREFIX(valp, "hex:")) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             unsigned char *tmp_data2 = | 
					
						
							| 
									
										
										
										
											2021-06-21 14:55:50 +08:00
										 |  |  |                 OPENSSL_hexstr2buf(valp, &val_len); | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (!tmp_data2) { | 
					
						
							|  |  |  |                 X509V3_conf_err(val); | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             tmp_data = OPENSSL_realloc((*policy)->data, | 
					
						
							|  |  |  |                                        (*policy)->length + val_len + 1); | 
					
						
							|  |  |  |             if (tmp_data) { | 
					
						
							|  |  |  |                 (*policy)->data = tmp_data; | 
					
						
							|  |  |  |                 memcpy(&(*policy)->data[(*policy)->length], | 
					
						
							|  |  |  |                        tmp_data2, val_len); | 
					
						
							|  |  |  |                 (*policy)->length += val_len; | 
					
						
							|  |  |  |                 (*policy)->data[(*policy)->length] = '\0'; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 OPENSSL_free(tmp_data2); | 
					
						
							|  |  |  |                 /*
 | 
					
						
							|  |  |  |                  * realloc failure implies the original data space is b0rked | 
					
						
							|  |  |  |                  * too! | 
					
						
							|  |  |  |                  */ | 
					
						
							|  |  |  |                 OPENSSL_free((*policy)->data); | 
					
						
							|  |  |  |                 (*policy)->data = NULL; | 
					
						
							|  |  |  |                 (*policy)->length = 0; | 
					
						
							|  |  |  |                 X509V3_conf_err(val); | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             OPENSSL_free(tmp_data2); | 
					
						
							| 
									
										
										
										
											2021-06-21 14:55:50 +08:00
										 |  |  |         } else if (CHECK_AND_SKIP_PREFIX(valp, "file:")) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             unsigned char buf[2048]; | 
					
						
							|  |  |  |             int n; | 
					
						
							| 
									
										
										
										
											2021-06-21 14:55:50 +08:00
										 |  |  |             BIO *b = BIO_new_file(valp, "r"); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (!b) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |                 ERR_raise(ERR_LIB_X509V3, ERR_R_BIO_LIB); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 X509V3_conf_err(val); | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             while ((n = BIO_read(b, buf, sizeof(buf))) > 0 | 
					
						
							|  |  |  |                    || (n == 0 && BIO_should_retry(b))) { | 
					
						
							|  |  |  |                 if (!n) | 
					
						
							|  |  |  |                     continue; | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 tmp_data = OPENSSL_realloc((*policy)->data, | 
					
						
							|  |  |  |                                            (*policy)->length + n + 1); | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 if (!tmp_data) { | 
					
						
							|  |  |  |                     OPENSSL_free((*policy)->data); | 
					
						
							|  |  |  |                     (*policy)->data = NULL; | 
					
						
							|  |  |  |                     (*policy)->length = 0; | 
					
						
							|  |  |  |                     X509V3_conf_err(val); | 
					
						
							|  |  |  |                     BIO_free_all(b); | 
					
						
							|  |  |  |                     goto err; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 (*policy)->data = tmp_data; | 
					
						
							|  |  |  |                 memcpy(&(*policy)->data[(*policy)->length], buf, n); | 
					
						
							|  |  |  |                 (*policy)->length += n; | 
					
						
							|  |  |  |                 (*policy)->data[(*policy)->length] = '\0'; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             BIO_free_all(b); | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (n < 0) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |                 ERR_raise(ERR_LIB_X509V3, ERR_R_BIO_LIB); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 X509V3_conf_err(val); | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-06-21 14:55:50 +08:00
										 |  |  |         } else if (CHECK_AND_SKIP_PREFIX(valp, "text:")) { | 
					
						
							|  |  |  |             val_len = strlen(valp); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             tmp_data = OPENSSL_realloc((*policy)->data, | 
					
						
							|  |  |  |                                        (*policy)->length + val_len + 1); | 
					
						
							|  |  |  |             if (tmp_data) { | 
					
						
							|  |  |  |                 (*policy)->data = tmp_data; | 
					
						
							|  |  |  |                 memcpy(&(*policy)->data[(*policy)->length], | 
					
						
							|  |  |  |                        val->value + 5, val_len); | 
					
						
							|  |  |  |                 (*policy)->length += val_len; | 
					
						
							|  |  |  |                 (*policy)->data[(*policy)->length] = '\0'; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 /*
 | 
					
						
							|  |  |  |                  * realloc failure implies the original data space is b0rked | 
					
						
							|  |  |  |                  * too! | 
					
						
							|  |  |  |                  */ | 
					
						
							|  |  |  |                 OPENSSL_free((*policy)->data); | 
					
						
							|  |  |  |                 (*policy)->data = NULL; | 
					
						
							|  |  |  |                 (*policy)->length = 0; | 
					
						
							|  |  |  |                 X509V3_conf_err(val); | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |             ERR_raise(ERR_LIB_X509V3, X509V3_R_INCORRECT_POLICY_SYNTAX_TAG); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             X509V3_conf_err(val); | 
					
						
							|  |  |  |             goto err; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!tmp_data) { | 
					
						
							|  |  |  |             X509V3_conf_err(val); | 
					
						
							|  |  |  |             goto err; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 1; | 
					
						
							|  |  |  |  err: | 
					
						
							|  |  |  |     if (free_policy) { | 
					
						
							|  |  |  |         ASN1_OCTET_STRING_free(*policy); | 
					
						
							|  |  |  |         *policy = NULL; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PROXY_CERT_INFO_EXTENSION *r2i_pci(X509V3_EXT_METHOD *method, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                                           X509V3_CTX *ctx, char *value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     PROXY_CERT_INFO_EXTENSION *pci = NULL; | 
					
						
							|  |  |  |     STACK_OF(CONF_VALUE) *vals; | 
					
						
							|  |  |  |     ASN1_OBJECT *language = NULL; | 
					
						
							|  |  |  |     ASN1_INTEGER *pathlen = NULL; | 
					
						
							|  |  |  |     ASN1_OCTET_STRING *policy = NULL; | 
					
						
							|  |  |  |     int i, j; | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     vals = X509V3_parse_list(value); | 
					
						
							|  |  |  |     for (i = 0; i < sk_CONF_VALUE_num(vals); i++) { | 
					
						
							|  |  |  |         CONF_VALUE *cnf = sk_CONF_VALUE_value(vals, i); | 
					
						
							| 
									
										
										
										
											2020-06-26 22:16:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         if (!cnf->name || (*cnf->name != '@' && !cnf->value)) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |             ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_PROXY_POLICY_SETTING); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             X509V3_conf_err(cnf); | 
					
						
							|  |  |  |             goto err; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (*cnf->name == '@') { | 
					
						
							|  |  |  |             STACK_OF(CONF_VALUE) *sect; | 
					
						
							|  |  |  |             int success_p = 1; | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             sect = X509V3_get_section(ctx, cnf->name + 1); | 
					
						
							|  |  |  |             if (!sect) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |                 ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 X509V3_conf_err(cnf); | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             for (j = 0; success_p && j < sk_CONF_VALUE_num(sect); j++) { | 
					
						
							|  |  |  |                 success_p = | 
					
						
							|  |  |  |                     process_pci_value(sk_CONF_VALUE_value(sect, j), | 
					
						
							|  |  |  |                                       &language, &pathlen, &policy); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             X509V3_section_free(ctx, sect); | 
					
						
							|  |  |  |             if (!success_p) | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             if (!process_pci_value(cnf, &language, &pathlen, &policy)) { | 
					
						
							|  |  |  |                 X509V3_conf_err(cnf); | 
					
						
							|  |  |  |                 goto err; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     /* Language is mandatory */ | 
					
						
							|  |  |  |     if (!language) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |         ERR_raise(ERR_LIB_X509V3, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                   X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED); | 
					
						
							|  |  |  |         goto err; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     i = OBJ_obj2nid(language); | 
					
						
							|  |  |  |     if ((i == NID_Independent || i == NID_id_ppl_inheritAll) && policy) { | 
					
						
							| 
									
										
										
										
											2020-11-04 19:23:19 +08:00
										 |  |  |         ERR_raise(ERR_LIB_X509V3, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                   X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY); | 
					
						
							|  |  |  |         goto err; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     pci = PROXY_CERT_INFO_EXTENSION_new(); | 
					
						
							| 
									
										
										
										
											2015-10-30 19:12:26 +08:00
										 |  |  |     if (pci == NULL) { | 
					
						
							| 
									
										
										
										
											2022-09-29 19:57:34 +08:00
										 |  |  |         ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         goto err; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2004-12-28 08:21:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     pci->proxyPolicy->policyLanguage = language; | 
					
						
							|  |  |  |     language = NULL; | 
					
						
							|  |  |  |     pci->proxyPolicy->policy = policy; | 
					
						
							|  |  |  |     policy = NULL; | 
					
						
							|  |  |  |     pci->pcPathLengthConstraint = pathlen; | 
					
						
							|  |  |  |     pathlen = NULL; | 
					
						
							|  |  |  |     goto end; | 
					
						
							|  |  |  |  err: | 
					
						
							| 
									
										
										
										
											2015-03-24 19:52:24 +08:00
										 |  |  |     ASN1_OBJECT_free(language); | 
					
						
							| 
									
										
										
										
											2015-04-30 23:30:03 +08:00
										 |  |  |     ASN1_INTEGER_free(pathlen); | 
					
						
							|  |  |  |     pathlen = NULL; | 
					
						
							|  |  |  |     ASN1_OCTET_STRING_free(policy); | 
					
						
							|  |  |  |     policy = NULL; | 
					
						
							|  |  |  |     PROXY_CERT_INFO_EXTENSION_free(pci); | 
					
						
							|  |  |  |     pci = NULL; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |  end: | 
					
						
							|  |  |  |     sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); | 
					
						
							|  |  |  |     return pci; | 
					
						
							|  |  |  | } |