xref: /onnv-gate/usr/src/common/openssl/crypto/conf/conf.h (revision 2139:6243c3338933)
10Sstevel@tonic-gate /* crypto/conf/conf.h */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate  * All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * This package is an SSL implementation written
60Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
110Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
130Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate  * the code are not to be removed.
180Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate  * as the author of the parts of the library used.
200Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate  *
230Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate  * are met:
260Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate  *    must display the following acknowledgement:
330Sstevel@tonic-gate  *    "This product includes cryptographic software written by
340Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate  *    being used are not cryptographic related :-).
370Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate  * SUCH DAMAGE.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
550Sstevel@tonic-gate  * copied and put under another distribution licence
560Sstevel@tonic-gate  * [including the GNU Public Licence.]
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #ifndef  HEADER_CONF_H
600Sstevel@tonic-gate #define HEADER_CONF_H
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #include <openssl/bio.h>
630Sstevel@tonic-gate #include <openssl/lhash.h>
640Sstevel@tonic-gate #include <openssl/stack.h>
650Sstevel@tonic-gate #include <openssl/safestack.h>
660Sstevel@tonic-gate #include <openssl/e_os2.h>
670Sstevel@tonic-gate 
68*2139Sjp161948 #include <openssl/ossl_typ.h>
69*2139Sjp161948 
700Sstevel@tonic-gate #ifdef  __cplusplus
710Sstevel@tonic-gate extern "C" {
720Sstevel@tonic-gate #endif
730Sstevel@tonic-gate 
740Sstevel@tonic-gate typedef struct
750Sstevel@tonic-gate 	{
760Sstevel@tonic-gate 	char *section;
770Sstevel@tonic-gate 	char *name;
780Sstevel@tonic-gate 	char *value;
790Sstevel@tonic-gate 	} CONF_VALUE;
800Sstevel@tonic-gate 
810Sstevel@tonic-gate DECLARE_STACK_OF(CONF_VALUE)
820Sstevel@tonic-gate DECLARE_STACK_OF(CONF_MODULE)
830Sstevel@tonic-gate DECLARE_STACK_OF(CONF_IMODULE)
840Sstevel@tonic-gate 
850Sstevel@tonic-gate struct conf_st;
860Sstevel@tonic-gate struct conf_method_st;
870Sstevel@tonic-gate typedef struct conf_method_st CONF_METHOD;
880Sstevel@tonic-gate 
890Sstevel@tonic-gate struct conf_method_st
900Sstevel@tonic-gate 	{
910Sstevel@tonic-gate 	const char *name;
920Sstevel@tonic-gate 	CONF *(*create)(CONF_METHOD *meth);
930Sstevel@tonic-gate 	int (*init)(CONF *conf);
940Sstevel@tonic-gate 	int (*destroy)(CONF *conf);
950Sstevel@tonic-gate 	int (*destroy_data)(CONF *conf);
960Sstevel@tonic-gate 	int (*load_bio)(CONF *conf, BIO *bp, long *eline);
970Sstevel@tonic-gate 	int (*dump)(const CONF *conf, BIO *bp);
980Sstevel@tonic-gate 	int (*is_number)(const CONF *conf, char c);
990Sstevel@tonic-gate 	int (*to_int)(const CONF *conf, char c);
1000Sstevel@tonic-gate 	int (*load)(CONF *conf, const char *name, long *eline);
1010Sstevel@tonic-gate 	};
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate /* Module definitions */
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate typedef struct conf_imodule_st CONF_IMODULE;
1060Sstevel@tonic-gate typedef struct conf_module_st CONF_MODULE;
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /* DSO module function typedefs */
1090Sstevel@tonic-gate typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf);
1100Sstevel@tonic-gate typedef void conf_finish_func(CONF_IMODULE *md);
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate #define	CONF_MFLAGS_IGNORE_ERRORS	0x1
1130Sstevel@tonic-gate #define CONF_MFLAGS_IGNORE_RETURN_CODES	0x2
1140Sstevel@tonic-gate #define CONF_MFLAGS_SILENT		0x4
1150Sstevel@tonic-gate #define CONF_MFLAGS_NO_DSO		0x8
1160Sstevel@tonic-gate #define CONF_MFLAGS_IGNORE_MISSING_FILE	0x10
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate int CONF_set_default_method(CONF_METHOD *meth);
1190Sstevel@tonic-gate void CONF_set_nconf(CONF *conf,LHASH *hash);
1200Sstevel@tonic-gate LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
1210Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
1220Sstevel@tonic-gate LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
1230Sstevel@tonic-gate #endif
1240Sstevel@tonic-gate LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
1250Sstevel@tonic-gate STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section);
1260Sstevel@tonic-gate char *CONF_get_string(LHASH *conf,const char *group,const char *name);
1270Sstevel@tonic-gate long CONF_get_number(LHASH *conf,const char *group,const char *name);
1280Sstevel@tonic-gate void CONF_free(LHASH *conf);
1290Sstevel@tonic-gate int CONF_dump_fp(LHASH *conf, FILE *out);
1300Sstevel@tonic-gate int CONF_dump_bio(LHASH *conf, BIO *out);
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate void OPENSSL_config(const char *config_name);
1330Sstevel@tonic-gate void OPENSSL_no_config(void);
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate /* New conf code.  The semantics are different from the functions above.
1360Sstevel@tonic-gate    If that wasn't the case, the above functions would have been replaced */
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate struct conf_st
1390Sstevel@tonic-gate 	{
1400Sstevel@tonic-gate 	CONF_METHOD *meth;
1410Sstevel@tonic-gate 	void *meth_data;
1420Sstevel@tonic-gate 	LHASH *data;
1430Sstevel@tonic-gate 	};
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate CONF *NCONF_new(CONF_METHOD *meth);
1460Sstevel@tonic-gate CONF_METHOD *NCONF_default(void);
1470Sstevel@tonic-gate CONF_METHOD *NCONF_WIN32(void);
1480Sstevel@tonic-gate #if 0 /* Just to give you an idea of what I have in mind */
1490Sstevel@tonic-gate CONF_METHOD *NCONF_XML(void);
1500Sstevel@tonic-gate #endif
1510Sstevel@tonic-gate void NCONF_free(CONF *conf);
1520Sstevel@tonic-gate void NCONF_free_data(CONF *conf);
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate int NCONF_load(CONF *conf,const char *file,long *eline);
1550Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
1560Sstevel@tonic-gate int NCONF_load_fp(CONF *conf, FILE *fp,long *eline);
1570Sstevel@tonic-gate #endif
1580Sstevel@tonic-gate int NCONF_load_bio(CONF *conf, BIO *bp,long *eline);
1590Sstevel@tonic-gate STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section);
1600Sstevel@tonic-gate char *NCONF_get_string(const CONF *conf,const char *group,const char *name);
1610Sstevel@tonic-gate int NCONF_get_number_e(const CONF *conf,const char *group,const char *name,
1620Sstevel@tonic-gate 		       long *result);
1630Sstevel@tonic-gate int NCONF_dump_fp(const CONF *conf, FILE *out);
1640Sstevel@tonic-gate int NCONF_dump_bio(const CONF *conf, BIO *out);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate #if 0 /* The following function has no error checking,
1670Sstevel@tonic-gate 	 and should therefore be avoided */
1680Sstevel@tonic-gate long NCONF_get_number(CONF *conf,char *group,char *name);
1690Sstevel@tonic-gate #else
1700Sstevel@tonic-gate #define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
1710Sstevel@tonic-gate #endif
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate /* Module functions */
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate int CONF_modules_load(const CONF *cnf, const char *appname,
1760Sstevel@tonic-gate 		      unsigned long flags);
1770Sstevel@tonic-gate int CONF_modules_load_file(const char *filename, const char *appname,
1780Sstevel@tonic-gate 			   unsigned long flags);
1790Sstevel@tonic-gate void CONF_modules_unload(int all);
1800Sstevel@tonic-gate void CONF_modules_finish(void);
1810Sstevel@tonic-gate void CONF_modules_free(void);
1820Sstevel@tonic-gate int CONF_module_add(const char *name, conf_init_func *ifunc,
1830Sstevel@tonic-gate 		    conf_finish_func *ffunc);
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate const char *CONF_imodule_get_name(const CONF_IMODULE *md);
1860Sstevel@tonic-gate const char *CONF_imodule_get_value(const CONF_IMODULE *md);
1870Sstevel@tonic-gate void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
1880Sstevel@tonic-gate void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
1890Sstevel@tonic-gate CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
1900Sstevel@tonic-gate unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
1910Sstevel@tonic-gate void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
1920Sstevel@tonic-gate void *CONF_module_get_usr_data(CONF_MODULE *pmod);
1930Sstevel@tonic-gate void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate char *CONF_get1_default_config_file(void);
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate int CONF_parse_list(const char *list, int sep, int nospc,
1980Sstevel@tonic-gate 	int (*list_cb)(const char *elem, int len, void *usr), void *arg);
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate void OPENSSL_load_builtin_modules(void);
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate /* BEGIN ERROR CODES */
2030Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes
2040Sstevel@tonic-gate  * made after this point may be overwritten when the script is next run.
2050Sstevel@tonic-gate  */
2060Sstevel@tonic-gate void ERR_load_CONF_strings(void);
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate /* Error codes for the CONF functions. */
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate /* Function codes. */
2110Sstevel@tonic-gate #define CONF_F_CONF_DUMP_FP				 104
2120Sstevel@tonic-gate #define CONF_F_CONF_LOAD				 100
2130Sstevel@tonic-gate #define CONF_F_CONF_LOAD_BIO				 102
2140Sstevel@tonic-gate #define CONF_F_CONF_LOAD_FP				 103
2150Sstevel@tonic-gate #define CONF_F_CONF_MODULES_LOAD			 116
216*2139Sjp161948 #define CONF_F_DEF_LOAD					 120
217*2139Sjp161948 #define CONF_F_DEF_LOAD_BIO				 121
2180Sstevel@tonic-gate #define CONF_F_MODULE_INIT				 115
2190Sstevel@tonic-gate #define CONF_F_MODULE_LOAD_DSO				 117
2200Sstevel@tonic-gate #define CONF_F_MODULE_RUN				 118
2210Sstevel@tonic-gate #define CONF_F_NCONF_DUMP_BIO				 105
2220Sstevel@tonic-gate #define CONF_F_NCONF_DUMP_FP				 106
2230Sstevel@tonic-gate #define CONF_F_NCONF_GET_NUMBER				 107
2240Sstevel@tonic-gate #define CONF_F_NCONF_GET_NUMBER_E			 112
2250Sstevel@tonic-gate #define CONF_F_NCONF_GET_SECTION			 108
2260Sstevel@tonic-gate #define CONF_F_NCONF_GET_STRING				 109
2270Sstevel@tonic-gate #define CONF_F_NCONF_LOAD				 113
2280Sstevel@tonic-gate #define CONF_F_NCONF_LOAD_BIO				 110
2290Sstevel@tonic-gate #define CONF_F_NCONF_LOAD_FP				 114
2300Sstevel@tonic-gate #define CONF_F_NCONF_NEW				 111
2310Sstevel@tonic-gate #define CONF_F_STR_COPY					 101
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate /* Reason codes. */
2340Sstevel@tonic-gate #define CONF_R_ERROR_LOADING_DSO			 110
2350Sstevel@tonic-gate #define CONF_R_MISSING_CLOSE_SQUARE_BRACKET		 100
2360Sstevel@tonic-gate #define CONF_R_MISSING_EQUAL_SIGN			 101
2370Sstevel@tonic-gate #define CONF_R_MISSING_FINISH_FUNCTION			 111
2380Sstevel@tonic-gate #define CONF_R_MISSING_INIT_FUNCTION			 112
2390Sstevel@tonic-gate #define CONF_R_MODULE_INITIALIZATION_ERROR		 109
2400Sstevel@tonic-gate #define CONF_R_NO_CLOSE_BRACE				 102
2410Sstevel@tonic-gate #define CONF_R_NO_CONF					 105
2420Sstevel@tonic-gate #define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE		 106
2430Sstevel@tonic-gate #define CONF_R_NO_SECTION				 107
2440Sstevel@tonic-gate #define CONF_R_NO_SUCH_FILE				 114
2450Sstevel@tonic-gate #define CONF_R_NO_VALUE					 108
2460Sstevel@tonic-gate #define CONF_R_UNABLE_TO_CREATE_NEW_SECTION		 103
2470Sstevel@tonic-gate #define CONF_R_UNKNOWN_MODULE_NAME			 113
2480Sstevel@tonic-gate #define CONF_R_VARIABLE_HAS_NO_VALUE			 104
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate #ifdef  __cplusplus
2510Sstevel@tonic-gate }
2520Sstevel@tonic-gate #endif
2530Sstevel@tonic-gate #endif
254