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.ssl49
-rw-r--r--src/lib/libcrypto/conf/cnf_save.c7
-rw-r--r--src/lib/libcrypto/conf/conf.c211
-rw-r--r--src/lib/libcrypto/conf/conf.err12
-rw-r--r--src/lib/libcrypto/conf/conf.h32
-rw-r--r--src/lib/libcrypto/conf/conf_err.c120
-rw-r--r--src/lib/libcrypto/conf/conf_lcl.h14
-rw-r--r--src/lib/libcrypto/conf/keysets.pl2
-rw-r--r--src/lib/libcrypto/conf/test.c5
9 files changed, 235 insertions, 217 deletions
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl
index 00e917aa44..64b763f068 100644
--- a/src/lib/libcrypto/conf/Makefile.ssl
+++ b/src/lib/libcrypto/conf/Makefile.ssl
@@ -7,24 +7,24 @@ TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
10INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl 14MAKEDEPEND= $(TOP)/util/domd $(TOP)
13MAKEFILE= Makefile.ssl 15MAKEFILE= Makefile.ssl
14AR= ar r 16AR= ar r
15 17
16CFLAGS= $(INCLUDES) $(CFLAG) 18CFLAGS= $(INCLUDES) $(CFLAG)
17 19
18ERR=conf
19ERRC=conf_err
20GENERAL=Makefile 20GENERAL=Makefile
21TEST= 21TEST=
22APPS= 22APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= conf.c $(ERRC).c 25LIBSRC= conf.c conf_err.c
26 26
27LIBOBJ= conf.o $(ERRC).o 27LIBOBJ= conf.o conf_err.o
28 28
29SRC= $(LIBSRC) 29SRC= $(LIBSRC)
30 30
@@ -40,24 +40,23 @@ all: lib
40 40
41lib: $(LIBOBJ) 41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB) 43 $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
47 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48 48
49links: 49links:
50 /bin/rm -f Makefile 50 @$(TOP)/util/point.sh Makefile.ssl Makefile
51 $(TOP)/util/point.sh Makefile.ssl Makefile ; 51 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
52 $(TOP)/util/mklink.sh ../../include $(EXHEADER) 52 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
53 $(TOP)/util/mklink.sh ../../test $(TEST) 53 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
54 $(TOP)/util/mklink.sh ../../apps $(APPS)
55 54
56install: 55install:
57 @for i in $(EXHEADER) ; \ 56 @for i in $(EXHEADER) ; \
58 do \ 57 do \
59 (cp $$i $(INSTALLTOP)/include/$$i; \ 58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
60 chmod 644 $(INSTALLTOP)/include/$$i ); \ 59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
61 done; 60 done;
62 61
63tags: 62tags:
@@ -69,17 +68,25 @@ lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff 68 lint -DLINT $(INCLUDES) $(SRC)>fluff
70 69
71depend: 70depend:
72 $(MAKEDEPEND) $(INCLUDES) $(LIBSRC) 71 $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(LIBSRC)
73 72
74dclean: 73dclean:
75 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 74 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
76 mv -f Makefile.new $(MAKEFILE) 75 mv -f Makefile.new $(MAKEFILE)
77 76
78clean: 77clean:
79 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 78 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81errors:
82 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
83 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
84 79
85# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81
82conf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
83conf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
84conf.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
85conf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
86conf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
87conf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
88conf.o: ../cryptlib.h conf_lcl.h
89conf_err.o: ../../include/openssl/bio.h ../../include/openssl/conf.h
90conf_err.o: ../../include/openssl/crypto.h ../../include/openssl/err.h
91conf_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslv.h
92conf_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
diff --git a/src/lib/libcrypto/conf/cnf_save.c b/src/lib/libcrypto/conf/cnf_save.c
index c9018de10e..e907cc2242 100644
--- a/src/lib/libcrypto/conf/cnf_save.c
+++ b/src/lib/libcrypto/conf/cnf_save.c
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "conf.h" 60#include <openssl/conf.h>
61 61
62void print_conf(CONF_VALUE *cv); 62void print_conf(CONF_VALUE *cv);
63 63
@@ -66,7 +66,7 @@ main()
66 LHASH *conf; 66 LHASH *conf;
67 long l; 67 long l;
68 68
69 conf=CONF_load(NULL,"../../apps/ssleay.cnf",&l); 69 conf=CONF_load(NULL,"../../apps/openssl.cnf",&l);
70 if (conf == NULL) 70 if (conf == NULL)
71 { 71 {
72 fprintf(stderr,"error loading config, line %ld\n",l); 72 fprintf(stderr,"error loading config, line %ld\n",l);
@@ -77,8 +77,7 @@ main()
77 } 77 }
78 78
79 79
80void print_conf(cv) 80void print_conf(CONF_VALUE *cv)
81CONF_VALUE *cv;
82 { 81 {
83 int i; 82 int i;
84 CONF_VALUE *v; 83 CONF_VALUE *v;
diff --git a/src/lib/libcrypto/conf/conf.c b/src/lib/libcrypto/conf/conf.c
index 9e84300c5e..7d8b89168a 100644
--- a/src/lib/libcrypto/conf/conf.c
+++ b/src/lib/libcrypto/conf/conf.c
@@ -59,19 +59,18 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <errno.h> 60#include <errno.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include "stack.h" 62#include <openssl/stack.h>
63#include "lhash.h" 63#include <openssl/lhash.h>
64#include "conf.h" 64#include <openssl/conf.h>
65#include "buffer.h" 65#include <openssl/buffer.h>
66#include "err.h" 66#include <openssl/err.h>
67 67
68#include "conf_lcl.h" 68#include "conf_lcl.h"
69 69
70#ifndef NOPROTO
71static void value_free_hash(CONF_VALUE *a, LHASH *conf); 70static void value_free_hash(CONF_VALUE *a, LHASH *conf);
72static void value_free_stack(CONF_VALUE *a,LHASH *conf); 71static void value_free_stack(CONF_VALUE *a,LHASH *conf);
73static unsigned long hash(CONF_VALUE *v); 72static unsigned long hash(CONF_VALUE *v);
74static int cmp(CONF_VALUE *a,CONF_VALUE *b); 73static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b);
75static char *eat_ws(char *p); 74static char *eat_ws(char *p);
76static char *eat_alpha_numeric(char *p); 75static char *eat_alpha_numeric(char *p);
77static void clear_comments(char *p); 76static void clear_comments(char *p);
@@ -79,71 +78,84 @@ static int str_copy(LHASH *conf,char *section,char **to, char *from);
79static char *scan_quote(char *p); 78static char *scan_quote(char *p);
80static CONF_VALUE *new_section(LHASH *conf,char *section); 79static CONF_VALUE *new_section(LHASH *conf,char *section);
81static CONF_VALUE *get_section(LHASH *conf,char *section); 80static CONF_VALUE *get_section(LHASH *conf,char *section);
81#define scan_esc(p) ((((p)[1] == '\0')?(p++):(p+=2)),p)
82
83const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
84
85
86LHASH *CONF_load(LHASH *h, const char *file, long *line)
87 {
88 LHASH *ltmp;
89 FILE *in=NULL;
90
91#ifdef VMS
92 in=fopen(file,"r");
82#else 93#else
83static void value_free_hash(); 94 in=fopen(file,"rb");
84static void value_free_stack();
85static unsigned long hash();
86static int cmp();
87static char *eat_ws();
88static char *eat_alpha_numeric();
89static void clear_comments();
90static int str_copy();
91static char *scan_quote();
92static CONF_VALUE *new_section();
93static CONF_VALUE *get_section();
94#endif 95#endif
96 if (in == NULL)
97 {
98 SYSerr(SYS_F_FOPEN,get_last_sys_error());
99 ERR_set_error_data(BUF_strdup(file),
100 ERR_TXT_MALLOCED|ERR_TXT_STRING);
101 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
102 return NULL;
103 }
95 104
96#define scan_esc(p) ((*(++p) == '\0')?(p):(++p)) 105 ltmp = CONF_load_fp(h, in, line);
106 fclose(in);
97 107
98char *CONF_version="CONF part of SSLeay 0.9.0b 29-Jun-1998"; 108 return ltmp;
109}
110
111LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)
112{
113 BIO *btmp;
114 LHASH *ltmp;
115 if(!(btmp = BIO_new_fp(in, BIO_NOCLOSE))) {
116 CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
117 return NULL;
118 }
119 ltmp = CONF_load_bio(h, btmp, line);
120 BIO_free(btmp);
121 return ltmp;
122}
99 123
100LHASH *CONF_load(h,file,line) 124LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line)
101LHASH *h;
102char *file;
103long *line;
104 { 125 {
105 LHASH *ret=NULL; 126 LHASH *ret=NULL;
106 FILE *in=NULL;
107#define BUFSIZE 512 127#define BUFSIZE 512
128 char btmp[16];
108 int bufnum=0,i,ii; 129 int bufnum=0,i,ii;
109 BUF_MEM *buff=NULL; 130 BUF_MEM *buff=NULL;
110 char *s,*p,*end; 131 char *s,*p,*end;
111 int again,n,eline=0; 132 int again,n;
133 long eline=0;
112 CONF_VALUE *v=NULL,*vv,*tv; 134 CONF_VALUE *v=NULL,*vv,*tv;
113 CONF_VALUE *sv=NULL; 135 CONF_VALUE *sv=NULL;
114 char *section=NULL,*buf; 136 char *section=NULL,*buf;
115 STACK *section_sk=NULL,*ts; 137 STACK_OF(CONF_VALUE) *section_sk=NULL,*ts;
116 char *start,*psection,*pname; 138 char *start,*psection,*pname;
117 139
118 if ((buff=BUF_MEM_new()) == NULL) 140 if ((buff=BUF_MEM_new()) == NULL)
119 { 141 {
120 CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB); 142 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
121 goto err;
122 }
123
124 in=fopen(file,"rb");
125 if (in == NULL)
126 {
127 SYSerr(SYS_F_FOPEN,get_last_sys_error());
128 ERR_set_error_data(BUF_strdup(file),
129 ERR_TXT_MALLOCED|ERR_TXT_STRING);
130 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
131 goto err; 143 goto err;
132 } 144 }
133 145
134 section=(char *)Malloc(10); 146 section=(char *)Malloc(10);
135 if (section == NULL) 147 if (section == NULL)
136 { 148 {
137 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); 149 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
138 goto err; 150 goto err;
139 } 151 }
140 strcpy(section,"default"); 152 strcpy(section,"default");
141 153
142 if (h == NULL) 154 if (h == NULL)
143 { 155 {
144 if ((ret=lh_new(hash,cmp)) == NULL) 156 if ((ret=lh_new(hash,cmp_conf)) == NULL)
145 { 157 {
146 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); 158 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
147 goto err; 159 goto err;
148 } 160 }
149 } 161 }
@@ -153,10 +165,11 @@ long *line;
153 sv=new_section(ret,section); 165 sv=new_section(ret,section);
154 if (sv == NULL) 166 if (sv == NULL)
155 { 167 {
156 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); 168 CONFerr(CONF_F_CONF_LOAD_BIO,
169 CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
157 goto err; 170 goto err;
158 } 171 }
159 section_sk=(STACK *)sv->value; 172 section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
160 173
161 bufnum=0; 174 bufnum=0;
162 for (;;) 175 for (;;)
@@ -164,12 +177,12 @@ long *line;
164 again=0; 177 again=0;
165 if (!BUF_MEM_grow(buff,bufnum+BUFSIZE)) 178 if (!BUF_MEM_grow(buff,bufnum+BUFSIZE))
166 { 179 {
167 CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB); 180 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
168 goto err; 181 goto err;
169 } 182 }
170 p= &(buff->data[bufnum]); 183 p= &(buff->data[bufnum]);
171 *p='\0'; 184 *p='\0';
172 fgets(p,BUFSIZE-1,in); 185 BIO_gets(in, p, BUFSIZE-1);
173 p[BUFSIZE-1]='\0'; 186 p[BUFSIZE-1]='\0';
174 ii=i=strlen(p); 187 ii=i=strlen(p);
175 if (i == 0) break; 188 if (i == 0) break;
@@ -219,13 +232,23 @@ long *line;
219 if (IS_EOF(*s)) continue; /* blank line */ 232 if (IS_EOF(*s)) continue; /* blank line */
220 if (*s == '[') 233 if (*s == '[')
221 { 234 {
235 char *ss;
236
222 s++; 237 s++;
223 start=eat_ws(s); 238 start=eat_ws(s);
224 end=eat_alpha_numeric(start); 239 ss=start;
240again:
241 end=eat_alpha_numeric(ss);
225 p=eat_ws(end); 242 p=eat_ws(end);
226 if (*p != ']') 243 if (*p != ']')
227 { 244 {
228 CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_CLOSE_SQUARE_BRACKET); 245 if (*p != '\0')
246 {
247 ss=p;
248 goto again;
249 }
250 CONFerr(CONF_F_CONF_LOAD_BIO,
251 CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
229 goto err; 252 goto err;
230 } 253 }
231 *end='\0'; 254 *end='\0';
@@ -234,10 +257,11 @@ long *line;
234 sv=new_section(ret,section); 257 sv=new_section(ret,section);
235 if (sv == NULL) 258 if (sv == NULL)
236 { 259 {
237 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); 260 CONFerr(CONF_F_CONF_LOAD_BIO,
261 CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
238 goto err; 262 goto err;
239 } 263 }
240 section_sk=(STACK *)sv->value; 264 section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
241 continue; 265 continue;
242 } 266 }
243 else 267 else
@@ -256,7 +280,8 @@ long *line;
256 p=eat_ws(end); 280 p=eat_ws(end);
257 if (*p != '=') 281 if (*p != '=')
258 { 282 {
259 CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_EQUAL_SIGN); 283 CONFerr(CONF_F_CONF_LOAD_BIO,
284 CONF_R_MISSING_EQUAL_SIGN);
260 goto err; 285 goto err;
261 } 286 }
262 *end='\0'; 287 *end='\0';
@@ -270,9 +295,10 @@ long *line;
270 p++; 295 p++;
271 *p='\0'; 296 *p='\0';
272 297
273 if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL) 298 if (!(v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))))
274 { 299 {
275 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); 300 CONFerr(CONF_F_CONF_LOAD_BIO,
301 ERR_R_MALLOC_FAILURE);
276 goto err; 302 goto err;
277 } 303 }
278 if (psection == NULL) psection=section; 304 if (psection == NULL) psection=section;
@@ -280,7 +306,8 @@ long *line;
280 v->value=NULL; 306 v->value=NULL;
281 if (v->name == NULL) 307 if (v->name == NULL)
282 { 308 {
283 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); 309 CONFerr(CONF_F_CONF_LOAD_BIO,
310 ERR_R_MALLOC_FAILURE);
284 goto err; 311 goto err;
285 } 312 }
286 strcpy(v->name,pname); 313 strcpy(v->name,pname);
@@ -293,10 +320,11 @@ long *line;
293 tv=new_section(ret,psection); 320 tv=new_section(ret,psection);
294 if (tv == NULL) 321 if (tv == NULL)
295 { 322 {
296 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); 323 CONFerr(CONF_F_CONF_LOAD_BIO,
324 CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
297 goto err; 325 goto err;
298 } 326 }
299 ts=(STACK *)tv->value; 327 ts=(STACK_OF(CONF_VALUE) *)tv->value;
300 } 328 }
301 else 329 else
302 { 330 {
@@ -304,15 +332,16 @@ long *line;
304 ts=section_sk; 332 ts=section_sk;
305 } 333 }
306 v->section=tv->section; 334 v->section=tv->section;
307 if (!sk_push(ts,(char *)v)) 335 if (!sk_CONF_VALUE_push(ts,v))
308 { 336 {
309 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); 337 CONFerr(CONF_F_CONF_LOAD_BIO,
338 ERR_R_MALLOC_FAILURE);
310 goto err; 339 goto err;
311 } 340 }
312 vv=(CONF_VALUE *)lh_insert(ret,(char *)v); 341 vv=(CONF_VALUE *)lh_insert(ret,(char *)v);
313 if (vv != NULL) 342 if (vv != NULL)
314 { 343 {
315 sk_delete_ptr(ts,(char *)vv); 344 sk_CONF_VALUE_delete_ptr(ts,vv);
316 Free(vv->name); 345 Free(vv->name);
317 Free(vv->value); 346 Free(vv->value);
318 Free(vv); 347 Free(vv);
@@ -322,13 +351,13 @@ long *line;
322 } 351 }
323 if (buff != NULL) BUF_MEM_free(buff); 352 if (buff != NULL) BUF_MEM_free(buff);
324 if (section != NULL) Free(section); 353 if (section != NULL) Free(section);
325 if (in != NULL) fclose(in);
326 return(ret); 354 return(ret);
327err: 355err:
328 if (buff != NULL) BUF_MEM_free(buff); 356 if (buff != NULL) BUF_MEM_free(buff);
329 if (section != NULL) Free(section); 357 if (section != NULL) Free(section);
330 if (line != NULL) *line=eline; 358 if (line != NULL) *line=eline;
331 if (in != NULL) fclose(in); 359 sprintf(btmp,"%ld",eline);
360 ERR_add_error_data(2,"line ",btmp);
332 if ((h != ret) && (ret != NULL)) CONF_free(ret); 361 if ((h != ret) && (ret != NULL)) CONF_free(ret);
333 if (v != NULL) 362 if (v != NULL)
334 { 363 {
@@ -338,11 +367,8 @@ err:
338 } 367 }
339 return(NULL); 368 return(NULL);
340 } 369 }
341 370
342char *CONF_get_string(conf,section,name) 371char *CONF_get_string(LHASH *conf, char *section, char *name)
343LHASH *conf;
344char *section;
345char *name;
346 { 372 {
347 CONF_VALUE *v,vv; 373 CONF_VALUE *v,vv;
348 char *p; 374 char *p;
@@ -374,9 +400,7 @@ char *name;
374 return(Getenv(name)); 400 return(Getenv(name));
375 } 401 }
376 402
377static CONF_VALUE *get_section(conf,section) 403static CONF_VALUE *get_section(LHASH *conf, char *section)
378LHASH *conf;
379char *section;
380 { 404 {
381 CONF_VALUE *v,vv; 405 CONF_VALUE *v,vv;
382 406
@@ -387,23 +411,18 @@ char *section;
387 return(v); 411 return(v);
388 } 412 }
389 413
390STACK *CONF_get_section(conf,section) 414STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf, char *section)
391LHASH *conf;
392char *section;
393 { 415 {
394 CONF_VALUE *v; 416 CONF_VALUE *v;
395 417
396 v=get_section(conf,section); 418 v=get_section(conf,section);
397 if (v != NULL) 419 if (v != NULL)
398 return((STACK *)v->value); 420 return((STACK_OF(CONF_VALUE) *)v->value);
399 else 421 else
400 return(NULL); 422 return(NULL);
401 } 423 }
402 424
403long CONF_get_number(conf,section,name) 425long CONF_get_number(LHASH *conf, char *section, char *name)
404LHASH *conf;
405char *section;
406char *name;
407 { 426 {
408 char *str; 427 char *str;
409 long ret=0; 428 long ret=0;
@@ -420,8 +439,7 @@ char *name;
420 } 439 }
421 } 440 }
422 441
423void CONF_free(conf) 442void CONF_free(LHASH *conf)
424LHASH *conf;
425 { 443 {
426 if (conf == NULL) return; 444 if (conf == NULL) return;
427 445
@@ -436,9 +454,7 @@ LHASH *conf;
436 lh_free(conf); 454 lh_free(conf);
437 } 455 }
438 456
439static void value_free_hash(a,conf) 457static void value_free_hash(CONF_VALUE *a, LHASH *conf)
440CONF_VALUE *a;
441LHASH *conf;
442 { 458 {
443 if (a->name != NULL) 459 if (a->name != NULL)
444 { 460 {
@@ -446,9 +462,7 @@ LHASH *conf;
446 } 462 }
447 } 463 }
448 464
449static void value_free_stack(a,conf) 465static void value_free_stack(CONF_VALUE *a, LHASH *conf)
450CONF_VALUE *a;
451LHASH *conf;
452 { 466 {
453 CONF_VALUE *vv; 467 CONF_VALUE *vv;
454 STACK *sk; 468 STACK *sk;
@@ -469,8 +483,7 @@ LHASH *conf;
469 Free(a); 483 Free(a);
470 } 484 }
471 485
472static void clear_comments(p) 486static void clear_comments(char *p)
473char *p;
474 { 487 {
475 char *to; 488 char *to;
476 489
@@ -499,10 +512,7 @@ char *p;
499 } 512 }
500 } 513 }
501 514
502static int str_copy(conf,section,pto,from) 515static int str_copy(LHASH *conf, char *section, char **pto, char *from)
503LHASH *conf;
504char *section;
505char **pto,*from;
506 { 516 {
507 int q,r,rr=0,to=0,len=0; 517 int q,r,rr=0,to=0,len=0;
508 char *s,*e,*rp,*p,*rrp,*np,*cp,v; 518 char *s,*e,*rp,*p,*rrp,*np,*cp,v;
@@ -616,16 +626,14 @@ err:
616 return(0); 626 return(0);
617 } 627 }
618 628
619static char *eat_ws(p) 629static char *eat_ws(char *p)
620char *p;
621 { 630 {
622 while (IS_WS(*p) && (!IS_EOF(*p))) 631 while (IS_WS(*p) && (!IS_EOF(*p)))
623 p++; 632 p++;
624 return(p); 633 return(p);
625 } 634 }
626 635
627static char *eat_alpha_numeric(p) 636static char *eat_alpha_numeric(char *p)
628char *p;
629 { 637 {
630 for (;;) 638 for (;;)
631 { 639 {
@@ -640,14 +648,12 @@ char *p;
640 } 648 }
641 } 649 }
642 650
643static unsigned long hash(v) 651static unsigned long hash(CONF_VALUE *v)
644CONF_VALUE *v;
645 { 652 {
646 return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); 653 return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
647 } 654 }
648 655
649static int cmp(a,b) 656static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b)
650CONF_VALUE *a,*b;
651 { 657 {
652 int i; 658 int i;
653 659
@@ -668,8 +674,7 @@ CONF_VALUE *a,*b;
668 return((a->name == NULL)?-1:1); 674 return((a->name == NULL)?-1:1);
669 } 675 }
670 676
671static char *scan_quote(p) 677static char *scan_quote(char *p)
672char *p;
673 { 678 {
674 int q= *p; 679 int q= *p;
675 680
@@ -687,9 +692,7 @@ char *p;
687 return(p); 692 return(p);
688 } 693 }
689 694
690static CONF_VALUE *new_section(conf,section) 695static CONF_VALUE *new_section(LHASH *conf, char *section)
691LHASH *conf;
692char *section;
693 { 696 {
694 STACK *sk=NULL; 697 STACK *sk=NULL;
695 int ok=0,i; 698 int ok=0,i;
@@ -725,3 +728,5 @@ err:
725 } 728 }
726 return(v); 729 return(v);
727 } 730 }
731
732IMPLEMENT_STACK_OF(CONF_VALUE)
diff --git a/src/lib/libcrypto/conf/conf.err b/src/lib/libcrypto/conf/conf.err
deleted file mode 100644
index 933d3d692a..0000000000
--- a/src/lib/libcrypto/conf/conf.err
+++ /dev/null
@@ -1,12 +0,0 @@
1/* Error codes for the CONF functions. */
2
3/* Function codes. */
4#define CONF_F_CONF_LOAD 100
5#define CONF_F_STR_COPY 101
6
7/* Reason codes. */
8#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
9#define CONF_R_MISSING_EQUAL_SIGN 101
10#define CONF_R_NO_CLOSE_BRACE 102
11#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
12#define CONF_R_VARIABLE_HAS_NO_VALUE 104
diff --git a/src/lib/libcrypto/conf/conf.h b/src/lib/libcrypto/conf/conf.h
index 1446226a16..e7c5150097 100644
--- a/src/lib/libcrypto/conf/conf.h
+++ b/src/lib/libcrypto/conf/conf.h
@@ -63,8 +63,10 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#include "stack.h" 66#include <openssl/bio.h>
67#include "lhash.h" 67#include <openssl/lhash.h>
68#include <openssl/stack.h>
69#include <openssl/safestack.h>
68 70
69typedef struct 71typedef struct
70 { 72 {
@@ -73,31 +75,29 @@ typedef struct
73 char *value; 75 char *value;
74 } CONF_VALUE; 76 } CONF_VALUE;
75 77
76#ifndef NOPROTO 78DECLARE_STACK_OF(CONF_VALUE)
77 79
78LHASH *CONF_load(LHASH *conf,char *file,long *eline); 80LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
79STACK *CONF_get_section(LHASH *conf,char *section); 81LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
82LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
83STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section);
80char *CONF_get_string(LHASH *conf,char *group,char *name); 84char *CONF_get_string(LHASH *conf,char *group,char *name);
81long CONF_get_number(LHASH *conf,char *group,char *name); 85long CONF_get_number(LHASH *conf,char *group,char *name);
82void CONF_free(LHASH *conf); 86void CONF_free(LHASH *conf);
83void ERR_load_CONF_strings(void ); 87void ERR_load_CONF_strings(void );
84 88
85#else
86
87LHASH *CONF_load();
88STACK *CONF_get_section();
89char *CONF_get_string();
90long CONF_get_number();
91void CONF_free();
92void ERR_load_CONF_strings();
93
94#endif
95 89
96/* BEGIN ERROR CODES */ 90/* BEGIN ERROR CODES */
91/* The following lines are auto generated by the script mkerr.pl. Any changes
92 * made after this point may be overwritten when the script is next run.
93 */
94
97/* Error codes for the CONF functions. */ 95/* Error codes for the CONF functions. */
98 96
99/* Function codes. */ 97/* Function codes. */
100#define CONF_F_CONF_LOAD 100 98#define CONF_F_CONF_LOAD 100
99#define CONF_F_CONF_LOAD_BIO 102
100#define CONF_F_CONF_LOAD_FP 103
101#define CONF_F_STR_COPY 101 101#define CONF_F_STR_COPY 101
102 102
103/* Reason codes. */ 103/* Reason codes. */
@@ -106,7 +106,7 @@ void ERR_load_CONF_strings();
106#define CONF_R_NO_CLOSE_BRACE 102 106#define CONF_R_NO_CLOSE_BRACE 102
107#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 107#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
108#define CONF_R_VARIABLE_HAS_NO_VALUE 104 108#define CONF_R_VARIABLE_HAS_NO_VALUE 104
109 109
110#ifdef __cplusplus 110#ifdef __cplusplus
111} 111}
112#endif 112#endif
diff --git a/src/lib/libcrypto/conf/conf_err.c b/src/lib/libcrypto/conf/conf_err.c
index a8db8f266f..eb4b3cfc70 100644
--- a/src/lib/libcrypto/conf/conf_err.c
+++ b/src/lib/libcrypto/conf/conf_err.c
@@ -1,71 +1,75 @@
1/* lib/conf/conf_err.c */ 1/* crypto/conf/conf_err.c */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* ====================================================================
3 * All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 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 5 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
25 * are met: 7 * are met:
26 * 1. Redistributions of source code must retain the copyright 8 *
27 * notice, this list of conditions and the following disclaimer. 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
28 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in
30 * documentation and/or other materials provided with the distribution. 14 * the documentation and/or other materials provided with the
31 * 3. All advertising materials mentioning features or use of this software 15 * distribution.
32 * must display the following acknowledgement: 16 *
33 * "This product includes cryptographic software written by 17 * 3. All advertising materials mentioning features or use of this
34 * Eric Young (eay@cryptsoft.com)" 18 * software must display the following acknowledgment:
35 * The word 'cryptographic' can be left out if the rouines from the library 19 * "This product includes software developed by the OpenSSL Project
36 * being used are not cryptographic related :-). 20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
37 * 4. If you include any Windows specific code (or a derivative thereof) from 21 *
38 * the apps directory (application code) you must include an acknowledgement: 22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 23 * endorse or promote products derived from this software without
40 * 24 * prior written permission. For written permission, please contact
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 25 * openssl-core@OpenSSL.org.
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 *
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * 5. Products derived from this software may not be called "OpenSSL"
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 28 * nor may "OpenSSL" appear in their names without prior written
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * permission of the OpenSSL Project.
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 *
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * 6. Redistributions of any form whatsoever must retain the following
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * acknowledgment:
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * "This product includes software developed by the OpenSSL Project
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
51 * SUCH DAMAGE. 35 *
52 * 36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
53 * The licence and distribution terms for any publically available version or 37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * copied and put under another distribution licence 39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
56 * [including the GNU Public Licence.] 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 *
57 */ 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 */
59
58#include <stdio.h> 60#include <stdio.h>
59#include "err.h" 61#include <openssl/err.h>
60#include "conf.h" 62#include <openssl/conf.h>
61 63
62/* BEGIN ERROR CODES */ 64/* BEGIN ERROR CODES */
63#ifndef NO_ERR 65#ifndef NO_ERR
64static ERR_STRING_DATA CONF_str_functs[]= 66static ERR_STRING_DATA CONF_str_functs[]=
65 { 67 {
66{ERR_PACK(0,CONF_F_CONF_LOAD,0), "CONF_load"}, 68{ERR_PACK(0,CONF_F_CONF_LOAD,0), "CONF_load"},
69{ERR_PACK(0,CONF_F_CONF_LOAD_BIO,0), "CONF_load_bio"},
70{ERR_PACK(0,CONF_F_CONF_LOAD_FP,0), "CONF_load_fp"},
67{ERR_PACK(0,CONF_F_STR_COPY,0), "STR_COPY"}, 71{ERR_PACK(0,CONF_F_STR_COPY,0), "STR_COPY"},
68{0,NULL}, 72{0,NULL}
69 }; 73 };
70 74
71static ERR_STRING_DATA CONF_str_reasons[]= 75static ERR_STRING_DATA CONF_str_reasons[]=
@@ -75,17 +79,17 @@ static ERR_STRING_DATA CONF_str_reasons[]=
75{CONF_R_NO_CLOSE_BRACE ,"no close brace"}, 79{CONF_R_NO_CLOSE_BRACE ,"no close brace"},
76{CONF_R_UNABLE_TO_CREATE_NEW_SECTION ,"unable to create new section"}, 80{CONF_R_UNABLE_TO_CREATE_NEW_SECTION ,"unable to create new section"},
77{CONF_R_VARIABLE_HAS_NO_VALUE ,"variable has no value"}, 81{CONF_R_VARIABLE_HAS_NO_VALUE ,"variable has no value"},
78{0,NULL}, 82{0,NULL}
79 }; 83 };
80 84
81#endif 85#endif
82 86
83void ERR_load_CONF_strings() 87void ERR_load_CONF_strings(void)
84 { 88 {
85 static int init=1; 89 static int init=1;
86 90
87 if (init); 91 if (init)
88 {; 92 {
89 init=0; 93 init=0;
90#ifndef NO_ERR 94#ifndef NO_ERR
91 ERR_load_strings(ERR_LIB_CONF,CONF_str_functs); 95 ERR_load_strings(ERR_LIB_CONF,CONF_str_functs);
diff --git a/src/lib/libcrypto/conf/conf_lcl.h b/src/lib/libcrypto/conf/conf_lcl.h
index 4e5644ed79..f9a015df57 100644
--- a/src/lib/libcrypto/conf/conf_lcl.h
+++ b/src/lib/libcrypto/conf/conf_lcl.h
@@ -71,6 +71,7 @@
71#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \ 71#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \
72 CONF_PUNCTUATION) 72 CONF_PUNCTUATION)
73 73
74#ifndef CHARSET_EBCDIC
74#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[(a)&0x7f])) 75#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[(a)&0x7f]))
75#define IS_EOF(a) ((a) == '\0') 76#define IS_EOF(a) ((a) == '\0')
76#define IS_ESC(a) ((a) == '\\') 77#define IS_ESC(a) ((a) == '\\')
@@ -81,6 +82,19 @@
81 (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT) 82 (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT)
82#define IS_QUOTE(a) (CONF_type[(a)&0x7f]&CONF_QUOTE) 83#define IS_QUOTE(a) (CONF_type[(a)&0x7f]&CONF_QUOTE)
83 84
85#else /*CHARSET_EBCDIC*/
86
87#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[os_toascii[a]&0x7f]))
88#define IS_EOF(a) (os_toascii[a] == '\0')
89#define IS_ESC(a) (os_toascii[a] == '\\')
90#define IS_NUMER(a) (CONF_type[os_toascii[a]&0x7f]&CONF_NUMBER)
91#define IS_WS(a) (CONF_type[os_toascii[a]&0x7f]&CONF_WS)
92#define IS_ALPHA_NUMERIC(a) (CONF_type[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC)
93#define IS_ALPHA_NUMERIC_PUNCT(a) \
94 (CONF_type[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC_PUNCT)
95#define IS_QUOTE(a) (CONF_type[os_toascii[a]&0x7f]&CONF_QUOTE)
96#endif /*CHARSET_EBCDIC*/
97
84static unsigned short CONF_type[128]={ 98static unsigned short CONF_type[128]={
85 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000, 99 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
86 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000, 100 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000,
diff --git a/src/lib/libcrypto/conf/keysets.pl b/src/lib/libcrypto/conf/keysets.pl
index e40fed0ca1..1aed0c80c4 100644
--- a/src/lib/libcrypto/conf/keysets.pl
+++ b/src/lib/libcrypto/conf/keysets.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3$NUMBER=0x01; 3$NUMBER=0x01;
4$UPPER=0x02; 4$UPPER=0x02;
diff --git a/src/lib/libcrypto/conf/test.c b/src/lib/libcrypto/conf/test.c
index 899ee2a067..9390a48baf 100644
--- a/src/lib/libcrypto/conf/test.c
+++ b/src/lib/libcrypto/conf/test.c
@@ -58,7 +58,8 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include "conf.h" 61#include <openssl/conf.h>
62#include <openssl/err.h>
62 63
63main() 64main()
64 { 65 {
@@ -66,7 +67,7 @@ main()
66 long eline; 67 long eline;
67 char *s,*s2; 68 char *s,*s2;
68 69
69 conf=CONF_load(NULL,"ssleay.conf",&eline); 70 conf=CONF_load(NULL,"openssl.conf",&eline);
70 if (conf == NULL) 71 if (conf == NULL)
71 { 72 {
72 ERR_load_crypto_strings(); 73 ERR_load_crypto_strings();