diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/conf/conf_api.c | 261 |
1 files changed, 0 insertions, 261 deletions
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c deleted file mode 100644 index f986243b65..0000000000 --- a/src/lib/libcrypto/conf/conf_api.c +++ /dev/null | |||
@@ -1,261 +0,0 @@ | |||
1 | /* $OpenBSD: conf_api.c,v 1.26 2025/03/08 09:35:53 tb Exp $ */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | /* Part of the code in here was originally in conf.c, which is now removed */ | ||
60 | |||
61 | #ifndef CONF_DEBUG | ||
62 | # undef NDEBUG /* avoid conflicting definitions */ | ||
63 | # define NDEBUG | ||
64 | #endif | ||
65 | |||
66 | #include <stdlib.h> | ||
67 | #include <string.h> | ||
68 | #include <unistd.h> | ||
69 | #include <openssl/conf.h> | ||
70 | |||
71 | #include "conf_local.h" | ||
72 | |||
73 | static void value_free_hash_doall_arg(CONF_VALUE *a, | ||
74 | LHASH_OF(CONF_VALUE) *conf); | ||
75 | static void value_free_stack_doall(CONF_VALUE *a); | ||
76 | static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE, | ||
77 | LHASH_OF(CONF_VALUE)) | ||
78 | static IMPLEMENT_LHASH_DOALL_FN(value_free_stack, CONF_VALUE) | ||
79 | |||
80 | /* Up until OpenSSL 0.9.5a, this was get_section */ | ||
81 | CONF_VALUE * | ||
82 | _CONF_get_section(const CONF *conf, const char *section) | ||
83 | { | ||
84 | CONF_VALUE *v, vv; | ||
85 | |||
86 | if ((conf == NULL) || (section == NULL)) | ||
87 | return (NULL); | ||
88 | vv.name = NULL; | ||
89 | vv.section = (char *)section; | ||
90 | v = lh_CONF_VALUE_retrieve(conf->data, &vv); | ||
91 | return (v); | ||
92 | } | ||
93 | |||
94 | int | ||
95 | _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value) | ||
96 | { | ||
97 | CONF_VALUE *v = NULL; | ||
98 | STACK_OF(CONF_VALUE) *ts; | ||
99 | |||
100 | ts = (STACK_OF(CONF_VALUE) *)section->value; | ||
101 | |||
102 | value->section = section->section; | ||
103 | if (!sk_CONF_VALUE_push(ts, value)) { | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | v = lh_CONF_VALUE_insert(conf->data, value); | ||
108 | if (v != NULL) { | ||
109 | (void)sk_CONF_VALUE_delete_ptr(ts, v); | ||
110 | free(v->name); | ||
111 | free(v->value); | ||
112 | free(v); | ||
113 | } | ||
114 | return 1; | ||
115 | } | ||
116 | |||
117 | char * | ||
118 | _CONF_get_string(const CONF *conf, const char *section, const char *name) | ||
119 | { | ||
120 | CONF_VALUE *v, vv; | ||
121 | |||
122 | if (name == NULL) | ||
123 | return (NULL); | ||
124 | if (conf != NULL) { | ||
125 | if (section != NULL) { | ||
126 | vv.name = (char *)name; | ||
127 | vv.section = (char *)section; | ||
128 | v = lh_CONF_VALUE_retrieve(conf->data, &vv); | ||
129 | if (v != NULL) | ||
130 | return (v->value); | ||
131 | } | ||
132 | vv.section = "default"; | ||
133 | vv.name = (char *)name; | ||
134 | v = lh_CONF_VALUE_retrieve(conf->data, &vv); | ||
135 | if (v != NULL) | ||
136 | return (v->value); | ||
137 | else | ||
138 | return (NULL); | ||
139 | } else | ||
140 | return (NULL); | ||
141 | } | ||
142 | |||
143 | static unsigned long | ||
144 | conf_value_hash(const CONF_VALUE *v) | ||
145 | { | ||
146 | return (lh_strhash(v->section) << 2) ^ lh_strhash(v->name); | ||
147 | } | ||
148 | |||
149 | static IMPLEMENT_LHASH_HASH_FN(conf_value, CONF_VALUE) | ||
150 | |||
151 | static int | ||
152 | conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b) | ||
153 | { | ||
154 | int i; | ||
155 | |||
156 | if (a->section != b->section) { | ||
157 | i = strcmp(a->section, b->section); | ||
158 | if (i) | ||
159 | return (i); | ||
160 | } | ||
161 | if ((a->name != NULL) && (b->name != NULL)) { | ||
162 | i = strcmp(a->name, b->name); | ||
163 | return (i); | ||
164 | } else if (a->name == b->name) | ||
165 | return (0); | ||
166 | else | ||
167 | return ((a->name == NULL)?-1 : 1); | ||
168 | } | ||
169 | |||
170 | static IMPLEMENT_LHASH_COMP_FN(conf_value, CONF_VALUE) | ||
171 | |||
172 | int | ||
173 | _CONF_new_data(CONF *conf) | ||
174 | { | ||
175 | if (conf == NULL) { | ||
176 | return 0; | ||
177 | } | ||
178 | if (conf->data == NULL) | ||
179 | if ((conf->data = lh_CONF_VALUE_new()) == NULL) { | ||
180 | return 0; | ||
181 | } | ||
182 | return 1; | ||
183 | } | ||
184 | |||
185 | void | ||
186 | _CONF_free_data(CONF *conf) | ||
187 | { | ||
188 | if (conf == NULL || conf->data == NULL) | ||
189 | return; | ||
190 | |||
191 | lh_CONF_VALUE_doall_arg(conf->data, | ||
192 | LHASH_DOALL_ARG_FN(value_free_hash), | ||
193 | LHASH_OF(CONF_VALUE), conf->data); | ||
194 | |||
195 | /* We now have only 'section' entries in the hash table. | ||
196 | * Due to problems with */ | ||
197 | |||
198 | lh_CONF_VALUE_doall(conf->data, LHASH_DOALL_FN(value_free_stack)); | ||
199 | lh_CONF_VALUE_free(conf->data); | ||
200 | } | ||
201 | |||
202 | static void | ||
203 | value_free_hash_doall_arg(CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf) | ||
204 | { | ||
205 | if (a->name != NULL) | ||
206 | (void)lh_CONF_VALUE_delete(conf, a); | ||
207 | } | ||
208 | |||
209 | static void | ||
210 | value_free_stack_doall(CONF_VALUE *a) | ||
211 | { | ||
212 | CONF_VALUE *vv; | ||
213 | STACK_OF(CONF_VALUE) *sk; | ||
214 | int i; | ||
215 | |||
216 | if (a->name != NULL) | ||
217 | return; | ||
218 | |||
219 | sk = (STACK_OF(CONF_VALUE) *)a->value; | ||
220 | for (i = sk_CONF_VALUE_num(sk) - 1; i >= 0; i--) { | ||
221 | vv = sk_CONF_VALUE_value(sk, i); | ||
222 | free(vv->value); | ||
223 | free(vv->name); | ||
224 | free(vv); | ||
225 | } | ||
226 | if (sk != NULL) | ||
227 | sk_CONF_VALUE_free(sk); | ||
228 | free(a->section); | ||
229 | free(a); | ||
230 | } | ||
231 | |||
232 | /* Up until OpenSSL 0.9.5a, this was new_section */ | ||
233 | CONF_VALUE * | ||
234 | _CONF_new_section(CONF *conf, const char *section) | ||
235 | { | ||
236 | STACK_OF(CONF_VALUE) *sk = NULL; | ||
237 | CONF_VALUE *v = NULL, *vv; | ||
238 | |||
239 | if ((sk = sk_CONF_VALUE_new_null()) == NULL) | ||
240 | goto err; | ||
241 | if ((v = calloc(1, sizeof(*v))) == NULL) | ||
242 | goto err; | ||
243 | if ((v->section = strdup(section)) == NULL) | ||
244 | goto err; | ||
245 | v->value = (char *)sk; | ||
246 | |||
247 | vv = lh_CONF_VALUE_insert(conf->data, v); | ||
248 | OPENSSL_assert(vv == NULL); | ||
249 | if (lh_CONF_VALUE_error(conf->data)) | ||
250 | goto err; | ||
251 | |||
252 | return v; | ||
253 | |||
254 | err: | ||
255 | sk_CONF_VALUE_free(sk); | ||
256 | if (v != NULL) | ||
257 | free(v->section); | ||
258 | free(v); | ||
259 | |||
260 | return NULL; | ||
261 | } | ||