diff options
Diffstat (limited to 'src/lib/libcrypto/conf')
| -rw-r--r-- | src/lib/libcrypto/conf/Makefile.ssl | 161 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/README | 78 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf.h | 248 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_api.c | 308 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_api.h | 89 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_def.c | 738 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_def.h | 180 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_err.c | 126 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_lib.c | 400 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_mall.c | 76 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_mod.c | 616 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/conf_sap.c | 107 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/keysets.pl | 185 | ||||
| -rw-r--r-- | src/lib/libcrypto/conf/ssleay.cnf | 78 |
14 files changed, 3390 insertions, 0 deletions
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl new file mode 100644 index 0000000000..d7489c87a2 --- /dev/null +++ b/src/lib/libcrypto/conf/Makefile.ssl | |||
| @@ -0,0 +1,161 @@ | |||
| 1 | # | ||
| 2 | # SSLeay/crypto/conf/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= conf | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 12 | INSTALLTOP=/usr/local/ssl | ||
| 13 | MAKE= make -f Makefile.ssl | ||
| 14 | MAKEDEPPROG= makedepend | ||
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 16 | MAKEFILE= Makefile.ssl | ||
| 17 | AR= ar r | ||
| 18 | |||
| 19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 20 | |||
| 21 | GENERAL=Makefile | ||
| 22 | TEST= | ||
| 23 | APPS= | ||
| 24 | |||
| 25 | LIB=$(TOP)/libcrypto.a | ||
| 26 | LIBSRC= conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c \ | ||
| 27 | conf_mall.c conf_sap.c | ||
| 28 | |||
| 29 | LIBOBJ= conf_err.o conf_lib.o conf_api.o conf_def.o conf_mod.o \ | ||
| 30 | conf_mall.o conf_sap.o | ||
| 31 | |||
| 32 | SRC= $(LIBSRC) | ||
| 33 | |||
| 34 | EXHEADER= conf.h conf_api.h | ||
| 35 | HEADER= conf_def.h $(EXHEADER) | ||
| 36 | |||
| 37 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 38 | |||
| 39 | top: | ||
| 40 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 41 | |||
| 42 | all: lib | ||
| 43 | |||
| 44 | lib: $(LIBOBJ) | ||
| 45 | $(AR) $(LIB) $(LIBOBJ) | ||
| 46 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 47 | @touch lib | ||
| 48 | |||
| 49 | files: | ||
| 50 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 51 | |||
| 52 | links: | ||
| 53 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
| 54 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 55 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 56 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
| 57 | |||
| 58 | install: | ||
| 59 | @for i in $(EXHEADER) ; \ | ||
| 60 | do \ | ||
| 61 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 62 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 63 | done; | ||
| 64 | |||
| 65 | tags: | ||
| 66 | ctags $(SRC) | ||
| 67 | |||
| 68 | tests: | ||
| 69 | |||
| 70 | lint: | ||
| 71 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 72 | |||
| 73 | depend: | ||
| 74 | $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(LIBSRC) | ||
| 75 | |||
| 76 | dclean: | ||
| 77 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 78 | mv -f Makefile.new $(MAKEFILE) | ||
| 79 | |||
| 80 | clean: | ||
| 81 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 82 | |||
| 83 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 84 | |||
| 85 | conf_api.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 86 | conf_api.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h | ||
| 87 | conf_api.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 88 | conf_api.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 89 | conf_api.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 90 | conf_api.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 91 | conf_api.o: conf_api.c | ||
| 92 | conf_def.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 93 | conf_def.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h | ||
| 94 | conf_def.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 95 | conf_def.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 96 | conf_def.o: ../../include/openssl/opensslconf.h | ||
| 97 | conf_def.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 98 | conf_def.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 99 | conf_def.o: conf_def.c conf_def.h | ||
| 100 | conf_err.o: ../../include/openssl/bio.h ../../include/openssl/conf.h | ||
| 101 | conf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 102 | conf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 103 | conf_err.o: ../../include/openssl/opensslconf.h | ||
| 104 | conf_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 105 | conf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 106 | conf_err.o: conf_err.c | ||
| 107 | conf_lib.o: ../../include/openssl/bio.h ../../include/openssl/conf.h | ||
| 108 | conf_lib.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h | ||
| 109 | conf_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 110 | conf_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 111 | conf_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 112 | conf_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 113 | conf_lib.o: conf_lib.c | ||
| 114 | conf_mall.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 115 | conf_mall.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 116 | conf_mall.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 117 | conf_mall.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 118 | conf_mall.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h | ||
| 119 | conf_mall.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 120 | conf_mall.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 121 | conf_mall.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 122 | conf_mall.o: ../../include/openssl/objects.h | ||
| 123 | conf_mall.o: ../../include/openssl/opensslconf.h | ||
| 124 | conf_mall.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 125 | conf_mall.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 126 | conf_mall.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 127 | conf_mall.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 128 | conf_mall.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 129 | conf_mall.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 130 | conf_mall.o: ../cryptlib.h conf_mall.c | ||
| 131 | conf_mod.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 132 | conf_mod.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 133 | conf_mod.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 134 | conf_mod.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 135 | conf_mod.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h | ||
| 136 | conf_mod.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 137 | conf_mod.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 138 | conf_mod.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 139 | conf_mod.o: ../../include/openssl/opensslconf.h | ||
| 140 | conf_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 141 | conf_mod.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 142 | conf_mod.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 143 | conf_mod.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 144 | conf_mod.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 145 | conf_mod.o: ../cryptlib.h conf_mod.c | ||
| 146 | conf_sap.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 147 | conf_sap.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 148 | conf_sap.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 149 | conf_sap.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 150 | conf_sap.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h | ||
| 151 | conf_sap.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 152 | conf_sap.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 153 | conf_sap.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 154 | conf_sap.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 155 | conf_sap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 156 | conf_sap.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 157 | conf_sap.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 158 | conf_sap.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 159 | conf_sap.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 160 | conf_sap.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 161 | conf_sap.o: ../cryptlib.h conf_sap.c | ||
diff --git a/src/lib/libcrypto/conf/README b/src/lib/libcrypto/conf/README new file mode 100644 index 0000000000..ca58d0240f --- /dev/null +++ b/src/lib/libcrypto/conf/README | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | WARNING WARNING WARNING!!! | ||
| 2 | |||
| 3 | This stuff is experimental, may change radically or be deleted altogether | ||
| 4 | before OpenSSL 0.9.7 release. You have been warned! | ||
| 5 | |||
| 6 | Configuration modules. These are a set of modules which can perform | ||
| 7 | various configuration functions. | ||
| 8 | |||
| 9 | Currently the routines should be called at most once when an application | ||
| 10 | starts up: that is before it starts any threads. | ||
| 11 | |||
| 12 | The routines read a configuration file set up like this: | ||
| 13 | |||
| 14 | ----- | ||
| 15 | #default section | ||
| 16 | openssl_init=init_section | ||
| 17 | |||
| 18 | [init_section] | ||
| 19 | |||
| 20 | module1=value1 | ||
| 21 | #Second instance of module1 | ||
| 22 | module1.1=valueX | ||
| 23 | module2=value2 | ||
| 24 | module3=dso_literal | ||
| 25 | module4=dso_section | ||
| 26 | |||
| 27 | [dso_section] | ||
| 28 | |||
| 29 | path=/some/path/to/some/dso.so | ||
| 30 | other_stuff=other_value | ||
| 31 | ---- | ||
| 32 | |||
| 33 | When this file is loaded a configuration module with the specified | ||
| 34 | string (module* in the above example) is looked up and its init | ||
| 35 | function called as: | ||
| 36 | |||
| 37 | int conf_init_func(CONF_IMODULE *md, CONF *cnf); | ||
| 38 | |||
| 39 | The function can then take whatever action is appropriate, for example | ||
| 40 | further lookups based on the value. Multiple instances of the same | ||
| 41 | config module can be loaded. | ||
| 42 | |||
| 43 | When the application closes down the modules are cleaned up by calling | ||
| 44 | an optional finish function: | ||
| 45 | |||
| 46 | void conf_finish_func(CONF_IMODULE *md); | ||
| 47 | |||
| 48 | The finish functions are called in reverse order: that is the last module | ||
| 49 | loaded is the first one cleaned up. | ||
| 50 | |||
| 51 | If no module exists with a given name then an attempt is made to load | ||
| 52 | a DSO with the supplied name. This might mean that "module3" attempts | ||
| 53 | to load a DSO called libmodule3.so or module3.dll for example. An explicit | ||
| 54 | DSO name can be given by including a separate section as in the module4 example | ||
| 55 | above. | ||
| 56 | |||
| 57 | The DSO is expected to at least contain an initialization function: | ||
| 58 | |||
| 59 | int OPENSSL_init(CONF_IMODULE *md, CONF *cnf); | ||
| 60 | |||
| 61 | and may also include a finish function: | ||
| 62 | |||
| 63 | void OPENSSL_finish(CONF_IMODULE *md); | ||
| 64 | |||
| 65 | Static modules can also be added using, | ||
| 66 | |||
| 67 | int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func *ffunc); | ||
| 68 | |||
| 69 | where "name" is the name in the configuration file this function corresponds to. | ||
| 70 | |||
| 71 | A set of builtin modules (currently only an ASN1 non functional test module) can be | ||
| 72 | added by calling OPENSSL_load_builtin_modules(). | ||
| 73 | |||
| 74 | The function OPENSSL_config() is intended as a simple configuration function that | ||
| 75 | any application can call to perform various default configuration tasks. It uses the | ||
| 76 | file openssl.cnf in the usual locations. | ||
| 77 | |||
| 78 | |||
diff --git a/src/lib/libcrypto/conf/conf.h b/src/lib/libcrypto/conf/conf.h new file mode 100644 index 0000000000..3c03fb19c0 --- /dev/null +++ b/src/lib/libcrypto/conf/conf.h | |||
| @@ -0,0 +1,248 @@ | |||
| 1 | /* crypto/conf/conf.h */ | ||
| 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 | #ifndef HEADER_CONF_H | ||
| 60 | #define HEADER_CONF_H | ||
| 61 | |||
| 62 | #include <openssl/bio.h> | ||
| 63 | #include <openssl/lhash.h> | ||
| 64 | #include <openssl/stack.h> | ||
| 65 | #include <openssl/safestack.h> | ||
| 66 | #include <openssl/e_os2.h> | ||
| 67 | |||
| 68 | #ifdef __cplusplus | ||
| 69 | extern "C" { | ||
| 70 | #endif | ||
| 71 | |||
| 72 | typedef struct | ||
| 73 | { | ||
| 74 | char *section; | ||
| 75 | char *name; | ||
| 76 | char *value; | ||
| 77 | } CONF_VALUE; | ||
| 78 | |||
| 79 | DECLARE_STACK_OF(CONF_VALUE) | ||
| 80 | DECLARE_STACK_OF(CONF_MODULE) | ||
| 81 | DECLARE_STACK_OF(CONF_IMODULE) | ||
| 82 | |||
| 83 | struct conf_st; | ||
| 84 | typedef struct conf_st CONF; | ||
| 85 | struct conf_method_st; | ||
| 86 | typedef struct conf_method_st CONF_METHOD; | ||
| 87 | |||
| 88 | struct conf_method_st | ||
| 89 | { | ||
| 90 | const char *name; | ||
| 91 | CONF *(*create)(CONF_METHOD *meth); | ||
| 92 | int (*init)(CONF *conf); | ||
| 93 | int (*destroy)(CONF *conf); | ||
| 94 | int (*destroy_data)(CONF *conf); | ||
| 95 | int (*load_bio)(CONF *conf, BIO *bp, long *eline); | ||
| 96 | int (*dump)(const CONF *conf, BIO *bp); | ||
| 97 | int (*is_number)(const CONF *conf, char c); | ||
| 98 | int (*to_int)(const CONF *conf, char c); | ||
| 99 | int (*load)(CONF *conf, const char *name, long *eline); | ||
| 100 | }; | ||
| 101 | |||
| 102 | /* Module definitions */ | ||
| 103 | |||
| 104 | typedef struct conf_imodule_st CONF_IMODULE; | ||
| 105 | typedef struct conf_module_st CONF_MODULE; | ||
| 106 | |||
| 107 | /* DSO module function typedefs */ | ||
| 108 | typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); | ||
| 109 | typedef void conf_finish_func(CONF_IMODULE *md); | ||
| 110 | |||
| 111 | #define CONF_MFLAGS_IGNORE_ERRORS 0x1 | ||
| 112 | #define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 | ||
| 113 | #define CONF_MFLAGS_SILENT 0x4 | ||
| 114 | #define CONF_MFLAGS_NO_DSO 0x8 | ||
| 115 | #define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 | ||
| 116 | |||
| 117 | int CONF_set_default_method(CONF_METHOD *meth); | ||
| 118 | void CONF_set_nconf(CONF *conf,LHASH *hash); | ||
| 119 | LHASH *CONF_load(LHASH *conf,const char *file,long *eline); | ||
| 120 | #ifndef OPENSSL_NO_FP_API | ||
| 121 | LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); | ||
| 122 | #endif | ||
| 123 | LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); | ||
| 124 | STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); | ||
| 125 | char *CONF_get_string(LHASH *conf,const char *group,const char *name); | ||
| 126 | long CONF_get_number(LHASH *conf,const char *group,const char *name); | ||
| 127 | void CONF_free(LHASH *conf); | ||
| 128 | int CONF_dump_fp(LHASH *conf, FILE *out); | ||
| 129 | int CONF_dump_bio(LHASH *conf, BIO *out); | ||
| 130 | |||
| 131 | void OPENSSL_config(const char *config_name); | ||
| 132 | |||
| 133 | /* New conf code. The semantics are different from the functions above. | ||
| 134 | If that wasn't the case, the above functions would have been replaced */ | ||
| 135 | |||
| 136 | struct conf_st | ||
| 137 | { | ||
| 138 | CONF_METHOD *meth; | ||
| 139 | void *meth_data; | ||
| 140 | LHASH *data; | ||
| 141 | }; | ||
| 142 | |||
| 143 | CONF *NCONF_new(CONF_METHOD *meth); | ||
| 144 | CONF_METHOD *NCONF_default(); | ||
| 145 | CONF_METHOD *NCONF_WIN32(); | ||
| 146 | #if 0 /* Just to give you an idea of what I have in mind */ | ||
| 147 | CONF_METHOD *NCONF_XML(); | ||
| 148 | #endif | ||
| 149 | void NCONF_free(CONF *conf); | ||
| 150 | void NCONF_free_data(CONF *conf); | ||
| 151 | |||
| 152 | int NCONF_load(CONF *conf,const char *file,long *eline); | ||
| 153 | #ifndef OPENSSL_NO_FP_API | ||
| 154 | int NCONF_load_fp(CONF *conf, FILE *fp,long *eline); | ||
| 155 | #endif | ||
| 156 | int NCONF_load_bio(CONF *conf, BIO *bp,long *eline); | ||
| 157 | STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section); | ||
| 158 | char *NCONF_get_string(const CONF *conf,const char *group,const char *name); | ||
| 159 | int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, | ||
| 160 | long *result); | ||
| 161 | int NCONF_dump_fp(const CONF *conf, FILE *out); | ||
| 162 | int NCONF_dump_bio(const CONF *conf, BIO *out); | ||
| 163 | |||
| 164 | #if 0 /* The following function has no error checking, | ||
| 165 | and should therefore be avoided */ | ||
| 166 | long NCONF_get_number(CONF *conf,char *group,char *name); | ||
| 167 | #else | ||
| 168 | #define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) | ||
| 169 | #endif | ||
| 170 | |||
| 171 | /* Module functions */ | ||
| 172 | |||
| 173 | int CONF_modules_load(const CONF *cnf, const char *appname, | ||
| 174 | unsigned long flags); | ||
| 175 | int CONF_modules_load_file(const char *filename, const char *appname, | ||
| 176 | unsigned long flags); | ||
| 177 | void CONF_modules_unload(int all); | ||
| 178 | void CONF_modules_finish(void); | ||
| 179 | int CONF_module_add(const char *name, conf_init_func *ifunc, | ||
| 180 | conf_finish_func *ffunc); | ||
| 181 | |||
| 182 | const char *CONF_imodule_get_name(const CONF_IMODULE *md); | ||
| 183 | const char *CONF_imodule_get_value(const CONF_IMODULE *md); | ||
| 184 | void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); | ||
| 185 | void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); | ||
| 186 | CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); | ||
| 187 | unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); | ||
| 188 | void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); | ||
| 189 | void *CONF_module_get_usr_data(CONF_MODULE *pmod); | ||
| 190 | void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); | ||
| 191 | |||
| 192 | char *CONF_get1_default_config_file(void); | ||
| 193 | |||
| 194 | int CONF_parse_list(const char *list, int sep, int nospc, | ||
| 195 | int (*list_cb)(const char *elem, int len, void *usr), void *arg); | ||
| 196 | |||
| 197 | void OPENSSL_load_builtin_modules(void); | ||
| 198 | |||
| 199 | /* BEGIN ERROR CODES */ | ||
| 200 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 201 | * made after this point may be overwritten when the script is next run. | ||
| 202 | */ | ||
| 203 | void ERR_load_CONF_strings(void); | ||
| 204 | |||
| 205 | /* Error codes for the CONF functions. */ | ||
| 206 | |||
| 207 | /* Function codes. */ | ||
| 208 | #define CONF_F_CONF_DUMP_FP 104 | ||
| 209 | #define CONF_F_CONF_LOAD 100 | ||
| 210 | #define CONF_F_CONF_LOAD_BIO 102 | ||
| 211 | #define CONF_F_CONF_LOAD_FP 103 | ||
| 212 | #define CONF_F_CONF_MODULES_LOAD 116 | ||
| 213 | #define CONF_F_MODULE_INIT 115 | ||
| 214 | #define CONF_F_MODULE_LOAD_DSO 117 | ||
| 215 | #define CONF_F_MODULE_RUN 118 | ||
| 216 | #define CONF_F_NCONF_DUMP_BIO 105 | ||
| 217 | #define CONF_F_NCONF_DUMP_FP 106 | ||
| 218 | #define CONF_F_NCONF_GET_NUMBER 107 | ||
| 219 | #define CONF_F_NCONF_GET_NUMBER_E 112 | ||
| 220 | #define CONF_F_NCONF_GET_SECTION 108 | ||
| 221 | #define CONF_F_NCONF_GET_STRING 109 | ||
| 222 | #define CONF_F_NCONF_LOAD 113 | ||
| 223 | #define CONF_F_NCONF_LOAD_BIO 110 | ||
| 224 | #define CONF_F_NCONF_LOAD_FP 114 | ||
| 225 | #define CONF_F_NCONF_NEW 111 | ||
| 226 | #define CONF_F_STR_COPY 101 | ||
| 227 | |||
| 228 | /* Reason codes. */ | ||
| 229 | #define CONF_R_ERROR_LOADING_DSO 110 | ||
| 230 | #define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 | ||
| 231 | #define CONF_R_MISSING_EQUAL_SIGN 101 | ||
| 232 | #define CONF_R_MISSING_FINISH_FUNCTION 111 | ||
| 233 | #define CONF_R_MISSING_INIT_FUNCTION 112 | ||
| 234 | #define CONF_R_MODULE_INITIALIZATION_ERROR 109 | ||
| 235 | #define CONF_R_NO_CLOSE_BRACE 102 | ||
| 236 | #define CONF_R_NO_CONF 105 | ||
| 237 | #define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 | ||
| 238 | #define CONF_R_NO_SECTION 107 | ||
| 239 | #define CONF_R_NO_SUCH_FILE 114 | ||
| 240 | #define CONF_R_NO_VALUE 108 | ||
| 241 | #define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 | ||
| 242 | #define CONF_R_UNKNOWN_MODULE_NAME 113 | ||
| 243 | #define CONF_R_VARIABLE_HAS_NO_VALUE 104 | ||
| 244 | |||
| 245 | #ifdef __cplusplus | ||
| 246 | } | ||
| 247 | #endif | ||
| 248 | #endif | ||
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c new file mode 100644 index 0000000000..0032baa711 --- /dev/null +++ b/src/lib/libcrypto/conf/conf_api.c | |||
| @@ -0,0 +1,308 @@ | |||
| 1 | /* conf_api.c */ | ||
| 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 <assert.h> | ||
| 67 | #include <string.h> | ||
| 68 | #include <openssl/conf.h> | ||
| 69 | #include <openssl/conf_api.h> | ||
| 70 | #include "e_os.h" | ||
| 71 | |||
| 72 | static void value_free_hash(CONF_VALUE *a, LHASH *conf); | ||
| 73 | static void value_free_stack(CONF_VALUE *a,LHASH *conf); | ||
| 74 | static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *) | ||
| 75 | static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *) | ||
| 76 | /* We don't use function pointer casting or wrapper functions - but cast each | ||
| 77 | * callback parameter inside the callback functions. */ | ||
| 78 | /* static unsigned long hash(CONF_VALUE *v); */ | ||
| 79 | static unsigned long hash(const void *v_void); | ||
| 80 | /* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */ | ||
| 81 | static int cmp_conf(const void *a_void,const void *b_void); | ||
| 82 | |||
| 83 | /* Up until OpenSSL 0.9.5a, this was get_section */ | ||
| 84 | CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section) | ||
| 85 | { | ||
| 86 | CONF_VALUE *v,vv; | ||
| 87 | |||
| 88 | if ((conf == NULL) || (section == NULL)) return(NULL); | ||
| 89 | vv.name=NULL; | ||
| 90 | vv.section=(char *)section; | ||
| 91 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); | ||
| 92 | return(v); | ||
| 93 | } | ||
| 94 | |||
| 95 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ | ||
| 96 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, | ||
| 97 | const char *section) | ||
| 98 | { | ||
| 99 | CONF_VALUE *v; | ||
| 100 | |||
| 101 | v=_CONF_get_section(conf,section); | ||
| 102 | if (v != NULL) | ||
| 103 | return((STACK_OF(CONF_VALUE) *)v->value); | ||
| 104 | else | ||
| 105 | return(NULL); | ||
| 106 | } | ||
| 107 | |||
| 108 | int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value) | ||
| 109 | { | ||
| 110 | CONF_VALUE *v = NULL; | ||
| 111 | STACK_OF(CONF_VALUE) *ts; | ||
| 112 | |||
| 113 | ts = (STACK_OF(CONF_VALUE) *)section->value; | ||
| 114 | |||
| 115 | value->section=section->section; | ||
| 116 | if (!sk_CONF_VALUE_push(ts,value)) | ||
| 117 | { | ||
| 118 | return 0; | ||
| 119 | } | ||
| 120 | |||
| 121 | v = (CONF_VALUE *)lh_insert(conf->data, value); | ||
| 122 | if (v != NULL) | ||
| 123 | { | ||
| 124 | sk_CONF_VALUE_delete_ptr(ts,v); | ||
| 125 | OPENSSL_free(v->name); | ||
| 126 | OPENSSL_free(v->value); | ||
| 127 | OPENSSL_free(v); | ||
| 128 | } | ||
| 129 | return 1; | ||
| 130 | } | ||
| 131 | |||
| 132 | char *_CONF_get_string(const CONF *conf, const char *section, const char *name) | ||
| 133 | { | ||
| 134 | CONF_VALUE *v,vv; | ||
| 135 | char *p; | ||
| 136 | |||
| 137 | if (name == NULL) return(NULL); | ||
| 138 | if (conf != NULL) | ||
| 139 | { | ||
| 140 | if (section != NULL) | ||
| 141 | { | ||
| 142 | vv.name=(char *)name; | ||
| 143 | vv.section=(char *)section; | ||
| 144 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); | ||
| 145 | if (v != NULL) return(v->value); | ||
| 146 | if (strcmp(section,"ENV") == 0) | ||
| 147 | { | ||
| 148 | p=Getenv(name); | ||
| 149 | if (p != NULL) return(p); | ||
| 150 | } | ||
| 151 | } | ||
| 152 | vv.section="default"; | ||
| 153 | vv.name=(char *)name; | ||
| 154 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); | ||
| 155 | if (v != NULL) | ||
| 156 | return(v->value); | ||
| 157 | else | ||
| 158 | return(NULL); | ||
| 159 | } | ||
| 160 | else | ||
| 161 | return(Getenv(name)); | ||
| 162 | } | ||
| 163 | |||
| 164 | #if 0 /* There's no way to provide error checking with this function, so | ||
| 165 | force implementors of the higher levels to get a string and read | ||
| 166 | the number themselves. */ | ||
| 167 | long _CONF_get_number(CONF *conf, char *section, char *name) | ||
| 168 | { | ||
| 169 | char *str; | ||
| 170 | long ret=0; | ||
| 171 | |||
| 172 | str=_CONF_get_string(conf,section,name); | ||
| 173 | if (str == NULL) return(0); | ||
| 174 | for (;;) | ||
| 175 | { | ||
| 176 | if (conf->meth->is_number(conf, *str)) | ||
| 177 | ret=ret*10+conf->meth->to_int(conf, *str); | ||
| 178 | else | ||
| 179 | return(ret); | ||
| 180 | str++; | ||
| 181 | } | ||
| 182 | } | ||
| 183 | #endif | ||
| 184 | |||
| 185 | int _CONF_new_data(CONF *conf) | ||
| 186 | { | ||
| 187 | if (conf == NULL) | ||
| 188 | { | ||
| 189 | return 0; | ||
| 190 | } | ||
| 191 | if (conf->data == NULL) | ||
| 192 | if ((conf->data = lh_new(hash, cmp_conf)) == NULL) | ||
| 193 | { | ||
| 194 | return 0; | ||
| 195 | } | ||
| 196 | return 1; | ||
| 197 | } | ||
| 198 | |||
| 199 | void _CONF_free_data(CONF *conf) | ||
| 200 | { | ||
| 201 | if (conf == NULL || conf->data == NULL) return; | ||
| 202 | |||
| 203 | conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()' | ||
| 204 | * works as expected */ | ||
| 205 | lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash), | ||
| 206 | conf->data); | ||
| 207 | |||
| 208 | /* We now have only 'section' entries in the hash table. | ||
| 209 | * Due to problems with */ | ||
| 210 | |||
| 211 | lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack), | ||
| 212 | conf->data); | ||
| 213 | lh_free(conf->data); | ||
| 214 | } | ||
| 215 | |||
| 216 | static void value_free_hash(CONF_VALUE *a, LHASH *conf) | ||
| 217 | { | ||
| 218 | if (a->name != NULL) | ||
| 219 | { | ||
| 220 | a=(CONF_VALUE *)lh_delete(conf,a); | ||
| 221 | } | ||
| 222 | } | ||
| 223 | |||
| 224 | static void value_free_stack(CONF_VALUE *a, LHASH *conf) | ||
| 225 | { | ||
| 226 | CONF_VALUE *vv; | ||
| 227 | STACK *sk; | ||
| 228 | int i; | ||
| 229 | |||
| 230 | if (a->name != NULL) return; | ||
| 231 | |||
| 232 | sk=(STACK *)a->value; | ||
| 233 | for (i=sk_num(sk)-1; i>=0; i--) | ||
| 234 | { | ||
| 235 | vv=(CONF_VALUE *)sk_value(sk,i); | ||
| 236 | OPENSSL_free(vv->value); | ||
| 237 | OPENSSL_free(vv->name); | ||
| 238 | OPENSSL_free(vv); | ||
| 239 | } | ||
| 240 | if (sk != NULL) sk_free(sk); | ||
| 241 | OPENSSL_free(a->section); | ||
| 242 | OPENSSL_free(a); | ||
| 243 | } | ||
| 244 | |||
| 245 | /* static unsigned long hash(CONF_VALUE *v) */ | ||
| 246 | static unsigned long hash(const void *v_void) | ||
| 247 | { | ||
| 248 | CONF_VALUE *v = (CONF_VALUE *)v_void; | ||
| 249 | return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); | ||
| 250 | } | ||
| 251 | |||
| 252 | /* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */ | ||
| 253 | static int cmp_conf(const void *a_void,const void *b_void) | ||
| 254 | { | ||
| 255 | int i; | ||
| 256 | CONF_VALUE *a = (CONF_VALUE *)a_void; | ||
| 257 | CONF_VALUE *b = (CONF_VALUE *)b_void; | ||
| 258 | |||
| 259 | if (a->section != b->section) | ||
| 260 | { | ||
| 261 | i=strcmp(a->section,b->section); | ||
| 262 | if (i) return(i); | ||
| 263 | } | ||
| 264 | |||
| 265 | if ((a->name != NULL) && (b->name != NULL)) | ||
| 266 | { | ||
| 267 | i=strcmp(a->name,b->name); | ||
| 268 | return(i); | ||
| 269 | } | ||
| 270 | else if (a->name == b->name) | ||
| 271 | return(0); | ||
| 272 | else | ||
| 273 | return((a->name == NULL)?-1:1); | ||
| 274 | } | ||
| 275 | |||
| 276 | /* Up until OpenSSL 0.9.5a, this was new_section */ | ||
| 277 | CONF_VALUE *_CONF_new_section(CONF *conf, const char *section) | ||
| 278 | { | ||
| 279 | STACK *sk=NULL; | ||
| 280 | int ok=0,i; | ||
| 281 | CONF_VALUE *v=NULL,*vv; | ||
| 282 | |||
| 283 | if ((sk=sk_new_null()) == NULL) | ||
| 284 | goto err; | ||
| 285 | if ((v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL) | ||
| 286 | goto err; | ||
| 287 | i=strlen(section)+1; | ||
| 288 | if ((v->section=(char *)OPENSSL_malloc(i)) == NULL) | ||
| 289 | goto err; | ||
| 290 | |||
| 291 | memcpy(v->section,section,i); | ||
| 292 | v->name=NULL; | ||
| 293 | v->value=(char *)sk; | ||
| 294 | |||
| 295 | vv=(CONF_VALUE *)lh_insert(conf->data,v); | ||
| 296 | assert(vv == NULL); | ||
| 297 | ok=1; | ||
| 298 | err: | ||
| 299 | if (!ok) | ||
| 300 | { | ||
| 301 | if (sk != NULL) sk_free(sk); | ||
| 302 | if (v != NULL) OPENSSL_free(v); | ||
| 303 | v=NULL; | ||
| 304 | } | ||
| 305 | return(v); | ||
| 306 | } | ||
| 307 | |||
| 308 | IMPLEMENT_STACK_OF(CONF_VALUE) | ||
diff --git a/src/lib/libcrypto/conf/conf_api.h b/src/lib/libcrypto/conf/conf_api.h new file mode 100644 index 0000000000..87a954aff6 --- /dev/null +++ b/src/lib/libcrypto/conf/conf_api.h | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | /* conf_api.h */ | ||
| 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 | #ifndef HEADER_CONF_API_H | ||
| 60 | #define HEADER_CONF_API_H | ||
| 61 | |||
| 62 | #include <openssl/lhash.h> | ||
| 63 | #include <openssl/conf.h> | ||
| 64 | |||
| 65 | #ifdef __cplusplus | ||
| 66 | extern "C" { | ||
| 67 | #endif | ||
| 68 | |||
| 69 | /* Up until OpenSSL 0.9.5a, this was new_section */ | ||
| 70 | CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); | ||
| 71 | /* Up until OpenSSL 0.9.5a, this was get_section */ | ||
| 72 | CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); | ||
| 73 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ | ||
| 74 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, | ||
| 75 | const char *section); | ||
| 76 | |||
| 77 | int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); | ||
| 78 | char *_CONF_get_string(const CONF *conf, const char *section, | ||
| 79 | const char *name); | ||
| 80 | long _CONF_get_number(const CONF *conf, const char *section, const char *name); | ||
| 81 | |||
| 82 | int _CONF_new_data(CONF *conf); | ||
| 83 | void _CONF_free_data(CONF *conf); | ||
| 84 | |||
| 85 | #ifdef __cplusplus | ||
| 86 | } | ||
| 87 | #endif | ||
| 88 | #endif | ||
| 89 | |||
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c new file mode 100644 index 0000000000..5e194de60e --- /dev/null +++ b/src/lib/libcrypto/conf/conf_def.c | |||
| @@ -0,0 +1,738 @@ | |||
| 1 | /* crypto/conf/conf.c */ | ||
| 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 | #include <stdio.h> | ||
| 62 | #include <string.h> | ||
| 63 | #include <openssl/stack.h> | ||
| 64 | #include <openssl/lhash.h> | ||
| 65 | #include <openssl/conf.h> | ||
| 66 | #include <openssl/conf_api.h> | ||
| 67 | #include "conf_def.h" | ||
| 68 | #include <openssl/buffer.h> | ||
| 69 | #include <openssl/err.h> | ||
| 70 | #include "cryptlib.h" | ||
| 71 | |||
| 72 | static char *eat_ws(CONF *conf, char *p); | ||
| 73 | static char *eat_alpha_numeric(CONF *conf, char *p); | ||
| 74 | static void clear_comments(CONF *conf, char *p); | ||
| 75 | static int str_copy(CONF *conf,char *section,char **to, char *from); | ||
| 76 | static char *scan_quote(CONF *conf, char *p); | ||
| 77 | static char *scan_dquote(CONF *conf, char *p); | ||
| 78 | #define scan_esc(conf,p) (((IS_EOF((conf),(p)[1]))?((p)+1):((p)+2))) | ||
| 79 | |||
| 80 | static CONF *def_create(CONF_METHOD *meth); | ||
| 81 | static int def_init_default(CONF *conf); | ||
| 82 | static int def_init_WIN32(CONF *conf); | ||
| 83 | static int def_destroy(CONF *conf); | ||
| 84 | static int def_destroy_data(CONF *conf); | ||
| 85 | static int def_load(CONF *conf, const char *name, long *eline); | ||
| 86 | static int def_load_bio(CONF *conf, BIO *bp, long *eline); | ||
| 87 | static int def_dump(const CONF *conf, BIO *bp); | ||
| 88 | static int def_is_number(const CONF *conf, char c); | ||
| 89 | static int def_to_int(const CONF *conf, char c); | ||
| 90 | |||
| 91 | const char *CONF_def_version="CONF_def" OPENSSL_VERSION_PTEXT; | ||
| 92 | |||
| 93 | static CONF_METHOD default_method = { | ||
| 94 | "OpenSSL default", | ||
| 95 | def_create, | ||
| 96 | def_init_default, | ||
| 97 | def_destroy, | ||
| 98 | def_destroy_data, | ||
| 99 | def_load_bio, | ||
| 100 | def_dump, | ||
| 101 | def_is_number, | ||
| 102 | def_to_int, | ||
| 103 | def_load | ||
| 104 | }; | ||
| 105 | |||
| 106 | static CONF_METHOD WIN32_method = { | ||
| 107 | "WIN32", | ||
| 108 | def_create, | ||
| 109 | def_init_WIN32, | ||
| 110 | def_destroy, | ||
| 111 | def_destroy_data, | ||
| 112 | def_load_bio, | ||
| 113 | def_dump, | ||
| 114 | def_is_number, | ||
| 115 | def_to_int, | ||
| 116 | def_load | ||
| 117 | }; | ||
| 118 | |||
| 119 | CONF_METHOD *NCONF_default() | ||
| 120 | { | ||
| 121 | return &default_method; | ||
| 122 | } | ||
| 123 | CONF_METHOD *NCONF_WIN32() | ||
| 124 | { | ||
| 125 | return &WIN32_method; | ||
| 126 | } | ||
| 127 | |||
| 128 | static CONF *def_create(CONF_METHOD *meth) | ||
| 129 | { | ||
| 130 | CONF *ret; | ||
| 131 | |||
| 132 | ret = (CONF *)OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *)); | ||
| 133 | if (ret) | ||
| 134 | if (meth->init(ret) == 0) | ||
| 135 | { | ||
| 136 | OPENSSL_free(ret); | ||
| 137 | ret = NULL; | ||
| 138 | } | ||
| 139 | return ret; | ||
| 140 | } | ||
| 141 | |||
| 142 | static int def_init_default(CONF *conf) | ||
| 143 | { | ||
| 144 | if (conf == NULL) | ||
| 145 | return 0; | ||
| 146 | |||
| 147 | conf->meth = &default_method; | ||
| 148 | conf->meth_data = (void *)CONF_type_default; | ||
| 149 | conf->data = NULL; | ||
| 150 | |||
| 151 | return 1; | ||
| 152 | } | ||
| 153 | |||
| 154 | static int def_init_WIN32(CONF *conf) | ||
| 155 | { | ||
| 156 | if (conf == NULL) | ||
| 157 | return 0; | ||
| 158 | |||
| 159 | conf->meth = &WIN32_method; | ||
| 160 | conf->meth_data = (void *)CONF_type_win32; | ||
| 161 | conf->data = NULL; | ||
| 162 | |||
| 163 | return 1; | ||
| 164 | } | ||
| 165 | |||
| 166 | static int def_destroy(CONF *conf) | ||
| 167 | { | ||
| 168 | if (def_destroy_data(conf)) | ||
| 169 | { | ||
| 170 | OPENSSL_free(conf); | ||
| 171 | return 1; | ||
| 172 | } | ||
| 173 | return 0; | ||
| 174 | } | ||
| 175 | |||
| 176 | static int def_destroy_data(CONF *conf) | ||
| 177 | { | ||
| 178 | if (conf == NULL) | ||
| 179 | return 0; | ||
| 180 | _CONF_free_data(conf); | ||
| 181 | return 1; | ||
| 182 | } | ||
| 183 | |||
| 184 | static int def_load(CONF *conf, const char *name, long *line) | ||
| 185 | { | ||
| 186 | int ret; | ||
| 187 | BIO *in=NULL; | ||
| 188 | |||
| 189 | #ifdef OPENSSL_SYS_VMS | ||
| 190 | in=BIO_new_file(name, "r"); | ||
| 191 | #else | ||
| 192 | in=BIO_new_file(name, "rb"); | ||
| 193 | #endif | ||
| 194 | if (in == NULL) | ||
| 195 | { | ||
| 196 | if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE) | ||
| 197 | CONFerr(CONF_F_CONF_LOAD,CONF_R_NO_SUCH_FILE); | ||
| 198 | else | ||
| 199 | CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); | ||
| 200 | return 0; | ||
| 201 | } | ||
| 202 | |||
| 203 | ret = def_load_bio(conf, in, line); | ||
| 204 | BIO_free(in); | ||
| 205 | |||
| 206 | return ret; | ||
| 207 | } | ||
| 208 | |||
| 209 | static int def_load_bio(CONF *conf, BIO *in, long *line) | ||
| 210 | { | ||
| 211 | #define BUFSIZE 512 | ||
| 212 | int bufnum=0,i,ii; | ||
| 213 | BUF_MEM *buff=NULL; | ||
| 214 | char *s,*p,*end; | ||
| 215 | int again,n; | ||
| 216 | long eline=0; | ||
| 217 | char btmp[DECIMAL_SIZE(eline)+1]; | ||
| 218 | CONF_VALUE *v=NULL,*tv; | ||
| 219 | CONF_VALUE *sv=NULL; | ||
| 220 | char *section=NULL,*buf; | ||
| 221 | STACK_OF(CONF_VALUE) *section_sk=NULL,*ts; | ||
| 222 | char *start,*psection,*pname; | ||
| 223 | void *h = (void *)(conf->data); | ||
| 224 | |||
| 225 | if ((buff=BUF_MEM_new()) == NULL) | ||
| 226 | { | ||
| 227 | CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB); | ||
| 228 | goto err; | ||
| 229 | } | ||
| 230 | |||
| 231 | section=(char *)OPENSSL_malloc(10); | ||
| 232 | if (section == NULL) | ||
| 233 | { | ||
| 234 | CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE); | ||
| 235 | goto err; | ||
| 236 | } | ||
| 237 | strcpy(section,"default"); | ||
| 238 | |||
| 239 | if (_CONF_new_data(conf) == 0) | ||
| 240 | { | ||
| 241 | CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE); | ||
| 242 | goto err; | ||
| 243 | } | ||
| 244 | |||
| 245 | sv=_CONF_new_section(conf,section); | ||
| 246 | if (sv == NULL) | ||
| 247 | { | ||
| 248 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 249 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | ||
| 250 | goto err; | ||
| 251 | } | ||
| 252 | section_sk=(STACK_OF(CONF_VALUE) *)sv->value; | ||
| 253 | |||
| 254 | bufnum=0; | ||
| 255 | for (;;) | ||
| 256 | { | ||
| 257 | again=0; | ||
| 258 | if (!BUF_MEM_grow(buff,bufnum+BUFSIZE)) | ||
| 259 | { | ||
| 260 | CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB); | ||
| 261 | goto err; | ||
| 262 | } | ||
| 263 | p= &(buff->data[bufnum]); | ||
| 264 | *p='\0'; | ||
| 265 | BIO_gets(in, p, BUFSIZE-1); | ||
| 266 | p[BUFSIZE-1]='\0'; | ||
| 267 | ii=i=strlen(p); | ||
| 268 | if (i == 0) break; | ||
| 269 | while (i > 0) | ||
| 270 | { | ||
| 271 | if ((p[i-1] != '\r') && (p[i-1] != '\n')) | ||
| 272 | break; | ||
| 273 | else | ||
| 274 | i--; | ||
| 275 | } | ||
| 276 | /* we removed some trailing stuff so there is a new | ||
| 277 | * line on the end. */ | ||
| 278 | if (i == ii) | ||
| 279 | again=1; /* long line */ | ||
| 280 | else | ||
| 281 | { | ||
| 282 | p[i]='\0'; | ||
| 283 | eline++; /* another input line */ | ||
| 284 | } | ||
| 285 | |||
| 286 | /* we now have a line with trailing \r\n removed */ | ||
| 287 | |||
| 288 | /* i is the number of bytes */ | ||
| 289 | bufnum+=i; | ||
| 290 | |||
| 291 | v=NULL; | ||
| 292 | /* check for line continuation */ | ||
| 293 | if (bufnum >= 1) | ||
| 294 | { | ||
| 295 | /* If we have bytes and the last char '\\' and | ||
| 296 | * second last char is not '\\' */ | ||
| 297 | p= &(buff->data[bufnum-1]); | ||
| 298 | if (IS_ESC(conf,p[0]) && | ||
| 299 | ((bufnum <= 1) || !IS_ESC(conf,p[-1]))) | ||
| 300 | { | ||
| 301 | bufnum--; | ||
| 302 | again=1; | ||
| 303 | } | ||
| 304 | } | ||
| 305 | if (again) continue; | ||
| 306 | bufnum=0; | ||
| 307 | buf=buff->data; | ||
| 308 | |||
| 309 | clear_comments(conf, buf); | ||
| 310 | n=strlen(buf); | ||
| 311 | s=eat_ws(conf, buf); | ||
| 312 | if (IS_EOF(conf,*s)) continue; /* blank line */ | ||
| 313 | if (*s == '[') | ||
| 314 | { | ||
| 315 | char *ss; | ||
| 316 | |||
| 317 | s++; | ||
| 318 | start=eat_ws(conf, s); | ||
| 319 | ss=start; | ||
| 320 | again: | ||
| 321 | end=eat_alpha_numeric(conf, ss); | ||
| 322 | p=eat_ws(conf, end); | ||
| 323 | if (*p != ']') | ||
| 324 | { | ||
| 325 | if (*p != '\0') | ||
| 326 | { | ||
| 327 | ss=p; | ||
| 328 | goto again; | ||
| 329 | } | ||
| 330 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 331 | CONF_R_MISSING_CLOSE_SQUARE_BRACKET); | ||
| 332 | goto err; | ||
| 333 | } | ||
| 334 | *end='\0'; | ||
| 335 | if (!str_copy(conf,NULL,§ion,start)) goto err; | ||
| 336 | if ((sv=_CONF_get_section(conf,section)) == NULL) | ||
| 337 | sv=_CONF_new_section(conf,section); | ||
| 338 | if (sv == NULL) | ||
| 339 | { | ||
| 340 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 341 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | ||
| 342 | goto err; | ||
| 343 | } | ||
| 344 | section_sk=(STACK_OF(CONF_VALUE) *)sv->value; | ||
| 345 | continue; | ||
| 346 | } | ||
| 347 | else | ||
| 348 | { | ||
| 349 | pname=s; | ||
| 350 | psection=NULL; | ||
| 351 | end=eat_alpha_numeric(conf, s); | ||
| 352 | if ((end[0] == ':') && (end[1] == ':')) | ||
| 353 | { | ||
| 354 | *end='\0'; | ||
| 355 | end+=2; | ||
| 356 | psection=pname; | ||
| 357 | pname=end; | ||
| 358 | end=eat_alpha_numeric(conf, end); | ||
| 359 | } | ||
| 360 | p=eat_ws(conf, end); | ||
| 361 | if (*p != '=') | ||
| 362 | { | ||
| 363 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 364 | CONF_R_MISSING_EQUAL_SIGN); | ||
| 365 | goto err; | ||
| 366 | } | ||
| 367 | *end='\0'; | ||
| 368 | p++; | ||
| 369 | start=eat_ws(conf, p); | ||
| 370 | while (!IS_EOF(conf,*p)) | ||
| 371 | p++; | ||
| 372 | p--; | ||
| 373 | while ((p != start) && (IS_WS(conf,*p))) | ||
| 374 | p--; | ||
| 375 | p++; | ||
| 376 | *p='\0'; | ||
| 377 | |||
| 378 | if (!(v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) | ||
| 379 | { | ||
| 380 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 381 | ERR_R_MALLOC_FAILURE); | ||
| 382 | goto err; | ||
| 383 | } | ||
| 384 | if (psection == NULL) psection=section; | ||
| 385 | v->name=(char *)OPENSSL_malloc(strlen(pname)+1); | ||
| 386 | v->value=NULL; | ||
| 387 | if (v->name == NULL) | ||
| 388 | { | ||
| 389 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 390 | ERR_R_MALLOC_FAILURE); | ||
| 391 | goto err; | ||
| 392 | } | ||
| 393 | strcpy(v->name,pname); | ||
| 394 | if (!str_copy(conf,psection,&(v->value),start)) goto err; | ||
| 395 | |||
| 396 | if (strcmp(psection,section) != 0) | ||
| 397 | { | ||
| 398 | if ((tv=_CONF_get_section(conf,psection)) | ||
| 399 | == NULL) | ||
| 400 | tv=_CONF_new_section(conf,psection); | ||
| 401 | if (tv == NULL) | ||
| 402 | { | ||
| 403 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 404 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | ||
| 405 | goto err; | ||
| 406 | } | ||
| 407 | ts=(STACK_OF(CONF_VALUE) *)tv->value; | ||
| 408 | } | ||
| 409 | else | ||
| 410 | { | ||
| 411 | tv=sv; | ||
| 412 | ts=section_sk; | ||
| 413 | } | ||
| 414 | #if 1 | ||
| 415 | if (_CONF_add_string(conf, tv, v) == 0) | ||
| 416 | { | ||
| 417 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 418 | ERR_R_MALLOC_FAILURE); | ||
| 419 | goto err; | ||
| 420 | } | ||
| 421 | #else | ||
| 422 | v->section=tv->section; | ||
| 423 | if (!sk_CONF_VALUE_push(ts,v)) | ||
| 424 | { | ||
| 425 | CONFerr(CONF_F_CONF_LOAD_BIO, | ||
| 426 | ERR_R_MALLOC_FAILURE); | ||
| 427 | goto err; | ||
| 428 | } | ||
| 429 | vv=(CONF_VALUE *)lh_insert(conf->data,v); | ||
| 430 | if (vv != NULL) | ||
| 431 | { | ||
| 432 | sk_CONF_VALUE_delete_ptr(ts,vv); | ||
| 433 | OPENSSL_free(vv->name); | ||
| 434 | OPENSSL_free(vv->value); | ||
| 435 | OPENSSL_free(vv); | ||
| 436 | } | ||
| 437 | #endif | ||
| 438 | v=NULL; | ||
| 439 | } | ||
| 440 | } | ||
| 441 | if (buff != NULL) BUF_MEM_free(buff); | ||
| 442 | if (section != NULL) OPENSSL_free(section); | ||
| 443 | return(1); | ||
| 444 | err: | ||
| 445 | if (buff != NULL) BUF_MEM_free(buff); | ||
| 446 | if (section != NULL) OPENSSL_free(section); | ||
| 447 | if (line != NULL) *line=eline; | ||
| 448 | sprintf(btmp,"%ld",eline); | ||
| 449 | ERR_add_error_data(2,"line ",btmp); | ||
| 450 | if ((h != conf->data) && (conf->data != NULL)) | ||
| 451 | { | ||
| 452 | CONF_free(conf->data); | ||
| 453 | conf->data=NULL; | ||
| 454 | } | ||
| 455 | if (v != NULL) | ||
| 456 | { | ||
| 457 | if (v->name != NULL) OPENSSL_free(v->name); | ||
| 458 | if (v->value != NULL) OPENSSL_free(v->value); | ||
| 459 | if (v != NULL) OPENSSL_free(v); | ||
| 460 | } | ||
| 461 | return(0); | ||
| 462 | } | ||
| 463 | |||
| 464 | static void clear_comments(CONF *conf, char *p) | ||
| 465 | { | ||
| 466 | char *to; | ||
| 467 | |||
| 468 | to=p; | ||
| 469 | for (;;) | ||
| 470 | { | ||
| 471 | if (IS_FCOMMENT(conf,*p)) | ||
| 472 | { | ||
| 473 | *p='\0'; | ||
| 474 | return; | ||
| 475 | } | ||
| 476 | if (!IS_WS(conf,*p)) | ||
| 477 | { | ||
| 478 | break; | ||
| 479 | } | ||
| 480 | p++; | ||
| 481 | } | ||
| 482 | |||
| 483 | for (;;) | ||
| 484 | { | ||
| 485 | if (IS_COMMENT(conf,*p)) | ||
| 486 | { | ||
| 487 | *p='\0'; | ||
| 488 | return; | ||
| 489 | } | ||
| 490 | if (IS_DQUOTE(conf,*p)) | ||
| 491 | { | ||
| 492 | p=scan_dquote(conf, p); | ||
| 493 | continue; | ||
| 494 | } | ||
| 495 | if (IS_QUOTE(conf,*p)) | ||
| 496 | { | ||
| 497 | p=scan_quote(conf, p); | ||
| 498 | continue; | ||
| 499 | } | ||
| 500 | if (IS_ESC(conf,*p)) | ||
| 501 | { | ||
| 502 | p=scan_esc(conf,p); | ||
| 503 | continue; | ||
| 504 | } | ||
| 505 | if (IS_EOF(conf,*p)) | ||
| 506 | return; | ||
| 507 | else | ||
| 508 | p++; | ||
| 509 | } | ||
| 510 | } | ||
| 511 | |||
| 512 | static int str_copy(CONF *conf, char *section, char **pto, char *from) | ||
| 513 | { | ||
| 514 | int q,r,rr=0,to=0,len=0; | ||
| 515 | char *s,*e,*rp,*p,*rrp,*np,*cp,v; | ||
| 516 | BUF_MEM *buf; | ||
| 517 | |||
| 518 | if ((buf=BUF_MEM_new()) == NULL) return(0); | ||
| 519 | |||
| 520 | len=strlen(from)+1; | ||
| 521 | if (!BUF_MEM_grow(buf,len)) goto err; | ||
| 522 | |||
| 523 | for (;;) | ||
| 524 | { | ||
| 525 | if (IS_QUOTE(conf,*from)) | ||
| 526 | { | ||
| 527 | q= *from; | ||
| 528 | from++; | ||
| 529 | while (!IS_EOF(conf,*from) && (*from != q)) | ||
| 530 | { | ||
| 531 | if (IS_ESC(conf,*from)) | ||
| 532 | { | ||
| 533 | from++; | ||
| 534 | if (IS_EOF(conf,*from)) break; | ||
| 535 | } | ||
| 536 | buf->data[to++]= *(from++); | ||
| 537 | } | ||
| 538 | if (*from == q) from++; | ||
| 539 | } | ||
| 540 | else if (IS_DQUOTE(conf,*from)) | ||
| 541 | { | ||
| 542 | q= *from; | ||
| 543 | from++; | ||
| 544 | while (!IS_EOF(conf,*from)) | ||
| 545 | { | ||
| 546 | if (*from == q) | ||
| 547 | { | ||
| 548 | if (*(from+1) == q) | ||
| 549 | { | ||
| 550 | from++; | ||
| 551 | } | ||
| 552 | else | ||
| 553 | { | ||
| 554 | break; | ||
| 555 | } | ||
| 556 | } | ||
| 557 | buf->data[to++]= *(from++); | ||
| 558 | } | ||
| 559 | if (*from == q) from++; | ||
| 560 | } | ||
| 561 | else if (IS_ESC(conf,*from)) | ||
| 562 | { | ||
| 563 | from++; | ||
| 564 | v= *(from++); | ||
| 565 | if (IS_EOF(conf,v)) break; | ||
| 566 | else if (v == 'r') v='\r'; | ||
| 567 | else if (v == 'n') v='\n'; | ||
| 568 | else if (v == 'b') v='\b'; | ||
| 569 | else if (v == 't') v='\t'; | ||
| 570 | buf->data[to++]= v; | ||
| 571 | } | ||
| 572 | else if (IS_EOF(conf,*from)) | ||
| 573 | break; | ||
| 574 | else if (*from == '$') | ||
| 575 | { | ||
| 576 | /* try to expand it */ | ||
| 577 | rrp=NULL; | ||
| 578 | s= &(from[1]); | ||
| 579 | if (*s == '{') | ||
| 580 | q='}'; | ||
| 581 | else if (*s == '(') | ||
| 582 | q=')'; | ||
| 583 | else q=0; | ||
| 584 | |||
| 585 | if (q) s++; | ||
| 586 | cp=section; | ||
| 587 | e=np=s; | ||
| 588 | while (IS_ALPHA_NUMERIC(conf,*e)) | ||
| 589 | e++; | ||
| 590 | if ((e[0] == ':') && (e[1] == ':')) | ||
| 591 | { | ||
| 592 | cp=np; | ||
| 593 | rrp=e; | ||
| 594 | rr= *e; | ||
| 595 | *rrp='\0'; | ||
| 596 | e+=2; | ||
| 597 | np=e; | ||
| 598 | while (IS_ALPHA_NUMERIC(conf,*e)) | ||
| 599 | e++; | ||
| 600 | } | ||
| 601 | r= *e; | ||
| 602 | *e='\0'; | ||
| 603 | rp=e; | ||
| 604 | if (q) | ||
| 605 | { | ||
| 606 | if (r != q) | ||
| 607 | { | ||
| 608 | CONFerr(CONF_F_STR_COPY,CONF_R_NO_CLOSE_BRACE); | ||
| 609 | goto err; | ||
| 610 | } | ||
| 611 | e++; | ||
| 612 | } | ||
| 613 | /* So at this point we have | ||
| 614 | * ns which is the start of the name string which is | ||
| 615 | * '\0' terminated. | ||
| 616 | * cs which is the start of the section string which is | ||
| 617 | * '\0' terminated. | ||
| 618 | * e is the 'next point after'. | ||
| 619 | * r and s are the chars replaced by the '\0' | ||
| 620 | * rp and sp is where 'r' and 's' came from. | ||
| 621 | */ | ||
| 622 | p=_CONF_get_string(conf,cp,np); | ||
| 623 | if (rrp != NULL) *rrp=rr; | ||
| 624 | *rp=r; | ||
| 625 | if (p == NULL) | ||
| 626 | { | ||
| 627 | CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE); | ||
| 628 | goto err; | ||
| 629 | } | ||
| 630 | BUF_MEM_grow(buf,(strlen(p)+len-(e-from))); | ||
| 631 | while (*p) | ||
| 632 | buf->data[to++]= *(p++); | ||
| 633 | from=e; | ||
| 634 | } | ||
| 635 | else | ||
| 636 | buf->data[to++]= *(from++); | ||
| 637 | } | ||
| 638 | buf->data[to]='\0'; | ||
| 639 | if (*pto != NULL) OPENSSL_free(*pto); | ||
| 640 | *pto=buf->data; | ||
| 641 | OPENSSL_free(buf); | ||
| 642 | return(1); | ||
| 643 | err: | ||
| 644 | if (buf != NULL) BUF_MEM_free(buf); | ||
| 645 | return(0); | ||
| 646 | } | ||
| 647 | |||
| 648 | static char *eat_ws(CONF *conf, char *p) | ||
| 649 | { | ||
| 650 | while (IS_WS(conf,*p) && (!IS_EOF(conf,*p))) | ||
| 651 | p++; | ||
| 652 | return(p); | ||
| 653 | } | ||
| 654 | |||
| 655 | static char *eat_alpha_numeric(CONF *conf, char *p) | ||
| 656 | { | ||
| 657 | for (;;) | ||
| 658 | { | ||
| 659 | if (IS_ESC(conf,*p)) | ||
| 660 | { | ||
| 661 | p=scan_esc(conf,p); | ||
| 662 | continue; | ||
| 663 | } | ||
| 664 | if (!IS_ALPHA_NUMERIC_PUNCT(conf,*p)) | ||
| 665 | return(p); | ||
| 666 | p++; | ||
| 667 | } | ||
| 668 | } | ||
| 669 | |||
| 670 | static char *scan_quote(CONF *conf, char *p) | ||
| 671 | { | ||
| 672 | int q= *p; | ||
| 673 | |||
| 674 | p++; | ||
| 675 | while (!(IS_EOF(conf,*p)) && (*p != q)) | ||
| 676 | { | ||
| 677 | if (IS_ESC(conf,*p)) | ||
| 678 | { | ||
| 679 | p++; | ||
| 680 | if (IS_EOF(conf,*p)) return(p); | ||
| 681 | } | ||
| 682 | p++; | ||
| 683 | } | ||
| 684 | if (*p == q) p++; | ||
| 685 | return(p); | ||
| 686 | } | ||
| 687 | |||
| 688 | |||
| 689 | static char *scan_dquote(CONF *conf, char *p) | ||
| 690 | { | ||
| 691 | int q= *p; | ||
| 692 | |||
| 693 | p++; | ||
| 694 | while (!(IS_EOF(conf,*p))) | ||
| 695 | { | ||
| 696 | if (*p == q) | ||
| 697 | { | ||
| 698 | if (*(p+1) == q) | ||
| 699 | { | ||
| 700 | p++; | ||
| 701 | } | ||
| 702 | else | ||
| 703 | { | ||
| 704 | break; | ||
| 705 | } | ||
| 706 | } | ||
| 707 | p++; | ||
| 708 | } | ||
| 709 | if (*p == q) p++; | ||
| 710 | return(p); | ||
| 711 | } | ||
| 712 | |||
| 713 | static void dump_value(CONF_VALUE *a, BIO *out) | ||
| 714 | { | ||
| 715 | if (a->name) | ||
| 716 | BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value); | ||
| 717 | else | ||
| 718 | BIO_printf(out, "[[%s]]\n", a->section); | ||
| 719 | } | ||
| 720 | |||
| 721 | static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *) | ||
| 722 | |||
| 723 | static int def_dump(const CONF *conf, BIO *out) | ||
| 724 | { | ||
| 725 | lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out); | ||
| 726 | return 1; | ||
| 727 | } | ||
| 728 | |||
| 729 | static int def_is_number(const CONF *conf, char c) | ||
| 730 | { | ||
| 731 | return IS_NUMBER(conf,c); | ||
| 732 | } | ||
| 733 | |||
| 734 | static int def_to_int(const CONF *conf, char c) | ||
| 735 | { | ||
| 736 | return c - '0'; | ||
| 737 | } | ||
| 738 | |||
diff --git a/src/lib/libcrypto/conf/conf_def.h b/src/lib/libcrypto/conf/conf_def.h new file mode 100644 index 0000000000..92a7d8ad77 --- /dev/null +++ b/src/lib/libcrypto/conf/conf_def.h | |||
| @@ -0,0 +1,180 @@ | |||
| 1 | /* crypto/conf/conf_def.h */ | ||
| 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 | /* THIS FILE WAS AUTOMAGICALLY GENERATED! | ||
| 60 | Please modify and use keysets.pl to regenerate it. */ | ||
| 61 | |||
| 62 | #define CONF_NUMBER 1 | ||
| 63 | #define CONF_UPPER 2 | ||
| 64 | #define CONF_LOWER 4 | ||
| 65 | #define CONF_UNDER 256 | ||
| 66 | #define CONF_PUNCTUATION 512 | ||
| 67 | #define CONF_WS 16 | ||
| 68 | #define CONF_ESC 32 | ||
| 69 | #define CONF_QUOTE 64 | ||
| 70 | #define CONF_DQUOTE 1024 | ||
| 71 | #define CONF_COMMENT 128 | ||
| 72 | #define CONF_FCOMMENT 2048 | ||
| 73 | #define CONF_EOF 8 | ||
| 74 | #define CONF_HIGHBIT 4096 | ||
| 75 | #define CONF_ALPHA (CONF_UPPER|CONF_LOWER) | ||
| 76 | #define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER) | ||
| 77 | #define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \ | ||
| 78 | CONF_PUNCTUATION) | ||
| 79 | |||
| 80 | #define KEYTYPES(c) ((unsigned short *)((c)->meth_data)) | ||
| 81 | #ifndef CHARSET_EBCDIC | ||
| 82 | #define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT) | ||
| 83 | #define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT) | ||
| 84 | #define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF) | ||
| 85 | #define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC) | ||
| 86 | #define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER) | ||
| 87 | #define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS) | ||
| 88 | #define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC) | ||
| 89 | #define IS_ALPHA_NUMERIC_PUNCT(c,a) \ | ||
| 90 | (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT) | ||
| 91 | #define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE) | ||
| 92 | #define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE) | ||
| 93 | #define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT) | ||
| 94 | |||
| 95 | #else /*CHARSET_EBCDIC*/ | ||
| 96 | |||
| 97 | #define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT) | ||
| 98 | #define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT) | ||
| 99 | #define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF) | ||
| 100 | #define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC) | ||
| 101 | #define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER) | ||
| 102 | #define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS) | ||
| 103 | #define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC) | ||
| 104 | #define IS_ALPHA_NUMERIC_PUNCT(c,a) \ | ||
| 105 | (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT) | ||
| 106 | #define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE) | ||
| 107 | #define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE) | ||
| 108 | #define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT) | ||
| 109 | #endif /*CHARSET_EBCDIC*/ | ||
| 110 | |||
| 111 | static unsigned short CONF_type_default[256]={ | ||
| 112 | 0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, | ||
| 113 | 0x0000,0x0010,0x0010,0x0000,0x0000,0x0010,0x0000,0x0000, | ||
| 114 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, | ||
| 115 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, | ||
| 116 | 0x0010,0x0200,0x0040,0x0080,0x0000,0x0200,0x0200,0x0040, | ||
| 117 | 0x0000,0x0000,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200, | ||
| 118 | 0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001, | ||
| 119 | 0x0001,0x0001,0x0000,0x0200,0x0000,0x0000,0x0000,0x0200, | ||
| 120 | 0x0200,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, | ||
| 121 | 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, | ||
| 122 | 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, | ||
| 123 | 0x0002,0x0002,0x0002,0x0000,0x0020,0x0000,0x0200,0x0100, | ||
| 124 | 0x0040,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004, | ||
| 125 | 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004, | ||
| 126 | 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004, | ||
| 127 | 0x0004,0x0004,0x0004,0x0000,0x0200,0x0000,0x0200,0x0000, | ||
| 128 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 129 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 130 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 131 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 132 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 133 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 134 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 135 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 136 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 137 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 138 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 139 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 140 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 141 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 142 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 143 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 144 | }; | ||
| 145 | |||
| 146 | static unsigned short CONF_type_win32[256]={ | ||
| 147 | 0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, | ||
| 148 | 0x0000,0x0010,0x0010,0x0000,0x0000,0x0010,0x0000,0x0000, | ||
| 149 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, | ||
| 150 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, | ||
| 151 | 0x0010,0x0200,0x0400,0x0000,0x0000,0x0200,0x0200,0x0000, | ||
| 152 | 0x0000,0x0000,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200, | ||
| 153 | 0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001, | ||
| 154 | 0x0001,0x0001,0x0000,0x0A00,0x0000,0x0000,0x0000,0x0200, | ||
| 155 | 0x0200,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, | ||
| 156 | 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, | ||
| 157 | 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, | ||
| 158 | 0x0002,0x0002,0x0002,0x0000,0x0000,0x0000,0x0200,0x0100, | ||
| 159 | 0x0000,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004, | ||
| 160 | 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004, | ||
| 161 | 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004, | ||
| 162 | 0x0004,0x0004,0x0004,0x0000,0x0200,0x0000,0x0200,0x0000, | ||
| 163 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 164 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 165 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 166 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 167 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 168 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 169 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 170 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 171 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 172 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 173 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 174 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 175 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 176 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 177 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 178 | 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, | ||
| 179 | }; | ||
| 180 | |||
diff --git a/src/lib/libcrypto/conf/conf_err.c b/src/lib/libcrypto/conf/conf_err.c new file mode 100644 index 0000000000..ee07bfe9d9 --- /dev/null +++ b/src/lib/libcrypto/conf/conf_err.c | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | /* crypto/conf/conf_err.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/conf.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | static ERR_STRING_DATA CONF_str_functs[]= | ||
| 68 | { | ||
| 69 | {ERR_PACK(0,CONF_F_CONF_DUMP_FP,0), "CONF_dump_fp"}, | ||
| 70 | {ERR_PACK(0,CONF_F_CONF_LOAD,0), "CONF_load"}, | ||
| 71 | {ERR_PACK(0,CONF_F_CONF_LOAD_BIO,0), "CONF_load_bio"}, | ||
| 72 | {ERR_PACK(0,CONF_F_CONF_LOAD_FP,0), "CONF_load_fp"}, | ||
| 73 | {ERR_PACK(0,CONF_F_CONF_MODULES_LOAD,0), "CONF_modules_load"}, | ||
| 74 | {ERR_PACK(0,CONF_F_MODULE_INIT,0), "MODULE_INIT"}, | ||
| 75 | {ERR_PACK(0,CONF_F_MODULE_LOAD_DSO,0), "MODULE_LOAD_DSO"}, | ||
| 76 | {ERR_PACK(0,CONF_F_MODULE_RUN,0), "MODULE_RUN"}, | ||
| 77 | {ERR_PACK(0,CONF_F_NCONF_DUMP_BIO,0), "NCONF_dump_bio"}, | ||
| 78 | {ERR_PACK(0,CONF_F_NCONF_DUMP_FP,0), "NCONF_dump_fp"}, | ||
| 79 | {ERR_PACK(0,CONF_F_NCONF_GET_NUMBER,0), "NCONF_get_number"}, | ||
| 80 | {ERR_PACK(0,CONF_F_NCONF_GET_NUMBER_E,0), "NCONF_get_number_e"}, | ||
| 81 | {ERR_PACK(0,CONF_F_NCONF_GET_SECTION,0), "NCONF_get_section"}, | ||
| 82 | {ERR_PACK(0,CONF_F_NCONF_GET_STRING,0), "NCONF_get_string"}, | ||
| 83 | {ERR_PACK(0,CONF_F_NCONF_LOAD,0), "NCONF_load"}, | ||
| 84 | {ERR_PACK(0,CONF_F_NCONF_LOAD_BIO,0), "NCONF_load_bio"}, | ||
| 85 | {ERR_PACK(0,CONF_F_NCONF_LOAD_FP,0), "NCONF_load_fp"}, | ||
| 86 | {ERR_PACK(0,CONF_F_NCONF_NEW,0), "NCONF_new"}, | ||
| 87 | {ERR_PACK(0,CONF_F_STR_COPY,0), "STR_COPY"}, | ||
| 88 | {0,NULL} | ||
| 89 | }; | ||
| 90 | |||
| 91 | static ERR_STRING_DATA CONF_str_reasons[]= | ||
| 92 | { | ||
| 93 | {CONF_R_ERROR_LOADING_DSO ,"error loading dso"}, | ||
| 94 | {CONF_R_MISSING_CLOSE_SQUARE_BRACKET ,"missing close square bracket"}, | ||
| 95 | {CONF_R_MISSING_EQUAL_SIGN ,"missing equal sign"}, | ||
| 96 | {CONF_R_MISSING_FINISH_FUNCTION ,"missing finish function"}, | ||
| 97 | {CONF_R_MISSING_INIT_FUNCTION ,"missing init function"}, | ||
| 98 | {CONF_R_MODULE_INITIALIZATION_ERROR ,"module initialization error"}, | ||
| 99 | {CONF_R_NO_CLOSE_BRACE ,"no close brace"}, | ||
| 100 | {CONF_R_NO_CONF ,"no conf"}, | ||
| 101 | {CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE ,"no conf or environment variable"}, | ||
| 102 | {CONF_R_NO_SECTION ,"no section"}, | ||
| 103 | {CONF_R_NO_SUCH_FILE ,"no such file"}, | ||
| 104 | {CONF_R_NO_VALUE ,"no value"}, | ||
| 105 | {CONF_R_UNABLE_TO_CREATE_NEW_SECTION ,"unable to create new section"}, | ||
| 106 | {CONF_R_UNKNOWN_MODULE_NAME ,"unknown module name"}, | ||
| 107 | {CONF_R_VARIABLE_HAS_NO_VALUE ,"variable has no value"}, | ||
| 108 | {0,NULL} | ||
| 109 | }; | ||
| 110 | |||
| 111 | #endif | ||
| 112 | |||
| 113 | void ERR_load_CONF_strings(void) | ||
| 114 | { | ||
| 115 | static int init=1; | ||
| 116 | |||
| 117 | if (init) | ||
| 118 | { | ||
| 119 | init=0; | ||
| 120 | #ifndef OPENSSL_NO_ERR | ||
| 121 | ERR_load_strings(ERR_LIB_CONF,CONF_str_functs); | ||
| 122 | ERR_load_strings(ERR_LIB_CONF,CONF_str_reasons); | ||
| 123 | #endif | ||
| 124 | |||
| 125 | } | ||
| 126 | } | ||
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c new file mode 100644 index 0000000000..7998f34c7b --- /dev/null +++ b/src/lib/libcrypto/conf/conf_lib.c | |||
| @@ -0,0 +1,400 @@ | |||
| 1 | /* conf_lib.c */ | ||
| 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/conf_api.h> | ||
| 64 | #include <openssl/lhash.h> | ||
| 65 | |||
| 66 | const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT; | ||
| 67 | |||
| 68 | static CONF_METHOD *default_CONF_method=NULL; | ||
| 69 | |||
| 70 | /* Init a 'CONF' structure from an old LHASH */ | ||
| 71 | |||
| 72 | void CONF_set_nconf(CONF *conf, LHASH *hash) | ||
| 73 | { | ||
| 74 | if (default_CONF_method == NULL) | ||
| 75 | default_CONF_method = NCONF_default(); | ||
| 76 | |||
| 77 | default_CONF_method->init(conf); | ||
| 78 | conf->data = hash; | ||
| 79 | } | ||
| 80 | |||
| 81 | /* The following section contains the "CONF classic" functions, | ||
| 82 | rewritten in terms of the new CONF interface. */ | ||
| 83 | |||
| 84 | int CONF_set_default_method(CONF_METHOD *meth) | ||
| 85 | { | ||
| 86 | default_CONF_method = meth; | ||
| 87 | return 1; | ||
| 88 | } | ||
| 89 | |||
| 90 | LHASH *CONF_load(LHASH *conf, const char *file, long *eline) | ||
| 91 | { | ||
| 92 | LHASH *ltmp; | ||
| 93 | BIO *in=NULL; | ||
| 94 | |||
| 95 | #ifdef OPENSSL_SYS_VMS | ||
| 96 | in=BIO_new_file(file, "r"); | ||
| 97 | #else | ||
| 98 | in=BIO_new_file(file, "rb"); | ||
| 99 | #endif | ||
| 100 | if (in == NULL) | ||
| 101 | { | ||
| 102 | CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); | ||
| 103 | return NULL; | ||
| 104 | } | ||
| 105 | |||
| 106 | ltmp = CONF_load_bio(conf, in, eline); | ||
| 107 | BIO_free(in); | ||
| 108 | |||
| 109 | return ltmp; | ||
| 110 | } | ||
| 111 | |||
| 112 | #ifndef OPENSSL_NO_FP_API | ||
| 113 | LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline) | ||
| 114 | { | ||
| 115 | BIO *btmp; | ||
| 116 | LHASH *ltmp; | ||
| 117 | if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { | ||
| 118 | CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB); | ||
| 119 | return NULL; | ||
| 120 | } | ||
| 121 | ltmp = CONF_load_bio(conf, btmp, eline); | ||
| 122 | BIO_free(btmp); | ||
| 123 | return ltmp; | ||
| 124 | } | ||
| 125 | #endif | ||
| 126 | |||
| 127 | LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline) | ||
| 128 | { | ||
| 129 | CONF ctmp; | ||
| 130 | int ret; | ||
| 131 | |||
| 132 | CONF_set_nconf(&ctmp, conf); | ||
| 133 | |||
| 134 | ret = NCONF_load_bio(&ctmp, bp, eline); | ||
| 135 | if (ret) | ||
| 136 | return ctmp.data; | ||
| 137 | return NULL; | ||
| 138 | } | ||
| 139 | |||
| 140 | STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section) | ||
| 141 | { | ||
| 142 | if (conf == NULL) | ||
| 143 | { | ||
| 144 | return NULL; | ||
| 145 | } | ||
| 146 | else | ||
| 147 | { | ||
| 148 | CONF ctmp; | ||
| 149 | CONF_set_nconf(&ctmp, conf); | ||
| 150 | return NCONF_get_section(&ctmp, section); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | char *CONF_get_string(LHASH *conf,const char *group,const char *name) | ||
| 155 | { | ||
| 156 | if (conf == NULL) | ||
| 157 | { | ||
| 158 | return NCONF_get_string(NULL, group, name); | ||
| 159 | } | ||
| 160 | else | ||
| 161 | { | ||
| 162 | CONF ctmp; | ||
| 163 | CONF_set_nconf(&ctmp, conf); | ||
| 164 | return NCONF_get_string(&ctmp, group, name); | ||
| 165 | } | ||
| 166 | } | ||
| 167 | |||
| 168 | long CONF_get_number(LHASH *conf,const char *group,const char *name) | ||
| 169 | { | ||
| 170 | int status; | ||
| 171 | long result = 0; | ||
| 172 | |||
| 173 | if (conf == NULL) | ||
| 174 | { | ||
| 175 | status = NCONF_get_number_e(NULL, group, name, &result); | ||
| 176 | } | ||
| 177 | else | ||
| 178 | { | ||
| 179 | CONF ctmp; | ||
| 180 | CONF_set_nconf(&ctmp, conf); | ||
| 181 | status = NCONF_get_number_e(&ctmp, group, name, &result); | ||
| 182 | } | ||
| 183 | |||
| 184 | if (status == 0) | ||
| 185 | { | ||
| 186 | /* This function does not believe in errors... */ | ||
| 187 | ERR_get_error(); | ||
| 188 | } | ||
| 189 | return result; | ||
| 190 | } | ||
| 191 | |||
| 192 | void CONF_free(LHASH *conf) | ||
| 193 | { | ||
| 194 | CONF ctmp; | ||
| 195 | CONF_set_nconf(&ctmp, conf); | ||
| 196 | NCONF_free_data(&ctmp); | ||
| 197 | } | ||
| 198 | |||
| 199 | #ifndef OPENSSL_NO_FP_API | ||
| 200 | int CONF_dump_fp(LHASH *conf, FILE *out) | ||
| 201 | { | ||
| 202 | BIO *btmp; | ||
| 203 | int ret; | ||
| 204 | |||
| 205 | if(!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) { | ||
| 206 | CONFerr(CONF_F_CONF_DUMP_FP,ERR_R_BUF_LIB); | ||
| 207 | return 0; | ||
| 208 | } | ||
| 209 | ret = CONF_dump_bio(conf, btmp); | ||
| 210 | BIO_free(btmp); | ||
| 211 | return ret; | ||
| 212 | } | ||
| 213 | #endif | ||
| 214 | |||
| 215 | int CONF_dump_bio(LHASH *conf, BIO *out) | ||
| 216 | { | ||
| 217 | CONF ctmp; | ||
| 218 | CONF_set_nconf(&ctmp, conf); | ||
| 219 | return NCONF_dump_bio(&ctmp, out); | ||
| 220 | } | ||
| 221 | |||
| 222 | /* The following section contains the "New CONF" functions. They are | ||
| 223 | completely centralised around a new CONF structure that may contain | ||
| 224 | basically anything, but at least a method pointer and a table of data. | ||
| 225 | These functions are also written in terms of the bridge functions used | ||
| 226 | by the "CONF classic" functions, for consistency. */ | ||
| 227 | |||
| 228 | CONF *NCONF_new(CONF_METHOD *meth) | ||
| 229 | { | ||
| 230 | CONF *ret; | ||
| 231 | |||
| 232 | if (meth == NULL) | ||
| 233 | meth = NCONF_default(); | ||
| 234 | |||
| 235 | ret = meth->create(meth); | ||
| 236 | if (ret == NULL) | ||
| 237 | { | ||
| 238 | CONFerr(CONF_F_NCONF_NEW,ERR_R_MALLOC_FAILURE); | ||
| 239 | return(NULL); | ||
| 240 | } | ||
| 241 | |||
| 242 | return ret; | ||
| 243 | } | ||
| 244 | |||
| 245 | void NCONF_free(CONF *conf) | ||
| 246 | { | ||
| 247 | if (conf == NULL) | ||
| 248 | return; | ||
| 249 | conf->meth->destroy(conf); | ||
| 250 | } | ||
| 251 | |||
| 252 | void NCONF_free_data(CONF *conf) | ||
| 253 | { | ||
| 254 | if (conf == NULL) | ||
| 255 | return; | ||
| 256 | conf->meth->destroy_data(conf); | ||
| 257 | } | ||
| 258 | |||
| 259 | int NCONF_load(CONF *conf, const char *file, long *eline) | ||
| 260 | { | ||
| 261 | if (conf == NULL) | ||
| 262 | { | ||
| 263 | CONFerr(CONF_F_NCONF_LOAD,CONF_R_NO_CONF); | ||
| 264 | return 0; | ||
| 265 | } | ||
| 266 | |||
| 267 | return conf->meth->load(conf, file, eline); | ||
| 268 | } | ||
| 269 | |||
| 270 | #ifndef OPENSSL_NO_FP_API | ||
| 271 | int NCONF_load_fp(CONF *conf, FILE *fp,long *eline) | ||
| 272 | { | ||
| 273 | BIO *btmp; | ||
| 274 | int ret; | ||
| 275 | if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) | ||
| 276 | { | ||
| 277 | CONFerr(CONF_F_NCONF_LOAD_FP,ERR_R_BUF_LIB); | ||
| 278 | return 0; | ||
| 279 | } | ||
| 280 | ret = NCONF_load_bio(conf, btmp, eline); | ||
| 281 | BIO_free(btmp); | ||
| 282 | return ret; | ||
| 283 | } | ||
| 284 | #endif | ||
| 285 | |||
| 286 | int NCONF_load_bio(CONF *conf, BIO *bp,long *eline) | ||
| 287 | { | ||
| 288 | if (conf == NULL) | ||
| 289 | { | ||
| 290 | CONFerr(CONF_F_NCONF_LOAD_BIO,CONF_R_NO_CONF); | ||
| 291 | return 0; | ||
| 292 | } | ||
| 293 | |||
| 294 | return conf->meth->load_bio(conf, bp, eline); | ||
| 295 | } | ||
| 296 | |||
| 297 | STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section) | ||
| 298 | { | ||
| 299 | if (conf == NULL) | ||
| 300 | { | ||
| 301 | CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_CONF); | ||
| 302 | return NULL; | ||
| 303 | } | ||
| 304 | |||
| 305 | if (section == NULL) | ||
| 306 | { | ||
| 307 | CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_SECTION); | ||
| 308 | return NULL; | ||
| 309 | } | ||
| 310 | |||
| 311 | return _CONF_get_section_values(conf, section); | ||
| 312 | } | ||
| 313 | |||
| 314 | char *NCONF_get_string(const CONF *conf,const char *group,const char *name) | ||
| 315 | { | ||
| 316 | char *s = _CONF_get_string(conf, group, name); | ||
| 317 | |||
| 318 | /* Since we may get a value from an environment variable even | ||
| 319 | if conf is NULL, let's check the value first */ | ||
| 320 | if (s) return s; | ||
| 321 | |||
| 322 | if (conf == NULL) | ||
| 323 | { | ||
| 324 | CONFerr(CONF_F_NCONF_GET_STRING, | ||
| 325 | CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); | ||
| 326 | return NULL; | ||
| 327 | } | ||
| 328 | CONFerr(CONF_F_NCONF_GET_STRING, | ||
| 329 | CONF_R_NO_VALUE); | ||
| 330 | ERR_add_error_data(4,"group=",group," name=",name); | ||
| 331 | return NULL; | ||
| 332 | } | ||
| 333 | |||
| 334 | int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, | ||
| 335 | long *result) | ||
| 336 | { | ||
| 337 | char *str; | ||
| 338 | |||
| 339 | if (result == NULL) | ||
| 340 | { | ||
| 341 | CONFerr(CONF_F_NCONF_GET_NUMBER_E,ERR_R_PASSED_NULL_PARAMETER); | ||
| 342 | return 0; | ||
| 343 | } | ||
| 344 | |||
| 345 | str = NCONF_get_string(conf,group,name); | ||
| 346 | |||
| 347 | if (str == NULL) | ||
| 348 | return 0; | ||
| 349 | |||
| 350 | for (*result = 0;conf->meth->is_number(conf, *str);) | ||
| 351 | { | ||
| 352 | *result = (*result)*10 + conf->meth->to_int(conf, *str); | ||
| 353 | str++; | ||
| 354 | } | ||
| 355 | |||
| 356 | return 1; | ||
| 357 | } | ||
| 358 | |||
| 359 | #ifndef OPENSSL_NO_FP_API | ||
| 360 | int NCONF_dump_fp(const CONF *conf, FILE *out) | ||
| 361 | { | ||
| 362 | BIO *btmp; | ||
| 363 | int ret; | ||
| 364 | if(!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) { | ||
| 365 | CONFerr(CONF_F_NCONF_DUMP_FP,ERR_R_BUF_LIB); | ||
| 366 | return 0; | ||
| 367 | } | ||
| 368 | ret = NCONF_dump_bio(conf, btmp); | ||
| 369 | BIO_free(btmp); | ||
| 370 | return ret; | ||
| 371 | } | ||
| 372 | #endif | ||
| 373 | |||
| 374 | int NCONF_dump_bio(const CONF *conf, BIO *out) | ||
| 375 | { | ||
| 376 | if (conf == NULL) | ||
| 377 | { | ||
| 378 | CONFerr(CONF_F_NCONF_DUMP_BIO,CONF_R_NO_CONF); | ||
| 379 | return 0; | ||
| 380 | } | ||
| 381 | |||
| 382 | return conf->meth->dump(conf, out); | ||
| 383 | } | ||
| 384 | |||
| 385 | /* This function should be avoided */ | ||
| 386 | #undef NCONF_get_number | ||
| 387 | long NCONF_get_number(CONF *conf,char *group,char *name) | ||
| 388 | { | ||
| 389 | int status; | ||
| 390 | long ret=0; | ||
| 391 | |||
| 392 | status = NCONF_get_number_e(conf, group, name, &ret); | ||
| 393 | if (status == 0) | ||
| 394 | { | ||
| 395 | /* This function does not believe in errors... */ | ||
| 396 | ERR_get_error(); | ||
| 397 | } | ||
| 398 | return ret; | ||
| 399 | } | ||
| 400 | |||
diff --git a/src/lib/libcrypto/conf/conf_mall.c b/src/lib/libcrypto/conf/conf_mall.c new file mode 100644 index 0000000000..d702af689b --- /dev/null +++ b/src/lib/libcrypto/conf/conf_mall.c | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* conf_mall.c */ | ||
| 2 | /* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 2001. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2001 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 "cryptlib.h" | ||
| 62 | #include <openssl/conf.h> | ||
| 63 | #include <openssl/dso.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | #include <openssl/asn1.h> | ||
| 66 | #include <openssl/engine.h> | ||
| 67 | |||
| 68 | /* Load all OpenSSL builtin modules */ | ||
| 69 | |||
| 70 | void OPENSSL_load_builtin_modules(void) | ||
| 71 | { | ||
| 72 | /* Add builtin modules here */ | ||
| 73 | ASN1_add_oid_module(); | ||
| 74 | ENGINE_add_conf_module(); | ||
| 75 | } | ||
| 76 | |||
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c new file mode 100644 index 0000000000..edcc08921c --- /dev/null +++ b/src/lib/libcrypto/conf/conf_mod.c | |||
| @@ -0,0 +1,616 @@ | |||
| 1 | /* conf_mod.c */ | ||
| 2 | /* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 2001. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2001 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 <ctype.h> | ||
| 61 | #include <openssl/crypto.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include <openssl/conf.h> | ||
| 64 | #include <openssl/dso.h> | ||
| 65 | #include <openssl/x509.h> | ||
| 66 | |||
| 67 | |||
| 68 | #define DSO_mod_init_name "OPENSSL_init" | ||
| 69 | #define DSO_mod_finish_name "OPENSSL_finish" | ||
| 70 | |||
| 71 | |||
| 72 | /* This structure contains a data about supported modules. | ||
| 73 | * entries in this table correspond to either dynamic or | ||
| 74 | * static modules. | ||
| 75 | */ | ||
| 76 | |||
| 77 | struct conf_module_st | ||
| 78 | { | ||
| 79 | /* DSO of this module or NULL if static */ | ||
| 80 | DSO *dso; | ||
| 81 | /* Name of the module */ | ||
| 82 | char *name; | ||
| 83 | /* Init function */ | ||
| 84 | conf_init_func *init; | ||
| 85 | /* Finish function */ | ||
| 86 | conf_finish_func *finish; | ||
| 87 | /* Number of successfully initialized modules */ | ||
| 88 | int links; | ||
| 89 | void *usr_data; | ||
| 90 | }; | ||
| 91 | |||
| 92 | |||
| 93 | /* This structure contains information about modules that have been | ||
| 94 | * successfully initialized. There may be more than one entry for a | ||
| 95 | * given module. | ||
| 96 | */ | ||
| 97 | |||
| 98 | struct conf_imodule_st | ||
| 99 | { | ||
| 100 | CONF_MODULE *pmod; | ||
| 101 | char *name; | ||
| 102 | char *value; | ||
| 103 | unsigned long flags; | ||
| 104 | void *usr_data; | ||
| 105 | }; | ||
| 106 | |||
| 107 | static STACK_OF(CONF_MODULE) *supported_modules = NULL; | ||
| 108 | static STACK_OF(CONF_IMODULE) *initialized_modules = NULL; | ||
| 109 | |||
| 110 | static void module_free(CONF_MODULE *md); | ||
| 111 | static void module_finish(CONF_IMODULE *imod); | ||
| 112 | static int module_run(const CONF *cnf, char *name, char *value, | ||
| 113 | unsigned long flags); | ||
| 114 | static CONF_MODULE *module_add(DSO *dso, const char *name, | ||
| 115 | conf_init_func *ifunc, conf_finish_func *ffunc); | ||
| 116 | static CONF_MODULE *module_find(char *name); | ||
| 117 | static int module_init(CONF_MODULE *pmod, char *name, char *value, | ||
| 118 | const CONF *cnf); | ||
| 119 | static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value, | ||
| 120 | unsigned long flags); | ||
| 121 | |||
| 122 | /* Main function: load modules from a CONF structure */ | ||
| 123 | |||
| 124 | int CONF_modules_load(const CONF *cnf, const char *appname, | ||
| 125 | unsigned long flags) | ||
| 126 | { | ||
| 127 | STACK_OF(CONF_VALUE) *values; | ||
| 128 | CONF_VALUE *vl; | ||
| 129 | char *vsection; | ||
| 130 | |||
| 131 | int ret, i; | ||
| 132 | |||
| 133 | if (!cnf) | ||
| 134 | return 1; | ||
| 135 | |||
| 136 | if (appname == NULL) | ||
| 137 | appname = "openssl_conf"; | ||
| 138 | |||
| 139 | vsection = NCONF_get_string(cnf, NULL, appname); | ||
| 140 | |||
| 141 | if (!vsection) | ||
| 142 | { | ||
| 143 | ERR_clear_error(); | ||
| 144 | return 1; | ||
| 145 | } | ||
| 146 | |||
| 147 | values = NCONF_get_section(cnf, vsection); | ||
| 148 | |||
| 149 | if (!values) | ||
| 150 | return 0; | ||
| 151 | |||
| 152 | for (i = 0; i < sk_CONF_VALUE_num(values); i++) | ||
| 153 | { | ||
| 154 | vl = sk_CONF_VALUE_value(values, i); | ||
| 155 | ret = module_run(cnf, vl->name, vl->value, flags); | ||
| 156 | if (ret <= 0) | ||
| 157 | if(!(flags & CONF_MFLAGS_IGNORE_ERRORS)) | ||
| 158 | return ret; | ||
| 159 | } | ||
| 160 | |||
| 161 | return 1; | ||
| 162 | |||
| 163 | } | ||
| 164 | |||
| 165 | int CONF_modules_load_file(const char *filename, const char *appname, | ||
| 166 | unsigned long flags) | ||
| 167 | { | ||
| 168 | char *file = NULL; | ||
| 169 | CONF *conf = NULL; | ||
| 170 | int ret = 0; | ||
| 171 | conf = NCONF_new(NULL); | ||
| 172 | if (!conf) | ||
| 173 | goto err; | ||
| 174 | |||
| 175 | if (filename == NULL) | ||
| 176 | { | ||
| 177 | file = CONF_get1_default_config_file(); | ||
| 178 | if (!file) | ||
| 179 | goto err; | ||
| 180 | } | ||
| 181 | else | ||
| 182 | file = (char *)filename; | ||
| 183 | |||
| 184 | if (NCONF_load(conf, file, NULL) <= 0) | ||
| 185 | { | ||
| 186 | if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) && | ||
| 187 | (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE)) | ||
| 188 | { | ||
| 189 | ERR_clear_error(); | ||
| 190 | ret = 1; | ||
| 191 | } | ||
| 192 | goto err; | ||
| 193 | } | ||
| 194 | |||
| 195 | ret = CONF_modules_load(conf, appname, flags); | ||
| 196 | |||
| 197 | err: | ||
| 198 | if (filename == NULL) | ||
| 199 | OPENSSL_free(file); | ||
| 200 | NCONF_free(conf); | ||
| 201 | |||
| 202 | return ret; | ||
| 203 | } | ||
| 204 | |||
| 205 | static int module_run(const CONF *cnf, char *name, char *value, | ||
| 206 | unsigned long flags) | ||
| 207 | { | ||
| 208 | CONF_MODULE *md; | ||
| 209 | int ret; | ||
| 210 | |||
| 211 | md = module_find(name); | ||
| 212 | |||
| 213 | /* Module not found: try to load DSO */ | ||
| 214 | if (!md && !(flags & CONF_MFLAGS_NO_DSO)) | ||
| 215 | md = module_load_dso(cnf, name, value, flags); | ||
| 216 | |||
| 217 | if (!md) | ||
| 218 | { | ||
| 219 | if (!(flags & CONF_MFLAGS_SILENT)) | ||
| 220 | { | ||
| 221 | CONFerr(CONF_F_MODULE_RUN, CONF_R_UNKNOWN_MODULE_NAME); | ||
| 222 | ERR_add_error_data(2, "module=", name); | ||
| 223 | } | ||
| 224 | return -1; | ||
| 225 | } | ||
| 226 | |||
| 227 | ret = module_init(md, name, value, cnf); | ||
| 228 | |||
| 229 | if (ret <= 0) | ||
| 230 | { | ||
| 231 | if (!(flags & CONF_MFLAGS_SILENT)) | ||
| 232 | { | ||
| 233 | char rcode[DECIMAL_SIZE(ret)+1]; | ||
| 234 | CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR); | ||
| 235 | sprintf(rcode, "%-8d", ret); | ||
| 236 | ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode); | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | return ret; | ||
| 241 | } | ||
| 242 | |||
| 243 | /* Load a module from a DSO */ | ||
| 244 | static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value, | ||
| 245 | unsigned long flags) | ||
| 246 | { | ||
| 247 | DSO *dso = NULL; | ||
| 248 | conf_init_func *ifunc; | ||
| 249 | conf_finish_func *ffunc; | ||
| 250 | char *path = NULL; | ||
| 251 | int errcode = 0; | ||
| 252 | CONF_MODULE *md; | ||
| 253 | /* Look for alternative path in module section */ | ||
| 254 | path = NCONF_get_string(cnf, value, "path"); | ||
| 255 | if (!path) | ||
| 256 | { | ||
| 257 | ERR_get_error(); | ||
| 258 | path = name; | ||
| 259 | } | ||
| 260 | dso = DSO_load(NULL, path, NULL, 0); | ||
| 261 | if (!dso) | ||
| 262 | { | ||
| 263 | errcode = CONF_R_ERROR_LOADING_DSO; | ||
| 264 | goto err; | ||
| 265 | } | ||
| 266 | ifunc = (conf_init_func *)DSO_bind_func(dso, DSO_mod_init_name); | ||
| 267 | if (!ifunc) | ||
| 268 | { | ||
| 269 | errcode = CONF_R_MISSING_INIT_FUNCTION; | ||
| 270 | goto err; | ||
| 271 | } | ||
| 272 | ffunc = (conf_finish_func *)DSO_bind_func(dso, DSO_mod_finish_name); | ||
| 273 | /* All OK, add module */ | ||
| 274 | md = module_add(dso, name, ifunc, ffunc); | ||
| 275 | |||
| 276 | if (!md) | ||
| 277 | goto err; | ||
| 278 | |||
| 279 | return md; | ||
| 280 | |||
| 281 | err: | ||
| 282 | if (dso) | ||
| 283 | DSO_free(dso); | ||
| 284 | CONFerr(CONF_F_MODULE_LOAD_DSO, errcode); | ||
| 285 | ERR_add_error_data(4, "module=", name, ", path=", path); | ||
| 286 | return NULL; | ||
| 287 | } | ||
| 288 | |||
| 289 | /* add module to list */ | ||
| 290 | static CONF_MODULE *module_add(DSO *dso, const char *name, | ||
| 291 | conf_init_func *ifunc, conf_finish_func *ffunc) | ||
| 292 | { | ||
| 293 | CONF_MODULE *tmod = NULL; | ||
| 294 | if (supported_modules == NULL) | ||
| 295 | supported_modules = sk_CONF_MODULE_new_null(); | ||
| 296 | if (supported_modules == NULL) | ||
| 297 | return NULL; | ||
| 298 | tmod = OPENSSL_malloc(sizeof(CONF_MODULE)); | ||
| 299 | if (tmod == NULL) | ||
| 300 | return NULL; | ||
| 301 | |||
| 302 | tmod->dso = dso; | ||
| 303 | tmod->name = BUF_strdup(name); | ||
| 304 | tmod->init = ifunc; | ||
| 305 | tmod->finish = ffunc; | ||
| 306 | tmod->links = 0; | ||
| 307 | |||
| 308 | if (!sk_CONF_MODULE_push(supported_modules, tmod)) | ||
| 309 | { | ||
| 310 | OPENSSL_free(tmod); | ||
| 311 | return NULL; | ||
| 312 | } | ||
| 313 | |||
| 314 | return tmod; | ||
| 315 | } | ||
| 316 | |||
| 317 | /* Find a module from the list. We allow module names of the | ||
| 318 | * form modname.XXXX to just search for modname to allow the | ||
| 319 | * same module to be initialized more than once. | ||
| 320 | */ | ||
| 321 | |||
| 322 | static CONF_MODULE *module_find(char *name) | ||
| 323 | { | ||
| 324 | CONF_MODULE *tmod; | ||
| 325 | int i, nchar; | ||
| 326 | char *p; | ||
| 327 | p = strrchr(name, '.'); | ||
| 328 | |||
| 329 | if (p) | ||
| 330 | nchar = p - name; | ||
| 331 | else | ||
| 332 | nchar = strlen(name); | ||
| 333 | |||
| 334 | for (i = 0; i < sk_CONF_MODULE_num(supported_modules); i++) | ||
| 335 | { | ||
| 336 | tmod = sk_CONF_MODULE_value(supported_modules, i); | ||
| 337 | if (!strncmp(tmod->name, name, nchar)) | ||
| 338 | return tmod; | ||
| 339 | } | ||
| 340 | |||
| 341 | return NULL; | ||
| 342 | |||
| 343 | } | ||
| 344 | |||
| 345 | /* initialize a module */ | ||
| 346 | static int module_init(CONF_MODULE *pmod, char *name, char *value, | ||
| 347 | const CONF *cnf) | ||
| 348 | { | ||
| 349 | int ret = 1; | ||
| 350 | int init_called = 0; | ||
| 351 | CONF_IMODULE *imod = NULL; | ||
| 352 | |||
| 353 | /* Otherwise add initialized module to list */ | ||
| 354 | imod = OPENSSL_malloc(sizeof(CONF_IMODULE)); | ||
| 355 | if (!imod) | ||
| 356 | goto err; | ||
| 357 | |||
| 358 | imod->pmod = pmod; | ||
| 359 | imod->name = BUF_strdup(name); | ||
| 360 | imod->value = BUF_strdup(value); | ||
| 361 | imod->usr_data = NULL; | ||
| 362 | |||
| 363 | if (!imod->name || !imod->value) | ||
| 364 | goto memerr; | ||
| 365 | |||
| 366 | /* Try to initialize module */ | ||
| 367 | if(pmod->init) | ||
| 368 | { | ||
| 369 | ret = pmod->init(imod, cnf); | ||
| 370 | init_called = 1; | ||
| 371 | /* Error occurred, exit */ | ||
| 372 | if (ret <= 0) | ||
| 373 | goto err; | ||
| 374 | } | ||
| 375 | |||
| 376 | if (initialized_modules == NULL) | ||
| 377 | { | ||
| 378 | initialized_modules = sk_CONF_IMODULE_new_null(); | ||
| 379 | if (!initialized_modules) | ||
| 380 | { | ||
| 381 | CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE); | ||
| 382 | goto err; | ||
| 383 | } | ||
| 384 | } | ||
| 385 | |||
| 386 | if (!sk_CONF_IMODULE_push(initialized_modules, imod)) | ||
| 387 | { | ||
| 388 | CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE); | ||
| 389 | goto err; | ||
| 390 | } | ||
| 391 | |||
| 392 | pmod->links++; | ||
| 393 | |||
| 394 | return ret; | ||
| 395 | |||
| 396 | err: | ||
| 397 | |||
| 398 | /* We've started the module so we'd better finish it */ | ||
| 399 | if (pmod->finish && init_called) | ||
| 400 | pmod->finish(imod); | ||
| 401 | |||
| 402 | memerr: | ||
| 403 | if (imod) | ||
| 404 | { | ||
| 405 | if (imod->name) | ||
| 406 | OPENSSL_free(imod->name); | ||
| 407 | if (imod->value) | ||
| 408 | OPENSSL_free(imod->value); | ||
| 409 | OPENSSL_free(imod); | ||
| 410 | } | ||
| 411 | |||
| 412 | return -1; | ||
| 413 | |||
| 414 | } | ||
| 415 | |||
| 416 | /* Unload any dynamic modules that have a link count of zero: | ||
| 417 | * i.e. have no active initialized modules. If 'all' is set | ||
| 418 | * then all modules are unloaded including static ones. | ||
| 419 | */ | ||
| 420 | |||
| 421 | void CONF_modules_unload(int all) | ||
| 422 | { | ||
| 423 | int i; | ||
| 424 | CONF_MODULE *md; | ||
| 425 | CONF_modules_finish(); | ||
| 426 | /* unload modules in reverse order */ | ||
| 427 | for (i = sk_CONF_MODULE_num(supported_modules) - 1; i >= 0; i--) | ||
| 428 | { | ||
| 429 | md = sk_CONF_MODULE_value(supported_modules, i); | ||
| 430 | /* If static or in use and 'all' not set ignore it */ | ||
| 431 | if (((md->links > 0) || !md->dso) && !all) | ||
| 432 | continue; | ||
| 433 | /* Since we're working in reverse this is OK */ | ||
| 434 | sk_CONF_MODULE_delete(supported_modules, i); | ||
| 435 | module_free(md); | ||
| 436 | } | ||
| 437 | if (sk_CONF_MODULE_num(supported_modules) == 0) | ||
| 438 | { | ||
| 439 | sk_CONF_MODULE_free(supported_modules); | ||
| 440 | supported_modules = NULL; | ||
| 441 | } | ||
| 442 | } | ||
| 443 | |||
| 444 | /* unload a single module */ | ||
| 445 | static void module_free(CONF_MODULE *md) | ||
| 446 | { | ||
| 447 | if (md->dso) | ||
| 448 | DSO_free(md->dso); | ||
| 449 | OPENSSL_free(md->name); | ||
| 450 | OPENSSL_free(md); | ||
| 451 | } | ||
| 452 | |||
| 453 | /* finish and free up all modules instances */ | ||
| 454 | |||
| 455 | void CONF_modules_finish(void) | ||
| 456 | { | ||
| 457 | CONF_IMODULE *imod; | ||
| 458 | while (sk_CONF_IMODULE_num(initialized_modules) > 0) | ||
| 459 | { | ||
| 460 | imod = sk_CONF_IMODULE_pop(initialized_modules); | ||
| 461 | module_finish(imod); | ||
| 462 | } | ||
| 463 | sk_CONF_IMODULE_free(initialized_modules); | ||
| 464 | initialized_modules = NULL; | ||
| 465 | } | ||
| 466 | |||
| 467 | /* finish a module instance */ | ||
| 468 | |||
| 469 | static void module_finish(CONF_IMODULE *imod) | ||
| 470 | { | ||
| 471 | if (imod->pmod->finish) | ||
| 472 | imod->pmod->finish(imod); | ||
| 473 | imod->pmod->links--; | ||
| 474 | OPENSSL_free(imod->name); | ||
| 475 | OPENSSL_free(imod->value); | ||
| 476 | OPENSSL_free(imod); | ||
| 477 | } | ||
| 478 | |||
| 479 | /* Add a static module to OpenSSL */ | ||
| 480 | |||
| 481 | int CONF_module_add(const char *name, conf_init_func *ifunc, | ||
| 482 | conf_finish_func *ffunc) | ||
| 483 | { | ||
| 484 | if (module_add(NULL, name, ifunc, ffunc)) | ||
| 485 | return 1; | ||
| 486 | else | ||
| 487 | return 0; | ||
| 488 | } | ||
| 489 | |||
| 490 | void CONF_modules_free(void) | ||
| 491 | { | ||
| 492 | CONF_modules_finish(); | ||
| 493 | CONF_modules_unload(1); | ||
| 494 | } | ||
| 495 | |||
| 496 | /* Utility functions */ | ||
| 497 | |||
| 498 | const char *CONF_imodule_get_name(const CONF_IMODULE *md) | ||
| 499 | { | ||
| 500 | return md->name; | ||
| 501 | } | ||
| 502 | |||
| 503 | const char *CONF_imodule_get_value(const CONF_IMODULE *md) | ||
| 504 | { | ||
| 505 | return md->value; | ||
| 506 | } | ||
| 507 | |||
| 508 | void *CONF_imodule_get_usr_data(const CONF_IMODULE *md) | ||
| 509 | { | ||
| 510 | return md->usr_data; | ||
| 511 | } | ||
| 512 | |||
| 513 | void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data) | ||
| 514 | { | ||
| 515 | md->usr_data = usr_data; | ||
| 516 | } | ||
| 517 | |||
| 518 | CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md) | ||
| 519 | { | ||
| 520 | return md->pmod; | ||
| 521 | } | ||
| 522 | |||
| 523 | unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md) | ||
| 524 | { | ||
| 525 | return md->flags; | ||
| 526 | } | ||
| 527 | |||
| 528 | void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags) | ||
| 529 | { | ||
| 530 | md->flags = flags; | ||
| 531 | } | ||
| 532 | |||
| 533 | void *CONF_module_get_usr_data(CONF_MODULE *pmod) | ||
| 534 | { | ||
| 535 | return pmod->usr_data; | ||
| 536 | } | ||
| 537 | |||
| 538 | void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data) | ||
| 539 | { | ||
| 540 | pmod->usr_data = usr_data; | ||
| 541 | } | ||
| 542 | |||
| 543 | /* Return default config file name */ | ||
| 544 | |||
| 545 | char *CONF_get1_default_config_file(void) | ||
| 546 | { | ||
| 547 | char *file; | ||
| 548 | int len; | ||
| 549 | |||
| 550 | file = getenv("OPENSSL_CONF"); | ||
| 551 | if (file) | ||
| 552 | return BUF_strdup(file); | ||
| 553 | |||
| 554 | len = strlen(X509_get_default_cert_area()); | ||
| 555 | #ifndef OPENSSL_SYS_VMS | ||
| 556 | len++; | ||
| 557 | #endif | ||
| 558 | len += strlen(OPENSSL_CONF); | ||
| 559 | |||
| 560 | file = OPENSSL_malloc(len + 1); | ||
| 561 | |||
| 562 | if (!file) | ||
| 563 | return NULL; | ||
| 564 | strcpy(file,X509_get_default_cert_area()); | ||
| 565 | #ifndef OPENSSL_SYS_VMS | ||
| 566 | strcat(file,"/"); | ||
| 567 | #endif | ||
| 568 | strcat(file,OPENSSL_CONF); | ||
| 569 | |||
| 570 | return file; | ||
| 571 | } | ||
| 572 | |||
| 573 | /* This function takes a list separated by 'sep' and calls the | ||
| 574 | * callback function giving the start and length of each member | ||
| 575 | * optionally stripping leading and trailing whitespace. This can | ||
| 576 | * be used to parse comma separated lists for example. | ||
| 577 | */ | ||
| 578 | |||
| 579 | int CONF_parse_list(const char *list, int sep, int nospc, | ||
| 580 | int (*list_cb)(const char *elem, int len, void *usr), void *arg) | ||
| 581 | { | ||
| 582 | int ret; | ||
| 583 | const char *lstart, *tmpend, *p; | ||
| 584 | lstart = list; | ||
| 585 | |||
| 586 | for(;;) | ||
| 587 | { | ||
| 588 | if (nospc) | ||
| 589 | { | ||
| 590 | while(*lstart && isspace((unsigned char)*lstart)) | ||
| 591 | lstart++; | ||
| 592 | } | ||
| 593 | p = strchr(lstart, sep); | ||
| 594 | if (p == lstart || !*lstart) | ||
| 595 | ret = list_cb(NULL, 0, arg); | ||
| 596 | else | ||
| 597 | { | ||
| 598 | if (p) | ||
| 599 | tmpend = p - 1; | ||
| 600 | else | ||
| 601 | tmpend = lstart + strlen(lstart) - 1; | ||
| 602 | if (nospc) | ||
| 603 | { | ||
| 604 | while(isspace((unsigned char)*tmpend)) | ||
| 605 | tmpend--; | ||
| 606 | } | ||
| 607 | ret = list_cb(lstart, tmpend - lstart + 1, arg); | ||
| 608 | } | ||
| 609 | if (ret <= 0) | ||
| 610 | return ret; | ||
| 611 | if (p == NULL) | ||
| 612 | return 1; | ||
| 613 | lstart = p + 1; | ||
| 614 | } | ||
| 615 | } | ||
| 616 | |||
diff --git a/src/lib/libcrypto/conf/conf_sap.c b/src/lib/libcrypto/conf/conf_sap.c new file mode 100644 index 0000000000..97fb174303 --- /dev/null +++ b/src/lib/libcrypto/conf/conf_sap.c | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | /* conf_sap.c */ | ||
| 2 | /* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 2001. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2001 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 "cryptlib.h" | ||
| 62 | #include <openssl/conf.h> | ||
| 63 | #include <openssl/dso.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | #include <openssl/asn1.h> | ||
| 66 | #include <openssl/engine.h> | ||
| 67 | |||
| 68 | /* This is the automatic configuration loader: it is called automatically by | ||
| 69 | * OpenSSL when any of a number of standard initialisation functions are called, | ||
| 70 | * unless this is overridden by calling OPENSSL_no_config() | ||
| 71 | */ | ||
| 72 | |||
| 73 | static int openssl_configured = 0; | ||
| 74 | |||
| 75 | void OPENSSL_config(const char *config_name) | ||
| 76 | { | ||
| 77 | if (openssl_configured) | ||
| 78 | return; | ||
| 79 | |||
| 80 | OPENSSL_load_builtin_modules(); | ||
| 81 | /* Need to load ENGINEs */ | ||
| 82 | ENGINE_load_builtin_engines(); | ||
| 83 | /* Add others here? */ | ||
| 84 | |||
| 85 | |||
| 86 | ERR_clear_error(); | ||
| 87 | if (CONF_modules_load_file(NULL, NULL, | ||
| 88 | CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) | ||
| 89 | { | ||
| 90 | BIO *bio_err; | ||
| 91 | ERR_load_crypto_strings(); | ||
| 92 | if ((bio_err=BIO_new_fp(stderr, BIO_NOCLOSE)) != NULL) | ||
| 93 | { | ||
| 94 | BIO_printf(bio_err,"Auto configuration failed\n"); | ||
| 95 | ERR_print_errors(bio_err); | ||
| 96 | BIO_free(bio_err); | ||
| 97 | } | ||
| 98 | exit(1); | ||
| 99 | } | ||
| 100 | |||
| 101 | return; | ||
| 102 | } | ||
| 103 | |||
| 104 | void OPENSSL_no_config() | ||
| 105 | { | ||
| 106 | openssl_configured = 1; | ||
| 107 | } | ||
diff --git a/src/lib/libcrypto/conf/keysets.pl b/src/lib/libcrypto/conf/keysets.pl new file mode 100644 index 0000000000..50ed67fa52 --- /dev/null +++ b/src/lib/libcrypto/conf/keysets.pl | |||
| @@ -0,0 +1,185 @@ | |||
| 1 | #!/usr/local/bin/perl | ||
| 2 | |||
| 3 | $NUMBER=0x01; | ||
| 4 | $UPPER=0x02; | ||
| 5 | $LOWER=0x04; | ||
| 6 | $UNDER=0x100; | ||
| 7 | $PUNCTUATION=0x200; | ||
| 8 | $WS=0x10; | ||
| 9 | $ESC=0x20; | ||
| 10 | $QUOTE=0x40; | ||
| 11 | $DQUOTE=0x400; | ||
| 12 | $COMMENT=0x80; | ||
| 13 | $FCOMMENT=0x800; | ||
| 14 | $EOF=0x08; | ||
| 15 | $HIGHBIT=0x1000; | ||
| 16 | |||
| 17 | foreach (0 .. 255) | ||
| 18 | { | ||
| 19 | $v=0; | ||
| 20 | $c=sprintf("%c",$_); | ||
| 21 | $v|=$NUMBER if ($c =~ /[0-9]/); | ||
| 22 | $v|=$UPPER if ($c =~ /[A-Z]/); | ||
| 23 | $v|=$LOWER if ($c =~ /[a-z]/); | ||
| 24 | $v|=$UNDER if ($c =~ /_/); | ||
| 25 | $v|=$PUNCTUATION if ($c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/); | ||
| 26 | $v|=$WS if ($c =~ /[ \t\r\n]/); | ||
| 27 | $v|=$ESC if ($c =~ /\\/); | ||
| 28 | $v|=$QUOTE if ($c =~ /['`"]/); # for emacs: "`'}/) | ||
| 29 | $v|=$COMMENT if ($c =~ /\#/); | ||
| 30 | $v|=$EOF if ($c =~ /\0/); | ||
| 31 | $v|=$HIGHBIT if ($c =~/[\x80-\xff]/); | ||
| 32 | |||
| 33 | push(@V_def,$v); | ||
| 34 | } | ||
| 35 | |||
| 36 | foreach (0 .. 255) | ||
| 37 | { | ||
| 38 | $v=0; | ||
| 39 | $c=sprintf("%c",$_); | ||
| 40 | $v|=$NUMBER if ($c =~ /[0-9]/); | ||
| 41 | $v|=$UPPER if ($c =~ /[A-Z]/); | ||
| 42 | $v|=$LOWER if ($c =~ /[a-z]/); | ||
| 43 | $v|=$UNDER if ($c =~ /_/); | ||
| 44 | $v|=$PUNCTUATION if ($c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/); | ||
| 45 | $v|=$WS if ($c =~ /[ \t\r\n]/); | ||
| 46 | $v|=$DQUOTE if ($c =~ /["]/); # for emacs: "}/) | ||
| 47 | $v|=$FCOMMENT if ($c =~ /;/); | ||
| 48 | $v|=$EOF if ($c =~ /\0/); | ||
| 49 | $v|=$HIGHBIT if ($c =~/[\x80-\xff]/); | ||
| 50 | |||
| 51 | push(@V_w32,$v); | ||
| 52 | } | ||
| 53 | |||
| 54 | print <<"EOF"; | ||
| 55 | /* crypto/conf/conf_def.h */ | ||
| 56 | /* Copyright (C) 1995-1998 Eric Young (eay\@cryptsoft.com) | ||
| 57 | * All rights reserved. | ||
| 58 | * | ||
| 59 | * This package is an SSL implementation written | ||
| 60 | * by Eric Young (eay\@cryptsoft.com). | ||
| 61 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 62 | * | ||
| 63 | * This library is free for commercial and non-commercial use as long as | ||
| 64 | * the following conditions are aheared to. The following conditions | ||
| 65 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 66 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 67 | * included with this distribution is covered by the same copyright terms | ||
| 68 | * except that the holder is Tim Hudson (tjh\@cryptsoft.com). | ||
| 69 | * | ||
| 70 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 71 | * the code are not to be removed. | ||
| 72 | * If this package is used in a product, Eric Young should be given attribution | ||
| 73 | * as the author of the parts of the library used. | ||
| 74 | * This can be in the form of a textual message at program startup or | ||
| 75 | * in documentation (online or textual) provided with the package. | ||
| 76 | * | ||
| 77 | * Redistribution and use in source and binary forms, with or without | ||
| 78 | * modification, are permitted provided that the following conditions | ||
| 79 | * are met: | ||
| 80 | * 1. Redistributions of source code must retain the copyright | ||
| 81 | * notice, this list of conditions and the following disclaimer. | ||
| 82 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 83 | * notice, this list of conditions and the following disclaimer in the | ||
| 84 | * documentation and/or other materials provided with the distribution. | ||
| 85 | * 3. All advertising materials mentioning features or use of this software | ||
| 86 | * must display the following acknowledgement: | ||
| 87 | * "This product includes cryptographic software written by | ||
| 88 | * Eric Young (eay\@cryptsoft.com)" | ||
| 89 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 90 | * being used are not cryptographic related :-). | ||
| 91 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 92 | * the apps directory (application code) you must include an acknowledgement: | ||
| 93 | * "This product includes software written by Tim Hudson (tjh\@cryptsoft.com)" | ||
| 94 | * | ||
| 95 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 96 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 97 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 98 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 99 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 100 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 101 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 102 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 103 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 104 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 105 | * SUCH DAMAGE. | ||
| 106 | * | ||
| 107 | * The licence and distribution terms for any publically available version or | ||
| 108 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 109 | * copied and put under another distribution licence | ||
| 110 | * [including the GNU Public Licence.] | ||
| 111 | */ | ||
| 112 | |||
| 113 | /* THIS FILE WAS AUTOMAGICALLY GENERATED! | ||
| 114 | Please modify and use keysets.pl to regenerate it. */ | ||
| 115 | |||
| 116 | #define CONF_NUMBER $NUMBER | ||
| 117 | #define CONF_UPPER $UPPER | ||
| 118 | #define CONF_LOWER $LOWER | ||
| 119 | #define CONF_UNDER $UNDER | ||
| 120 | #define CONF_PUNCTUATION $PUNCTUATION | ||
| 121 | #define CONF_WS $WS | ||
| 122 | #define CONF_ESC $ESC | ||
| 123 | #define CONF_QUOTE $QUOTE | ||
| 124 | #define CONF_DQUOTE $DQUOTE | ||
| 125 | #define CONF_COMMENT $COMMENT | ||
| 126 | #define CONF_FCOMMENT $FCOMMENT | ||
| 127 | #define CONF_EOF $EOF | ||
| 128 | #define CONF_HIGHBIT $HIGHBIT | ||
| 129 | #define CONF_ALPHA (CONF_UPPER|CONF_LOWER) | ||
| 130 | #define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER) | ||
| 131 | #define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \\ | ||
| 132 | CONF_PUNCTUATION) | ||
| 133 | |||
| 134 | #define KEYTYPES(c) ((unsigned short *)((c)->meth_data)) | ||
| 135 | #ifndef CHARSET_EBCDIC | ||
| 136 | #define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT) | ||
| 137 | #define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT) | ||
| 138 | #define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF) | ||
| 139 | #define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC) | ||
| 140 | #define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER) | ||
| 141 | #define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS) | ||
| 142 | #define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC) | ||
| 143 | #define IS_ALPHA_NUMERIC_PUNCT(c,a) \\ | ||
| 144 | (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT) | ||
| 145 | #define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE) | ||
| 146 | #define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE) | ||
| 147 | #define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT) | ||
| 148 | |||
| 149 | #else /*CHARSET_EBCDIC*/ | ||
| 150 | |||
| 151 | #define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT) | ||
| 152 | #define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT) | ||
| 153 | #define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF) | ||
| 154 | #define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC) | ||
| 155 | #define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER) | ||
| 156 | #define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS) | ||
| 157 | #define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC) | ||
| 158 | #define IS_ALPHA_NUMERIC_PUNCT(c,a) \\ | ||
| 159 | (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT) | ||
| 160 | #define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE) | ||
| 161 | #define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE) | ||
| 162 | #define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT) | ||
| 163 | #endif /*CHARSET_EBCDIC*/ | ||
| 164 | |||
| 165 | EOF | ||
| 166 | |||
| 167 | print "static unsigned short CONF_type_default[256]={"; | ||
| 168 | |||
| 169 | for ($i=0; $i<256; $i++) | ||
| 170 | { | ||
| 171 | print "\n\t" if ($i % 8) == 0; | ||
| 172 | printf "0x%04X,",$V_def[$i]; | ||
| 173 | } | ||
| 174 | |||
| 175 | print "\n\t};\n\n"; | ||
| 176 | |||
| 177 | print "static unsigned short CONF_type_win32[256]={"; | ||
| 178 | |||
| 179 | for ($i=0; $i<256; $i++) | ||
| 180 | { | ||
| 181 | print "\n\t" if ($i % 8) == 0; | ||
| 182 | printf "0x%04X,",$V_w32[$i]; | ||
| 183 | } | ||
| 184 | |||
| 185 | print "\n\t};\n\n"; | ||
diff --git a/src/lib/libcrypto/conf/ssleay.cnf b/src/lib/libcrypto/conf/ssleay.cnf new file mode 100644 index 0000000000..ed33af601e --- /dev/null +++ b/src/lib/libcrypto/conf/ssleay.cnf | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | # | ||
| 2 | # This is a test configuration file for use in SSLeay etc... | ||
| 3 | # | ||
| 4 | |||
| 5 | init = 5 | ||
| 6 | in\#it1 =10 | ||
| 7 | init2='10' | ||
| 8 | init3='10\'' | ||
| 9 | init4="10'" | ||
| 10 | init5='='10\'' again' | ||
| 11 | |||
| 12 | SSLeay::version = 0.5.0 | ||
| 13 | |||
| 14 | [genrsa] | ||
| 15 | default_bits = 512 | ||
| 16 | SSLEAY::version = 0.5.0 | ||
| 17 | |||
| 18 | [gendh] | ||
| 19 | default_bits = 512 | ||
| 20 | def_generator = 2 | ||
| 21 | |||
| 22 | [s_client] | ||
| 23 | cipher1 = DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5\ | ||
| 24 | cipher2 = 'DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5' | ||
| 25 | cipher3 = "DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5" | ||
| 26 | cipher4 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 | ||
| 27 | |||
| 28 | [ default ] | ||
| 29 | cert_dir = $ENV::HOME/.ca_certs | ||
| 30 | |||
| 31 | HOME = /tmp/eay | ||
| 32 | |||
| 33 | tmp_cert_dir = $HOME/.ca_certs | ||
| 34 | tmp2_cert_dir = thisis$(HOME)stuff | ||
| 35 | |||
| 36 | LOGNAME = Eric Young (home=$HOME) | ||
| 37 | |||
| 38 | [ special ] | ||
| 39 | |||
| 40 | H=$HOME | ||
| 41 | H=$default::HOME | ||
| 42 | H=$ENV::HOME | ||
| 43 | # | ||
| 44 | # SSLeay example configuration file. | ||
| 45 | # This is mostly being used for generation of certificate requests. | ||
| 46 | # | ||
| 47 | |||
| 48 | RANDFILE = $HOME/.rand | ||
| 49 | |||
| 50 | [ req ] | ||
| 51 | default_bits = 512 | ||
| 52 | default_keyfile = privkey.pem | ||
| 53 | |||
| 54 | Attribute_type_1 = countryName | ||
| 55 | Attribute_text_1 = Country Name (2 letter code) | ||
| 56 | Attribute_default_1 = AU | ||
| 57 | |||
| 58 | Attribute_type_2 = stateOrProvinceName | ||
| 59 | Attribute_text_2 = State or Province Name (full name) | ||
| 60 | Attribute_default_2 = Queensland | ||
| 61 | |||
| 62 | Attribute_type_3 = localityName | ||
| 63 | Attribute_text_3 = Locality Name (eg, city) | ||
| 64 | |||
| 65 | Attribute_type_4 = organizationName | ||
| 66 | Attribute_text_4 = Organization Name (eg, company) | ||
| 67 | Attribute_default_4 = Mincom Pty Ltd | ||
| 68 | |||
| 69 | Attribute_type_5 = organizationalUnitName | ||
| 70 | Attribute_text_5 = Organizational Unit Name (eg, section) | ||
| 71 | Attribute_default_5 = TR | ||
| 72 | |||
| 73 | Attribute_type_6 = commonName | ||
| 74 | Attribute_text_6 = Common Name (eg, YOUR name) | ||
| 75 | |||
| 76 | Attribute_type_7 = emailAddress | ||
| 77 | Attribute_text_7 = Email Address | ||
| 78 | |||
