summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/conf
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/conf')
-rw-r--r--src/lib/libcrypto/conf/Makefile.ssl183
-rw-r--r--src/lib/libcrypto/conf/README47
-rw-r--r--src/lib/libcrypto/conf/conf.h35
-rw-r--r--src/lib/libcrypto/conf/conf_api.c134
-rw-r--r--src/lib/libcrypto/conf/conf_def.c11
-rw-r--r--src/lib/libcrypto/conf/conf_err.c4
-rw-r--r--src/lib/libcrypto/conf/conf_lib.c30
-rw-r--r--src/lib/libcrypto/conf/conf_mall.c2
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c8
9 files changed, 140 insertions, 314 deletions
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl
deleted file mode 100644
index c5873bc6e7..0000000000
--- a/src/lib/libcrypto/conf/Makefile.ssl
+++ /dev/null
@@ -1,183 +0,0 @@
1#
2# SSLeay/crypto/conf/Makefile
3#
4
5DIR= conf
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c \
27 conf_mall.c conf_sap.c
28
29LIBOBJ= conf_err.o conf_lib.o conf_api.o conf_def.o conf_mod.o \
30 conf_mall.o conf_sap.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= conf.h conf_api.h
35HEADER= conf_def.h $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49files:
50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51
52links:
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
58install:
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
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75
76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
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
85conf_api.o: ../../e_os.h ../../include/openssl/bio.h
86conf_api.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h
87conf_api.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88conf_api.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
89conf_api.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
90conf_api.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
91conf_api.o: conf_api.c
92conf_def.o: ../../e_os.h ../../include/openssl/bio.h
93conf_def.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
94conf_def.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h
95conf_def.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
96conf_def.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
97conf_def.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
98conf_def.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
99conf_def.o: ../cryptlib.h conf_def.c conf_def.h
100conf_err.o: ../../include/openssl/bio.h ../../include/openssl/conf.h
101conf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
102conf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
103conf_err.o: ../../include/openssl/opensslconf.h
104conf_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
105conf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
106conf_err.o: conf_err.c
107conf_lib.o: ../../include/openssl/bio.h ../../include/openssl/conf.h
108conf_lib.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h
109conf_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
110conf_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
111conf_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
112conf_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
113conf_lib.o: conf_lib.c
114conf_mall.o: ../../e_os.h ../../include/openssl/aes.h
115conf_mall.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
116conf_mall.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
117conf_mall.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
118conf_mall.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
119conf_mall.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
120conf_mall.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
121conf_mall.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
122conf_mall.o: ../../include/openssl/engine.h ../../include/openssl/err.h
123conf_mall.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
124conf_mall.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
125conf_mall.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
126conf_mall.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
127conf_mall.o: ../../include/openssl/objects.h
128conf_mall.o: ../../include/openssl/opensslconf.h
129conf_mall.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
130conf_mall.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
131conf_mall.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
132conf_mall.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
133conf_mall.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
134conf_mall.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
135conf_mall.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
136conf_mall.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
137conf_mall.o: ../../include/openssl/x509_vfy.h ../cryptlib.h conf_mall.c
138conf_mod.o: ../../e_os.h ../../include/openssl/aes.h
139conf_mod.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
140conf_mod.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
141conf_mod.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
142conf_mod.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
143conf_mod.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
144conf_mod.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
145conf_mod.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
146conf_mod.o: ../../include/openssl/err.h ../../include/openssl/evp.h
147conf_mod.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
148conf_mod.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
149conf_mod.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
150conf_mod.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
151conf_mod.o: ../../include/openssl/opensslconf.h
152conf_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
153conf_mod.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
154conf_mod.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
155conf_mod.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
156conf_mod.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
157conf_mod.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
158conf_mod.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
159conf_mod.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
160conf_mod.o: ../cryptlib.h conf_mod.c
161conf_sap.o: ../../e_os.h ../../include/openssl/aes.h
162conf_sap.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
163conf_sap.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
164conf_sap.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
165conf_sap.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
166conf_sap.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
167conf_sap.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
168conf_sap.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
169conf_sap.o: ../../include/openssl/engine.h ../../include/openssl/err.h
170conf_sap.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
171conf_sap.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
172conf_sap.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
173conf_sap.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
174conf_sap.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
175conf_sap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
176conf_sap.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
177conf_sap.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
178conf_sap.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
179conf_sap.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
180conf_sap.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
181conf_sap.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
182conf_sap.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
183conf_sap.o: ../../include/openssl/x509_vfy.h ../cryptlib.h conf_sap.c
diff --git a/src/lib/libcrypto/conf/README b/src/lib/libcrypto/conf/README
index ca58d0240f..96e53b34ed 100644
--- a/src/lib/libcrypto/conf/README
+++ b/src/lib/libcrypto/conf/README
@@ -1,8 +1,3 @@
1WARNING WARNING WARNING!!!
2
3This stuff is experimental, may change radically or be deleted altogether
4before OpenSSL 0.9.7 release. You have been warned!
5
6Configuration modules. These are a set of modules which can perform 1Configuration modules. These are a set of modules which can perform
7various configuration functions. 2various configuration functions.
8 3
@@ -13,7 +8,7 @@ The routines read a configuration file set up like this:
13 8
14----- 9-----
15#default section 10#default section
16openssl_init=init_section 11openssl_conf=init_section
17 12
18[init_section] 13[init_section]
19 14
@@ -30,29 +25,27 @@ path=/some/path/to/some/dso.so
30other_stuff=other_value 25other_stuff=other_value
31---- 26----
32 27
33When this file is loaded a configuration module with the specified 28When this file is loaded a configuration module with the specified string
34string (module* in the above example) is looked up and its init 29(module* in the above example) is looked up and its init function called as:
35function called as:
36 30
37int conf_init_func(CONF_IMODULE *md, CONF *cnf); 31int conf_init_func(CONF_IMODULE *md, CONF *cnf);
38 32
39The function can then take whatever action is appropriate, for example 33The function can then take whatever action is appropriate, for example further
40further lookups based on the value. Multiple instances of the same 34lookups based on the value. Multiple instances of the same config module can be
41config module can be loaded. 35loaded.
42 36
43When the application closes down the modules are cleaned up by calling 37When the application closes down the modules are cleaned up by calling an
44an optional finish function: 38optional finish function:
45 39
46void conf_finish_func(CONF_IMODULE *md); 40void conf_finish_func(CONF_IMODULE *md);
47 41
48The finish functions are called in reverse order: that is the last module 42The finish functions are called in reverse order: that is the last module
49loaded is the first one cleaned up. 43loaded is the first one cleaned up.
50 44
51If no module exists with a given name then an attempt is made to load 45If no module exists with a given name then an attempt is made to load a DSO
52a DSO with the supplied name. This might mean that "module3" attempts 46with the supplied name. This might mean that "module3" attempts to load a DSO
53to load a DSO called libmodule3.so or module3.dll for example. An explicit 47called libmodule3.so or module3.dll for example. An explicit DSO name can be
54DSO name can be given by including a separate section as in the module4 example 48given by including a separate section as in the module4 example above.
55above.
56 49
57The DSO is expected to at least contain an initialization function: 50The DSO is expected to at least contain an initialization function:
58 51
@@ -64,15 +57,17 @@ void OPENSSL_finish(CONF_IMODULE *md);
64 57
65Static modules can also be added using, 58Static modules can also be added using,
66 59
67int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func *ffunc); 60int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func
61*ffunc);
68 62
69where "name" is the name in the configuration file this function corresponds to. 63where "name" is the name in the configuration file this function corresponds
64to.
70 65
71A set of builtin modules (currently only an ASN1 non functional test module) can be 66A set of builtin modules (currently only an ASN1 non functional test module)
72added by calling OPENSSL_load_builtin_modules(). 67can be added by calling OPENSSL_load_builtin_modules().
73 68
74The function OPENSSL_config() is intended as a simple configuration function that 69The function OPENSSL_config() is intended as a simple configuration function
75any application can call to perform various default configuration tasks. It uses the 70that any application can call to perform various default configuration tasks.
76file openssl.cnf in the usual locations. 71It uses the file openssl.cnf in the usual locations.
77 72
78 73
diff --git a/src/lib/libcrypto/conf/conf.h b/src/lib/libcrypto/conf/conf.h
index 8aa06bc5ec..c2199978a3 100644
--- a/src/lib/libcrypto/conf/conf.h
+++ b/src/lib/libcrypto/conf/conf.h
@@ -79,8 +79,7 @@ typedef struct
79 } CONF_VALUE; 79 } CONF_VALUE;
80 80
81DECLARE_STACK_OF(CONF_VALUE) 81DECLARE_STACK_OF(CONF_VALUE)
82DECLARE_STACK_OF(CONF_MODULE) 82DECLARE_LHASH_OF(CONF_VALUE);
83DECLARE_STACK_OF(CONF_IMODULE)
84 83
85struct conf_st; 84struct conf_st;
86struct conf_method_st; 85struct conf_method_st;
@@ -105,6 +104,9 @@ struct conf_method_st
105typedef struct conf_imodule_st CONF_IMODULE; 104typedef struct conf_imodule_st CONF_IMODULE;
106typedef struct conf_module_st CONF_MODULE; 105typedef struct conf_module_st CONF_MODULE;
107 106
107DECLARE_STACK_OF(CONF_MODULE)
108DECLARE_STACK_OF(CONF_IMODULE)
109
108/* DSO module function typedefs */ 110/* DSO module function typedefs */
109typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); 111typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf);
110typedef void conf_finish_func(CONF_IMODULE *md); 112typedef void conf_finish_func(CONF_IMODULE *md);
@@ -117,18 +119,23 @@ typedef void conf_finish_func(CONF_IMODULE *md);
117#define CONF_MFLAGS_DEFAULT_SECTION 0x20 119#define CONF_MFLAGS_DEFAULT_SECTION 0x20
118 120
119int CONF_set_default_method(CONF_METHOD *meth); 121int CONF_set_default_method(CONF_METHOD *meth);
120void CONF_set_nconf(CONF *conf,LHASH *hash); 122void CONF_set_nconf(CONF *conf,LHASH_OF(CONF_VALUE) *hash);
121LHASH *CONF_load(LHASH *conf,const char *file,long *eline); 123LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf,const char *file,
124 long *eline);
122#ifndef OPENSSL_NO_FP_API 125#ifndef OPENSSL_NO_FP_API
123LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); 126LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
127 long *eline);
124#endif 128#endif
125LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); 129LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,long *eline);
126STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); 130STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
127char *CONF_get_string(LHASH *conf,const char *group,const char *name); 131 const char *section);
128long CONF_get_number(LHASH *conf,const char *group,const char *name); 132char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group,
129void CONF_free(LHASH *conf); 133 const char *name);
130int CONF_dump_fp(LHASH *conf, FILE *out); 134long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group,
131int CONF_dump_bio(LHASH *conf, BIO *out); 135 const char *name);
136void CONF_free(LHASH_OF(CONF_VALUE) *conf);
137int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
138int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
132 139
133void OPENSSL_config(const char *config_name); 140void OPENSSL_config(const char *config_name);
134void OPENSSL_no_config(void); 141void OPENSSL_no_config(void);
@@ -140,7 +147,7 @@ struct conf_st
140 { 147 {
141 CONF_METHOD *meth; 148 CONF_METHOD *meth;
142 void *meth_data; 149 void *meth_data;
143 LHASH *data; 150 LHASH_OF(CONF_VALUE) *data;
144 }; 151 };
145 152
146CONF *NCONF_new(CONF_METHOD *meth); 153CONF *NCONF_new(CONF_METHOD *meth);
@@ -214,6 +221,7 @@ void ERR_load_CONF_strings(void);
214#define CONF_F_CONF_LOAD_BIO 102 221#define CONF_F_CONF_LOAD_BIO 102
215#define CONF_F_CONF_LOAD_FP 103 222#define CONF_F_CONF_LOAD_FP 103
216#define CONF_F_CONF_MODULES_LOAD 116 223#define CONF_F_CONF_MODULES_LOAD 116
224#define CONF_F_CONF_PARSE_LIST 119
217#define CONF_F_DEF_LOAD 120 225#define CONF_F_DEF_LOAD 120
218#define CONF_F_DEF_LOAD_BIO 121 226#define CONF_F_DEF_LOAD_BIO 121
219#define CONF_F_MODULE_INIT 115 227#define CONF_F_MODULE_INIT 115
@@ -233,6 +241,7 @@ void ERR_load_CONF_strings(void);
233 241
234/* Reason codes. */ 242/* Reason codes. */
235#define CONF_R_ERROR_LOADING_DSO 110 243#define CONF_R_ERROR_LOADING_DSO 110
244#define CONF_R_LIST_CANNOT_BE_NULL 115
236#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 245#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
237#define CONF_R_MISSING_EQUAL_SIGN 101 246#define CONF_R_MISSING_EQUAL_SIGN 101
238#define CONF_R_MISSING_FINISH_FUNCTION 111 247#define CONF_R_MISSING_FINISH_FUNCTION 111
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c
index 909d72b4b8..22617e5fa1 100644
--- a/src/lib/libcrypto/conf/conf_api.c
+++ b/src/lib/libcrypto/conf/conf_api.c
@@ -69,16 +69,12 @@
69#include <openssl/conf_api.h> 69#include <openssl/conf_api.h>
70#include "e_os.h" 70#include "e_os.h"
71 71
72static void value_free_hash(CONF_VALUE *a, LHASH *conf); 72static void value_free_hash_doall_arg(CONF_VALUE *a,
73static void value_free_stack(CONF_VALUE *a,LHASH *conf); 73 LHASH_OF(CONF_VALUE) *conf);
74static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *) 74static void value_free_stack_doall(CONF_VALUE *a);
75static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *) 75static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE,
76/* We don't use function pointer casting or wrapper functions - but cast each 76 LHASH_OF(CONF_VALUE))
77 * callback parameter inside the callback functions. */ 77static IMPLEMENT_LHASH_DOALL_FN(value_free_stack, CONF_VALUE)
78/* static unsigned long hash(CONF_VALUE *v); */
79static unsigned long hash(const void *v_void);
80/* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */
81static int cmp_conf(const void *a_void,const void *b_void);
82 78
83/* Up until OpenSSL 0.9.5a, this was get_section */ 79/* Up until OpenSSL 0.9.5a, this was get_section */
84CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section) 80CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
@@ -88,7 +84,7 @@ CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
88 if ((conf == NULL) || (section == NULL)) return(NULL); 84 if ((conf == NULL) || (section == NULL)) return(NULL);
89 vv.name=NULL; 85 vv.name=NULL;
90 vv.section=(char *)section; 86 vv.section=(char *)section;
91 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 87 v=lh_CONF_VALUE_retrieve(conf->data,&vv);
92 return(v); 88 return(v);
93 } 89 }
94 90
@@ -118,7 +114,7 @@ int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value)
118 return 0; 114 return 0;
119 } 115 }
120 116
121 v = (CONF_VALUE *)lh_insert(conf->data, value); 117 v = lh_CONF_VALUE_insert(conf->data, value);
122 if (v != NULL) 118 if (v != NULL)
123 { 119 {
124 (void)sk_CONF_VALUE_delete_ptr(ts,v); 120 (void)sk_CONF_VALUE_delete_ptr(ts,v);
@@ -141,24 +137,24 @@ char *_CONF_get_string(const CONF *conf, const char *section, const char *name)
141 { 137 {
142 vv.name=(char *)name; 138 vv.name=(char *)name;
143 vv.section=(char *)section; 139 vv.section=(char *)section;
144 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 140 v=lh_CONF_VALUE_retrieve(conf->data,&vv);
145 if (v != NULL) return(v->value); 141 if (v != NULL) return(v->value);
146 if (strcmp(section,"ENV") == 0) 142 if (strcmp(section,"ENV") == 0)
147 { 143 {
148 p=Getenv(name); 144 p=getenv(name);
149 if (p != NULL) return(p); 145 if (p != NULL) return(p);
150 } 146 }
151 } 147 }
152 vv.section="default"; 148 vv.section="default";
153 vv.name=(char *)name; 149 vv.name=(char *)name;
154 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 150 v=lh_CONF_VALUE_retrieve(conf->data,&vv);
155 if (v != NULL) 151 if (v != NULL)
156 return(v->value); 152 return(v->value);
157 else 153 else
158 return(NULL); 154 return(NULL);
159 } 155 }
160 else 156 else
161 return(Getenv(name)); 157 return(getenv(name));
162 } 158 }
163 159
164#if 0 /* There's no way to provide error checking with this function, so 160#if 0 /* There's no way to provide error checking with this function, so
@@ -182,6 +178,34 @@ long _CONF_get_number(CONF *conf, char *section, char *name)
182 } 178 }
183#endif 179#endif
184 180
181static unsigned long conf_value_hash(const CONF_VALUE *v)
182 {
183 return (lh_strhash(v->section)<<2)^lh_strhash(v->name);
184 }
185static IMPLEMENT_LHASH_HASH_FN(conf_value, CONF_VALUE)
186
187static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b)
188 {
189 int i;
190
191 if (a->section != b->section)
192 {
193 i=strcmp(a->section,b->section);
194 if (i) return(i);
195 }
196
197 if ((a->name != NULL) && (b->name != NULL))
198 {
199 i=strcmp(a->name,b->name);
200 return(i);
201 }
202 else if (a->name == b->name)
203 return(0);
204 else
205 return((a->name == NULL)?-1:1);
206 }
207static IMPLEMENT_LHASH_COMP_FN(conf_value, CONF_VALUE)
208
185int _CONF_new_data(CONF *conf) 209int _CONF_new_data(CONF *conf)
186 { 210 {
187 if (conf == NULL) 211 if (conf == NULL)
@@ -189,7 +213,7 @@ int _CONF_new_data(CONF *conf)
189 return 0; 213 return 0;
190 } 214 }
191 if (conf->data == NULL) 215 if (conf->data == NULL)
192 if ((conf->data = lh_new(hash, cmp_conf)) == NULL) 216 if ((conf->data = lh_CONF_VALUE_new()) == NULL)
193 { 217 {
194 return 0; 218 return 0;
195 } 219 }
@@ -200,105 +224,73 @@ void _CONF_free_data(CONF *conf)
200 { 224 {
201 if (conf == NULL || conf->data == NULL) return; 225 if (conf == NULL || conf->data == NULL) return;
202 226
203 conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()' 227 lh_CONF_VALUE_down_load(conf->data)=0; /* evil thing to make
204 * works as expected */ 228 * sure the 'OPENSSL_free()' works as
205 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash), 229 * expected */
206 conf->data); 230 lh_CONF_VALUE_doall_arg(conf->data,
231 LHASH_DOALL_ARG_FN(value_free_hash),
232 LHASH_OF(CONF_VALUE), conf->data);
207 233
208 /* We now have only 'section' entries in the hash table. 234 /* We now have only 'section' entries in the hash table.
209 * Due to problems with */ 235 * Due to problems with */
210 236
211 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack), 237 lh_CONF_VALUE_doall(conf->data, LHASH_DOALL_FN(value_free_stack));
212 conf->data); 238 lh_CONF_VALUE_free(conf->data);
213 lh_free(conf->data);
214 } 239 }
215 240
216static void value_free_hash(CONF_VALUE *a, LHASH *conf) 241static void value_free_hash_doall_arg(CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf)
217 { 242 {
218 if (a->name != NULL) 243 if (a->name != NULL)
219 { 244 (void)lh_CONF_VALUE_delete(conf,a);
220 a=(CONF_VALUE *)lh_delete(conf,a);
221 }
222 } 245 }
223 246
224static void value_free_stack(CONF_VALUE *a, LHASH *conf) 247static void value_free_stack_doall(CONF_VALUE *a)
225 { 248 {
226 CONF_VALUE *vv; 249 CONF_VALUE *vv;
227 STACK *sk; 250 STACK_OF(CONF_VALUE) *sk;
228 int i; 251 int i;
229 252
230 if (a->name != NULL) return; 253 if (a->name != NULL) return;
231 254
232 sk=(STACK *)a->value; 255 sk=(STACK_OF(CONF_VALUE) *)a->value;
233 for (i=sk_num(sk)-1; i>=0; i--) 256 for (i=sk_CONF_VALUE_num(sk)-1; i>=0; i--)
234 { 257 {
235 vv=(CONF_VALUE *)sk_value(sk,i); 258 vv=sk_CONF_VALUE_value(sk,i);
236 OPENSSL_free(vv->value); 259 OPENSSL_free(vv->value);
237 OPENSSL_free(vv->name); 260 OPENSSL_free(vv->name);
238 OPENSSL_free(vv); 261 OPENSSL_free(vv);
239 } 262 }
240 if (sk != NULL) sk_free(sk); 263 if (sk != NULL) sk_CONF_VALUE_free(sk);
241 OPENSSL_free(a->section); 264 OPENSSL_free(a->section);
242 OPENSSL_free(a); 265 OPENSSL_free(a);
243 } 266 }
244 267
245/* static unsigned long hash(CONF_VALUE *v) */
246static 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) */
253static 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 */ 268/* Up until OpenSSL 0.9.5a, this was new_section */
277CONF_VALUE *_CONF_new_section(CONF *conf, const char *section) 269CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
278 { 270 {
279 STACK *sk=NULL; 271 STACK_OF(CONF_VALUE) *sk=NULL;
280 int ok=0,i; 272 int ok=0,i;
281 CONF_VALUE *v=NULL,*vv; 273 CONF_VALUE *v=NULL,*vv;
282 274
283 if ((sk=sk_new_null()) == NULL) 275 if ((sk=sk_CONF_VALUE_new_null()) == NULL)
284 goto err; 276 goto err;
285 if ((v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL) 277 if ((v=OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL)
286 goto err; 278 goto err;
287 i=strlen(section)+1; 279 i=strlen(section)+1;
288 if ((v->section=(char *)OPENSSL_malloc(i)) == NULL) 280 if ((v->section=OPENSSL_malloc(i)) == NULL)
289 goto err; 281 goto err;
290 282
291 memcpy(v->section,section,i); 283 memcpy(v->section,section,i);
292 v->name=NULL; 284 v->name=NULL;
293 v->value=(char *)sk; 285 v->value=(char *)sk;
294 286
295 vv=(CONF_VALUE *)lh_insert(conf->data,v); 287 vv=lh_CONF_VALUE_insert(conf->data,v);
296 assert(vv == NULL); 288 assert(vv == NULL);
297 ok=1; 289 ok=1;
298err: 290err:
299 if (!ok) 291 if (!ok)
300 { 292 {
301 if (sk != NULL) sk_free(sk); 293 if (sk != NULL) sk_CONF_VALUE_free(sk);
302 if (v != NULL) OPENSSL_free(v); 294 if (v != NULL) OPENSSL_free(v);
303 v=NULL; 295 v=NULL;
304 } 296 }
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c
index d8bce8732a..0b571b0394 100644
--- a/src/lib/libcrypto/conf/conf_def.c
+++ b/src/lib/libcrypto/conf/conf_def.c
@@ -129,7 +129,7 @@ static CONF *def_create(CONF_METHOD *meth)
129 { 129 {
130 CONF *ret; 130 CONF *ret;
131 131
132 ret = (CONF *)OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *)); 132 ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
133 if (ret) 133 if (ret)
134 if (meth->init(ret) == 0) 134 if (meth->init(ret) == 0)
135 { 135 {
@@ -145,7 +145,7 @@ static int def_init_default(CONF *conf)
145 return 0; 145 return 0;
146 146
147 conf->meth = &default_method; 147 conf->meth = &default_method;
148 conf->meth_data = (void *)CONF_type_default; 148 conf->meth_data = CONF_type_default;
149 conf->data = NULL; 149 conf->data = NULL;
150 150
151 return 1; 151 return 1;
@@ -722,7 +722,7 @@ static char *scan_dquote(CONF *conf, char *p)
722 return(p); 722 return(p);
723 } 723 }
724 724
725static void dump_value(CONF_VALUE *a, BIO *out) 725static void dump_value_doall_arg(CONF_VALUE *a, BIO *out)
726 { 726 {
727 if (a->name) 727 if (a->name)
728 BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value); 728 BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
@@ -730,11 +730,12 @@ static void dump_value(CONF_VALUE *a, BIO *out)
730 BIO_printf(out, "[[%s]]\n", a->section); 730 BIO_printf(out, "[[%s]]\n", a->section);
731 } 731 }
732 732
733static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *) 733static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, BIO)
734 734
735static int def_dump(const CONF *conf, BIO *out) 735static int def_dump(const CONF *conf, BIO *out)
736 { 736 {
737 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out); 737 lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value),
738 BIO, out);
738 return 1; 739 return 1;
739 } 740 }
740 741
diff --git a/src/lib/libcrypto/conf/conf_err.c b/src/lib/libcrypto/conf/conf_err.c
index a16a5e0bd4..25bb5dc9aa 100644
--- a/src/lib/libcrypto/conf/conf_err.c
+++ b/src/lib/libcrypto/conf/conf_err.c
@@ -1,6 +1,6 @@
1/* crypto/conf/conf_err.c */ 1/* crypto/conf/conf_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -75,6 +75,7 @@ static ERR_STRING_DATA CONF_str_functs[]=
75{ERR_FUNC(CONF_F_CONF_LOAD_BIO), "CONF_load_bio"}, 75{ERR_FUNC(CONF_F_CONF_LOAD_BIO), "CONF_load_bio"},
76{ERR_FUNC(CONF_F_CONF_LOAD_FP), "CONF_load_fp"}, 76{ERR_FUNC(CONF_F_CONF_LOAD_FP), "CONF_load_fp"},
77{ERR_FUNC(CONF_F_CONF_MODULES_LOAD), "CONF_modules_load"}, 77{ERR_FUNC(CONF_F_CONF_MODULES_LOAD), "CONF_modules_load"},
78{ERR_FUNC(CONF_F_CONF_PARSE_LIST), "CONF_parse_list"},
78{ERR_FUNC(CONF_F_DEF_LOAD), "DEF_LOAD"}, 79{ERR_FUNC(CONF_F_DEF_LOAD), "DEF_LOAD"},
79{ERR_FUNC(CONF_F_DEF_LOAD_BIO), "DEF_LOAD_BIO"}, 80{ERR_FUNC(CONF_F_DEF_LOAD_BIO), "DEF_LOAD_BIO"},
80{ERR_FUNC(CONF_F_MODULE_INIT), "MODULE_INIT"}, 81{ERR_FUNC(CONF_F_MODULE_INIT), "MODULE_INIT"},
@@ -97,6 +98,7 @@ static ERR_STRING_DATA CONF_str_functs[]=
97static ERR_STRING_DATA CONF_str_reasons[]= 98static ERR_STRING_DATA CONF_str_reasons[]=
98 { 99 {
99{ERR_REASON(CONF_R_ERROR_LOADING_DSO) ,"error loading dso"}, 100{ERR_REASON(CONF_R_ERROR_LOADING_DSO) ,"error loading dso"},
101{ERR_REASON(CONF_R_LIST_CANNOT_BE_NULL) ,"list cannot be null"},
100{ERR_REASON(CONF_R_MISSING_CLOSE_SQUARE_BRACKET),"missing close square bracket"}, 102{ERR_REASON(CONF_R_MISSING_CLOSE_SQUARE_BRACKET),"missing close square bracket"},
101{ERR_REASON(CONF_R_MISSING_EQUAL_SIGN) ,"missing equal sign"}, 103{ERR_REASON(CONF_R_MISSING_EQUAL_SIGN) ,"missing equal sign"},
102{ERR_REASON(CONF_R_MISSING_FINISH_FUNCTION),"missing finish function"}, 104{ERR_REASON(CONF_R_MISSING_FINISH_FUNCTION),"missing finish function"},
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c
index 2a3399d269..54046defca 100644
--- a/src/lib/libcrypto/conf/conf_lib.c
+++ b/src/lib/libcrypto/conf/conf_lib.c
@@ -69,7 +69,7 @@ static CONF_METHOD *default_CONF_method=NULL;
69 69
70/* Init a 'CONF' structure from an old LHASH */ 70/* Init a 'CONF' structure from an old LHASH */
71 71
72void CONF_set_nconf(CONF *conf, LHASH *hash) 72void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash)
73 { 73 {
74 if (default_CONF_method == NULL) 74 if (default_CONF_method == NULL)
75 default_CONF_method = NCONF_default(); 75 default_CONF_method = NCONF_default();
@@ -87,9 +87,10 @@ int CONF_set_default_method(CONF_METHOD *meth)
87 return 1; 87 return 1;
88 } 88 }
89 89
90LHASH *CONF_load(LHASH *conf, const char *file, long *eline) 90LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
91 long *eline)
91 { 92 {
92 LHASH *ltmp; 93 LHASH_OF(CONF_VALUE) *ltmp;
93 BIO *in=NULL; 94 BIO *in=NULL;
94 95
95#ifdef OPENSSL_SYS_VMS 96#ifdef OPENSSL_SYS_VMS
@@ -110,10 +111,11 @@ LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
110 } 111 }
111 112
112#ifndef OPENSSL_NO_FP_API 113#ifndef OPENSSL_NO_FP_API
113LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline) 114LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
115 long *eline)
114 { 116 {
115 BIO *btmp; 117 BIO *btmp;
116 LHASH *ltmp; 118 LHASH_OF(CONF_VALUE) *ltmp;
117 if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { 119 if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
118 CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB); 120 CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
119 return NULL; 121 return NULL;
@@ -124,7 +126,8 @@ LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
124 } 126 }
125#endif 127#endif
126 128
127LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline) 129LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,
130 long *eline)
128 { 131 {
129 CONF ctmp; 132 CONF ctmp;
130 int ret; 133 int ret;
@@ -137,7 +140,8 @@ LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
137 return NULL; 140 return NULL;
138 } 141 }
139 142
140STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section) 143STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
144 const char *section)
141 { 145 {
142 if (conf == NULL) 146 if (conf == NULL)
143 { 147 {
@@ -151,7 +155,8 @@ STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section)
151 } 155 }
152 } 156 }
153 157
154char *CONF_get_string(LHASH *conf,const char *group,const char *name) 158char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group,
159 const char *name)
155 { 160 {
156 if (conf == NULL) 161 if (conf == NULL)
157 { 162 {
@@ -165,7 +170,8 @@ char *CONF_get_string(LHASH *conf,const char *group,const char *name)
165 } 170 }
166 } 171 }
167 172
168long CONF_get_number(LHASH *conf,const char *group,const char *name) 173long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group,
174 const char *name)
169 { 175 {
170 int status; 176 int status;
171 long result = 0; 177 long result = 0;
@@ -189,7 +195,7 @@ long CONF_get_number(LHASH *conf,const char *group,const char *name)
189 return result; 195 return result;
190 } 196 }
191 197
192void CONF_free(LHASH *conf) 198void CONF_free(LHASH_OF(CONF_VALUE) *conf)
193 { 199 {
194 CONF ctmp; 200 CONF ctmp;
195 CONF_set_nconf(&ctmp, conf); 201 CONF_set_nconf(&ctmp, conf);
@@ -197,7 +203,7 @@ void CONF_free(LHASH *conf)
197 } 203 }
198 204
199#ifndef OPENSSL_NO_FP_API 205#ifndef OPENSSL_NO_FP_API
200int CONF_dump_fp(LHASH *conf, FILE *out) 206int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out)
201 { 207 {
202 BIO *btmp; 208 BIO *btmp;
203 int ret; 209 int ret;
@@ -212,7 +218,7 @@ int CONF_dump_fp(LHASH *conf, FILE *out)
212 } 218 }
213#endif 219#endif
214 220
215int CONF_dump_bio(LHASH *conf, BIO *out) 221int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out)
216 { 222 {
217 CONF ctmp; 223 CONF ctmp;
218 CONF_set_nconf(&ctmp, conf); 224 CONF_set_nconf(&ctmp, conf);
diff --git a/src/lib/libcrypto/conf/conf_mall.c b/src/lib/libcrypto/conf/conf_mall.c
index 1cc1fd5534..c6f4cb2d55 100644
--- a/src/lib/libcrypto/conf/conf_mall.c
+++ b/src/lib/libcrypto/conf/conf_mall.c
@@ -63,7 +63,6 @@
63#include <openssl/dso.h> 63#include <openssl/dso.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#include <openssl/evp.h>
67#ifndef OPENSSL_NO_ENGINE 66#ifndef OPENSSL_NO_ENGINE
68#include <openssl/engine.h> 67#include <openssl/engine.h>
69#endif 68#endif
@@ -77,6 +76,5 @@ void OPENSSL_load_builtin_modules(void)
77#ifndef OPENSSL_NO_ENGINE 76#ifndef OPENSSL_NO_ENGINE
78 ENGINE_add_conf_module(); 77 ENGINE_add_conf_module();
79#endif 78#endif
80 EVP_add_alg_module();
81 } 79 }
82 80
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index ee9c677d9b..df1642a0a5 100644
--- a/src/lib/libcrypto/conf/conf_mod.c
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -582,8 +582,14 @@ int CONF_parse_list(const char *list_, int sep, int nospc,
582 { 582 {
583 int ret; 583 int ret;
584 const char *lstart, *tmpend, *p; 584 const char *lstart, *tmpend, *p;
585 lstart = list_;
586 585
586 if(list_ == NULL)
587 {
588 CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL);
589 return 0;
590 }
591
592 lstart = list_;
587 for(;;) 593 for(;;)
588 { 594 {
589 if (nospc) 595 if (nospc)