1 /* $OpenBSD: conf.h,v 1.15 2020/02/17 12:51:48 inoguchi 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 core.stdc.config.c_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 module libressl_d.openssl.conf;
59 
60 
61 private static import core.stdc.config;
62 private static import libressl_d.compat.stdio;
63 public import libressl_d.openssl.bio;
64 public import libressl_d.openssl.lhash;
65 public import libressl_d.openssl.opensslconf;
66 public import libressl_d.openssl.ossl_typ;
67 public import libressl_d.openssl.safestack;
68 public import libressl_d.openssl.stack;
69 
70 enum HEADER_CONF_H = true;
71 
72 extern (C):
73 nothrow @nogc:
74 
75 struct CONF_VALUE
76 {
77 	char* section;
78 	char* name;
79 	char* value;
80 }
81 
82 //DECLARE_STACK_OF(CONF_VALUE)
83 struct stack_st_CONF_VALUE
84 {
85 	libressl_d.openssl.stack._STACK stack;
86 }
87 
88 //DECLARE_LHASH_OF(CONF_VALUE)
89 struct lhash_st_CONF_VALUE
90 {
91 	int dummy;
92 }
93 
94 alias CONF_METHOD = .conf_method_st;
95 
96 struct conf_method_st
97 {
98 	const (char)* name;
99 	libressl_d.openssl.ossl_typ.CONF* function(.CONF_METHOD* meth) create;
100 	int function(libressl_d.openssl.ossl_typ.CONF* conf) init;
101 	int function(libressl_d.openssl.ossl_typ.CONF* conf) destroy;
102 	int function(libressl_d.openssl.ossl_typ.CONF* conf) destroy_data;
103 	int function(libressl_d.openssl.ossl_typ.CONF* conf, libressl_d.openssl.bio.BIO* bp, core.stdc.config.c_long* eline) load_bio;
104 	int function(const (libressl_d.openssl.ossl_typ.CONF)* conf, libressl_d.openssl.bio.BIO* bp) dump;
105 	int function(const (libressl_d.openssl.ossl_typ.CONF)* conf, char c) is_number;
106 	int function(const (libressl_d.openssl.ossl_typ.CONF)* conf, char c) to_int;
107 	int function(libressl_d.openssl.ossl_typ.CONF* conf, const (char)* name, core.stdc.config.c_long* eline) load;
108 }
109 
110 /* Module definitions */
111 struct conf_imodule_st;
112 struct conf_module_st;
113 
114 alias CONF_IMODULE = .conf_imodule_st;
115 alias CONF_MODULE = .conf_module_st;
116 
117 //DECLARE_STACK_OF(CONF_MODULE)
118 struct stack_st_CONF_MODULE
119 {
120 	libressl_d.openssl.stack._STACK stack;
121 }
122 
123 //DECLARE_STACK_OF(CONF_IMODULE)
124 struct stack_st_CONF_IMODULE
125 {
126 	libressl_d.openssl.stack._STACK stack;
127 }
128 
129 /* DSO module function typedefs */
130 alias conf_init_func = extern (C) nothrow @nogc int function(.CONF_IMODULE* md, const (libressl_d.openssl.ossl_typ.CONF)* cnf);
131 alias conf_finish_func = extern (C) nothrow @nogc void function(.CONF_IMODULE* md);
132 
133 enum CONF_MFLAGS_IGNORE_ERRORS = 0x01;
134 enum CONF_MFLAGS_IGNORE_RETURN_CODES = 0x02;
135 enum CONF_MFLAGS_SILENT = 0x04;
136 enum CONF_MFLAGS_NO_DSO = 0x08;
137 enum CONF_MFLAGS_IGNORE_MISSING_FILE = 0x10;
138 enum CONF_MFLAGS_DEFAULT_SECTION = 0x20;
139 
140 int CONF_set_default_method(.CONF_METHOD* meth);
141 void CONF_set_nconf(libressl_d.openssl.ossl_typ.CONF* conf, .lhash_st_CONF_VALUE * hash);
142 .lhash_st_CONF_VALUE* CONF_load(.lhash_st_CONF_VALUE * conf, const (char)* file, core.stdc.config.c_long* eline);
143 .lhash_st_CONF_VALUE* CONF_load_fp(.lhash_st_CONF_VALUE * conf, libressl_d.compat.stdio.FILE* fp, core.stdc.config.c_long* eline);
144 .lhash_st_CONF_VALUE* CONF_load_bio(.lhash_st_CONF_VALUE * conf, libressl_d.openssl.bio.BIO* bp, core.stdc.config.c_long* eline);
145 .stack_st_CONF_VALUE* CONF_get_section(.lhash_st_CONF_VALUE * conf, const (char)* section);
146 char* CONF_get_string(.lhash_st_CONF_VALUE * conf, const (char)* group, const (char)* name);
147 core.stdc.config.c_long CONF_get_number(.lhash_st_CONF_VALUE * conf, const (char)* group, const (char)* name);
148 void CONF_free(.lhash_st_CONF_VALUE * conf);
149 int CONF_dump_fp(.lhash_st_CONF_VALUE * conf, libressl_d.compat.stdio.FILE* out_);
150 int CONF_dump_bio(.lhash_st_CONF_VALUE * conf, libressl_d.openssl.bio.BIO* out_);
151 
152 void OPENSSL_config(const (char)* config_name);
153 void OPENSSL_no_config();
154 
155 /**
156  * New conf code.  The semantics are different from the functions above.
157  * If that wasn't the case, the above functions would have been replaced
158  */
159 struct conf_st
160 {
161 	.CONF_METHOD* meth;
162 	void* meth_data;
163 	.lhash_st_CONF_VALUE* data;
164 }
165 
166 libressl_d.openssl.ossl_typ.CONF* NCONF_new(.CONF_METHOD* meth);
167 .CONF_METHOD* NCONF_default();
168 .CONF_METHOD* NCONF_WIN32();
169 void NCONF_free(libressl_d.openssl.ossl_typ.CONF* conf);
170 void NCONF_free_data(libressl_d.openssl.ossl_typ.CONF* conf);
171 
172 int NCONF_load(libressl_d.openssl.ossl_typ.CONF* conf, const (char)* file, core.stdc.config.c_long* eline);
173 int NCONF_load_fp(libressl_d.openssl.ossl_typ.CONF* conf, libressl_d.compat.stdio.FILE* fp, core.stdc.config.c_long* eline);
174 int NCONF_load_bio(libressl_d.openssl.ossl_typ.CONF* conf, libressl_d.openssl.bio.BIO* bp, core.stdc.config.c_long* eline);
175 .stack_st_CONF_VALUE* NCONF_get_section(const (libressl_d.openssl.ossl_typ.CONF)* conf, const (char)* section);
176 char* NCONF_get_string(const (libressl_d.openssl.ossl_typ.CONF)* conf, const (char)* group, const (char)* name);
177 int NCONF_get_number_e(const (libressl_d.openssl.ossl_typ.CONF)* conf, const (char)* group, const (char)* name, core.stdc.config.c_long* result);
178 int NCONF_dump_fp(const (libressl_d.openssl.ossl_typ.CONF)* conf, libressl_d.compat.stdio.FILE* out_);
179 int NCONF_dump_bio(const (libressl_d.openssl.ossl_typ.CONF)* conf, libressl_d.openssl.bio.BIO* out_);
180 
181 alias NCONF_get_number = .NCONF_get_number_e;
182 
183 /* Module functions */
184 
185 int CONF_modules_load(const (libressl_d.openssl.ossl_typ.CONF)* cnf, const (char)* appname, core.stdc.config.c_ulong flags);
186 int CONF_modules_load_file(const (char)* filename, const (char)* appname, core.stdc.config.c_ulong flags);
187 void CONF_modules_unload(int all);
188 void CONF_modules_finish();
189 void CONF_modules_free();
190 int CONF_module_add(const (char)* name, .conf_init_func* ifunc, .conf_finish_func* ffunc);
191 
192 const (char)* CONF_imodule_get_name(const (.CONF_IMODULE)* md);
193 const (char)* CONF_imodule_get_value(const (.CONF_IMODULE)* md);
194 void* CONF_imodule_get_usr_data(const (.CONF_IMODULE)* md);
195 void CONF_imodule_set_usr_data(.CONF_IMODULE* md, void* usr_data);
196 .CONF_MODULE* CONF_imodule_get_module(const (.CONF_IMODULE)* md);
197 core.stdc.config.c_ulong CONF_imodule_get_flags(const (.CONF_IMODULE)* md);
198 void CONF_imodule_set_flags(.CONF_IMODULE* md, core.stdc.config.c_ulong flags);
199 void* CONF_module_get_usr_data(.CONF_MODULE* pmod);
200 void CONF_module_set_usr_data(.CONF_MODULE* pmod, void* usr_data);
201 
202 char* CONF_get1_default_config_file();
203 
204 int CONF_parse_list(const (char)* list, int sep, int nospc, int function(const (char)* elem, int len, void* usr) list_cb, void* arg);
205 
206 void OPENSSL_load_builtin_modules();
207 
208 /* BEGIN ERROR CODES */
209 /*
210  * The following lines are auto generated by the script mkerr.pl. Any changes
211  * made after this point may be overwritten when the script is next run.
212  */
213 void ERR_load_CONF_strings();
214 
215 /* Error codes for the CONF functions. */
216 
217 /* Function codes. */
218 enum CONF_F_CONF_DUMP_FP = 104;
219 enum CONF_F_CONF_LOAD = 100;
220 enum CONF_F_CONF_LOAD_BIO = 102;
221 enum CONF_F_CONF_LOAD_FP = 103;
222 enum CONF_F_CONF_MODULES_LOAD = 116;
223 enum CONF_F_CONF_PARSE_LIST = 119;
224 enum CONF_F_DEF_LOAD = 120;
225 enum CONF_F_DEF_LOAD_BIO = 121;
226 enum CONF_F_MODULE_INIT = 115;
227 enum CONF_F_MODULE_LOAD_DSO = 117;
228 enum CONF_F_MODULE_RUN = 118;
229 enum CONF_F_NCONF_DUMP_BIO = 105;
230 enum CONF_F_NCONF_DUMP_FP = 106;
231 enum CONF_F_NCONF_GET_NUMBER = 107;
232 enum CONF_F_NCONF_GET_NUMBER_E = 112;
233 enum CONF_F_NCONF_GET_SECTION = 108;
234 enum CONF_F_NCONF_GET_STRING = 109;
235 enum CONF_F_NCONF_LOAD = 113;
236 enum CONF_F_NCONF_LOAD_BIO = 110;
237 enum CONF_F_NCONF_LOAD_FP = 114;
238 enum CONF_F_NCONF_NEW = 111;
239 enum CONF_F_STR_COPY = 101;
240 
241 /* Reason codes. */
242 enum CONF_R_ERROR_LOADING_DSO = 110;
243 enum CONF_R_LIST_CANNOT_BE_NULL = 115;
244 enum CONF_R_MISSING_CLOSE_SQUARE_BRACKET = 100;
245 enum CONF_R_MISSING_EQUAL_SIGN = 101;
246 enum CONF_R_MISSING_FINISH_FUNCTION = 111;
247 enum CONF_R_MISSING_INIT_FUNCTION = 112;
248 enum CONF_R_MODULE_INITIALIZATION_ERROR = 109;
249 enum CONF_R_NO_CLOSE_BRACE = 102;
250 enum CONF_R_NO_CONF = 105;
251 enum CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE = 106;
252 enum CONF_R_NO_SECTION = 107;
253 enum CONF_R_NO_SUCH_FILE = 114;
254 enum CONF_R_NO_VALUE = 108;
255 enum CONF_R_UNABLE_TO_CREATE_NEW_SECTION = 103;
256 enum CONF_R_UNKNOWN_MODULE_NAME = 113;
257 enum CONF_R_VARIABLE_EXPANSION_TOO_LONG = 116;
258 enum CONF_R_VARIABLE_HAS_NO_VALUE = 104;