diff options
author | cvs2svn <admin@example.com> | 2025-04-14 17:32:06 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 2025-04-14 17:32:06 +0000 |
commit | eb8dd9dca1228af0cd132f515509051ecfabf6f6 (patch) | |
tree | edb6da6af7e865d488dc1a29309f1e1ec226e603 /src/lib/libcrypto/conf/conf_lib.c | |
parent | 247f0352e0ed72a4f476db9dc91f4d982bc83eb2 (diff) | |
download | openbsd-tb_20250414.tar.gz openbsd-tb_20250414.tar.bz2 openbsd-tb_20250414.zip |
This commit was manufactured by cvs2git to create tag 'tb_20250414'.tb_20250414
Diffstat (limited to 'src/lib/libcrypto/conf/conf_lib.c')
-rw-r--r-- | src/lib/libcrypto/conf/conf_lib.c | 197 |
1 files changed, 0 insertions, 197 deletions
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c deleted file mode 100644 index 863e1c9475..0000000000 --- a/src/lib/libcrypto/conf/conf_lib.c +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | /* $OpenBSD: conf_lib.c,v 1.25 2025/03/08 09:35:53 tb Exp $ */ | ||
2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <openssl/crypto.h> | ||
61 | #include <openssl/err.h> | ||
62 | #include <openssl/conf.h> | ||
63 | #include <openssl/lhash.h> | ||
64 | |||
65 | #include "conf_local.h" | ||
66 | |||
67 | static const CONF_METHOD *default_CONF_method = NULL; | ||
68 | |||
69 | /* Init a 'CONF' structure from an old LHASH */ | ||
70 | |||
71 | void | ||
72 | CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash) | ||
73 | { | ||
74 | if (default_CONF_method == NULL) | ||
75 | default_CONF_method = NCONF_default(); | ||
76 | default_CONF_method->init(conf); | ||
77 | conf->data = hash; | ||
78 | } | ||
79 | |||
80 | CONF * | ||
81 | NCONF_new(const CONF_METHOD *meth) | ||
82 | { | ||
83 | CONF *ret; | ||
84 | |||
85 | if (meth == NULL) | ||
86 | meth = NCONF_default(); | ||
87 | |||
88 | ret = meth->create(meth); | ||
89 | if (ret == NULL) { | ||
90 | CONFerror(ERR_R_MALLOC_FAILURE); | ||
91 | return (NULL); | ||
92 | } | ||
93 | |||
94 | return ret; | ||
95 | } | ||
96 | LCRYPTO_ALIAS(NCONF_new); | ||
97 | |||
98 | void | ||
99 | NCONF_free(CONF *conf) | ||
100 | { | ||
101 | if (conf == NULL) | ||
102 | return; | ||
103 | conf->meth->destroy(conf); | ||
104 | } | ||
105 | LCRYPTO_ALIAS(NCONF_free); | ||
106 | |||
107 | int | ||
108 | NCONF_load(CONF *conf, const char *file, long *eline) | ||
109 | { | ||
110 | if (conf == NULL) { | ||
111 | CONFerror(CONF_R_NO_CONF); | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | return conf->meth->load(conf, file, eline); | ||
116 | } | ||
117 | LCRYPTO_ALIAS(NCONF_load); | ||
118 | |||
119 | int | ||
120 | NCONF_load_bio(CONF *conf, BIO *bp, long *eline) | ||
121 | { | ||
122 | if (conf == NULL) { | ||
123 | CONFerror(CONF_R_NO_CONF); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | return conf->meth->load_bio(conf, bp, eline); | ||
128 | } | ||
129 | LCRYPTO_ALIAS(NCONF_load_bio); | ||
130 | |||
131 | STACK_OF(CONF_VALUE) * | ||
132 | NCONF_get_section(const CONF *conf, const char *section) | ||
133 | { | ||
134 | CONF_VALUE *v; | ||
135 | |||
136 | if (conf == NULL) { | ||
137 | CONFerror(CONF_R_NO_CONF); | ||
138 | return NULL; | ||
139 | } | ||
140 | |||
141 | if (section == NULL) { | ||
142 | CONFerror(CONF_R_NO_SECTION); | ||
143 | return NULL; | ||
144 | } | ||
145 | |||
146 | if ((v = _CONF_get_section(conf, section)) == NULL) | ||
147 | return NULL; | ||
148 | |||
149 | return (STACK_OF(CONF_VALUE) *)v->value; | ||
150 | } | ||
151 | LCRYPTO_ALIAS(NCONF_get_section); | ||
152 | |||
153 | char * | ||
154 | NCONF_get_string(const CONF *conf, const char *group, const char *name) | ||
155 | { | ||
156 | char *s = _CONF_get_string(conf, group, name); | ||
157 | |||
158 | /* Since we may get a value from an environment variable even | ||
159 | if conf is NULL, let's check the value first */ | ||
160 | if (s) | ||
161 | return s; | ||
162 | |||
163 | if (conf == NULL) { | ||
164 | CONFerror(CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); | ||
165 | return NULL; | ||
166 | } | ||
167 | CONFerror(CONF_R_NO_VALUE); | ||
168 | ERR_asprintf_error_data("group=%s name=%s", | ||
169 | group ? group : "", name); | ||
170 | return NULL; | ||
171 | } | ||
172 | LCRYPTO_ALIAS(NCONF_get_string); | ||
173 | |||
174 | int | ||
175 | NCONF_get_number_e(const CONF *conf, const char *group, const char *name, | ||
176 | long *result) | ||
177 | { | ||
178 | char *str; | ||
179 | |||
180 | if (result == NULL) { | ||
181 | CONFerror(ERR_R_PASSED_NULL_PARAMETER); | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | str = NCONF_get_string(conf, group, name); | ||
186 | |||
187 | if (str == NULL) | ||
188 | return 0; | ||
189 | |||
190 | for (*result = 0; conf->meth->is_number(conf, *str); ) { | ||
191 | *result = (*result) * 10 + conf->meth->to_int(conf, *str); | ||
192 | str++; | ||
193 | } | ||
194 | |||
195 | return 1; | ||
196 | } | ||
197 | LCRYPTO_ALIAS(NCONF_get_number_e); | ||