diff options
author | djm <> | 2010-10-01 22:59:01 +0000 |
---|---|---|
committer | djm <> | 2010-10-01 22:59:01 +0000 |
commit | fe047d8b632246cb2db3234a0a4f32e5c318857b (patch) | |
tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/objects | |
parent | 2ea67f4aa254b09ded62e6e14fc893bbe6381579 (diff) | |
download | openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.gz openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.bz2 openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.zip |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/objects')
-rw-r--r-- | src/lib/libcrypto/objects/Makefile.ssl | 123 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/o_names.c | 47 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/obj_dat.c | 180 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/obj_dat.pl | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/obj_err.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/obj_lib.c | 35 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/obj_mac.num | 34 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/objects.h | 97 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/objects.pl | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/objects.txt | 44 |
10 files changed, 324 insertions, 261 deletions
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl deleted file mode 100644 index 3e7a194cf9..0000000000 --- a/src/lib/libcrypto/objects/Makefile.ssl +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | # | ||
2 | # SSLeay/crypto/objects/Makefile | ||
3 | # | ||
4 | |||
5 | DIR= objects | ||
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 | PERL= perl | ||
19 | |||
20 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
21 | |||
22 | GENERAL=Makefile README | ||
23 | TEST= | ||
24 | APPS= | ||
25 | |||
26 | LIB=$(TOP)/libcrypto.a | ||
27 | LIBSRC= o_names.c obj_dat.c obj_lib.c obj_err.c | ||
28 | LIBOBJ= o_names.o obj_dat.o obj_lib.o obj_err.o | ||
29 | |||
30 | SRC= $(LIBSRC) | ||
31 | |||
32 | EXHEADER= objects.h obj_mac.h | ||
33 | HEADER= $(EXHEADER) obj_dat.h | ||
34 | |||
35 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
36 | |||
37 | top: | ||
38 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
39 | |||
40 | all: obj_dat.h lib | ||
41 | |||
42 | lib: $(LIBOBJ) | ||
43 | $(AR) $(LIB) $(LIBOBJ) | ||
44 | $(RANLIB) $(LIB) || echo Never mind. | ||
45 | @touch lib | ||
46 | |||
47 | obj_dat.h: obj_dat.pl obj_mac.h | ||
48 | $(PERL) obj_dat.pl obj_mac.h obj_dat.h | ||
49 | |||
50 | # objects.pl both reads and writes obj_mac.num | ||
51 | obj_mac.h: objects.pl objects.txt obj_mac.num | ||
52 | $(PERL) objects.pl objects.txt obj_mac.num obj_mac.h | ||
53 | |||
54 | files: | ||
55 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
56 | |||
57 | links: | ||
58 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
59 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
60 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
61 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
62 | |||
63 | install: | ||
64 | @for i in $(EXHEADER) ; \ | ||
65 | do \ | ||
66 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
67 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
68 | done; | ||
69 | |||
70 | tags: | ||
71 | ctags $(SRC) | ||
72 | |||
73 | tests: | ||
74 | |||
75 | lint: | ||
76 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
77 | |||
78 | depend: | ||
79 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
80 | |||
81 | dclean: | ||
82 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
83 | mv -f Makefile.new $(MAKEFILE) | ||
84 | |||
85 | clean: | ||
86 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
87 | |||
88 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
89 | |||
90 | o_names.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
91 | o_names.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
92 | o_names.o: ../../include/openssl/e_os2.h ../../include/openssl/lhash.h | ||
93 | o_names.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
94 | o_names.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
95 | o_names.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
96 | o_names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
97 | o_names.o: o_names.c | ||
98 | obj_dat.o: ../../e_os.h ../../include/openssl/asn1.h | ||
99 | obj_dat.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
100 | obj_dat.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
101 | obj_dat.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
102 | obj_dat.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
103 | obj_dat.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
104 | obj_dat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
105 | obj_dat.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
106 | obj_dat.o: ../../include/openssl/symhacks.h ../cryptlib.h obj_dat.c obj_dat.h | ||
107 | obj_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
108 | obj_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
109 | obj_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
110 | obj_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
111 | obj_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
112 | obj_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
113 | obj_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
114 | obj_err.o: ../../include/openssl/symhacks.h obj_err.c | ||
115 | obj_lib.o: ../../e_os.h ../../include/openssl/asn1.h | ||
116 | obj_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
117 | obj_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
118 | obj_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
119 | obj_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
120 | obj_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
121 | obj_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
122 | obj_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
123 | obj_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h obj_lib.c | ||
diff --git a/src/lib/libcrypto/objects/o_names.c b/src/lib/libcrypto/objects/o_names.c index adb5731f76..84380a96a9 100644 --- a/src/lib/libcrypto/objects/o_names.c +++ b/src/lib/libcrypto/objects/o_names.c | |||
@@ -22,7 +22,8 @@ | |||
22 | /* I use the ex_data stuff to manage the identifiers for the obj_name_types | 22 | /* I use the ex_data stuff to manage the identifiers for the obj_name_types |
23 | * that applications may define. I only really use the free function field. | 23 | * that applications may define. I only really use the free function field. |
24 | */ | 24 | */ |
25 | static LHASH *names_lh=NULL; | 25 | DECLARE_LHASH_OF(OBJ_NAME); |
26 | static LHASH_OF(OBJ_NAME) *names_lh=NULL; | ||
26 | static int names_type_num=OBJ_NAME_TYPE_NUM; | 27 | static int names_type_num=OBJ_NAME_TYPE_NUM; |
27 | 28 | ||
28 | typedef struct name_funcs_st | 29 | typedef struct name_funcs_st |
@@ -46,11 +47,14 @@ static unsigned long obj_name_hash(const void *a_void); | |||
46 | /* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */ | 47 | /* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */ |
47 | static int obj_name_cmp(const void *a_void,const void *b_void); | 48 | static int obj_name_cmp(const void *a_void,const void *b_void); |
48 | 49 | ||
50 | static IMPLEMENT_LHASH_HASH_FN(obj_name, OBJ_NAME) | ||
51 | static IMPLEMENT_LHASH_COMP_FN(obj_name, OBJ_NAME) | ||
52 | |||
49 | int OBJ_NAME_init(void) | 53 | int OBJ_NAME_init(void) |
50 | { | 54 | { |
51 | if (names_lh != NULL) return(1); | 55 | if (names_lh != NULL) return(1); |
52 | MemCheck_off(); | 56 | MemCheck_off(); |
53 | names_lh=lh_new(obj_name_hash, obj_name_cmp); | 57 | names_lh=lh_OBJ_NAME_new(); |
54 | MemCheck_on(); | 58 | MemCheck_on(); |
55 | return(names_lh != NULL); | 59 | return(names_lh != NULL); |
56 | } | 60 | } |
@@ -164,7 +168,7 @@ const char *OBJ_NAME_get(const char *name, int type) | |||
164 | 168 | ||
165 | for (;;) | 169 | for (;;) |
166 | { | 170 | { |
167 | ret=(OBJ_NAME *)lh_retrieve(names_lh,&on); | 171 | ret=lh_OBJ_NAME_retrieve(names_lh,&on); |
168 | if (ret == NULL) return(NULL); | 172 | if (ret == NULL) return(NULL); |
169 | if ((ret->alias) && !alias) | 173 | if ((ret->alias) && !alias) |
170 | { | 174 | { |
@@ -200,7 +204,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data) | |||
200 | onp->type=type; | 204 | onp->type=type; |
201 | onp->data=data; | 205 | onp->data=data; |
202 | 206 | ||
203 | ret=(OBJ_NAME *)lh_insert(names_lh,onp); | 207 | ret=lh_OBJ_NAME_insert(names_lh,onp); |
204 | if (ret != NULL) | 208 | if (ret != NULL) |
205 | { | 209 | { |
206 | /* free things */ | 210 | /* free things */ |
@@ -217,7 +221,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data) | |||
217 | } | 221 | } |
218 | else | 222 | else |
219 | { | 223 | { |
220 | if (lh_error(names_lh)) | 224 | if (lh_OBJ_NAME_error(names_lh)) |
221 | { | 225 | { |
222 | /* ERROR */ | 226 | /* ERROR */ |
223 | return(0); | 227 | return(0); |
@@ -235,7 +239,7 @@ int OBJ_NAME_remove(const char *name, int type) | |||
235 | type&= ~OBJ_NAME_ALIAS; | 239 | type&= ~OBJ_NAME_ALIAS; |
236 | on.name=name; | 240 | on.name=name; |
237 | on.type=type; | 241 | on.type=type; |
238 | ret=(OBJ_NAME *)lh_delete(names_lh,&on); | 242 | ret=lh_OBJ_NAME_delete(names_lh,&on); |
239 | if (ret != NULL) | 243 | if (ret != NULL) |
240 | { | 244 | { |
241 | /* free things */ | 245 | /* free things */ |
@@ -262,13 +266,13 @@ struct doall | |||
262 | void *arg; | 266 | void *arg; |
263 | }; | 267 | }; |
264 | 268 | ||
265 | static void do_all_fn(const OBJ_NAME *name,struct doall *d) | 269 | static void do_all_fn_doall_arg(const OBJ_NAME *name,struct doall *d) |
266 | { | 270 | { |
267 | if(name->type == d->type) | 271 | if(name->type == d->type) |
268 | d->fn(name,d->arg); | 272 | d->fn(name,d->arg); |
269 | } | 273 | } |
270 | 274 | ||
271 | static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME *, struct doall *) | 275 | static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME, struct doall) |
272 | 276 | ||
273 | void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) | 277 | void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) |
274 | { | 278 | { |
@@ -278,7 +282,8 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) | |||
278 | d.fn=fn; | 282 | d.fn=fn; |
279 | d.arg=arg; | 283 | d.arg=arg; |
280 | 284 | ||
281 | lh_doall_arg(names_lh,LHASH_DOALL_ARG_FN(do_all_fn),&d); | 285 | lh_OBJ_NAME_doall_arg(names_lh, LHASH_DOALL_ARG_FN(do_all_fn), |
286 | struct doall, &d); | ||
282 | } | 287 | } |
283 | 288 | ||
284 | struct doall_sorted | 289 | struct doall_sorted |
@@ -313,7 +318,7 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), | |||
313 | int n; | 318 | int n; |
314 | 319 | ||
315 | d.type=type; | 320 | d.type=type; |
316 | d.names=OPENSSL_malloc(lh_num_items(names_lh)*sizeof *d.names); | 321 | d.names=OPENSSL_malloc(lh_OBJ_NAME_num_items(names_lh)*sizeof *d.names); |
317 | d.n=0; | 322 | d.n=0; |
318 | OBJ_NAME_do_all(type,do_all_sorted_fn,&d); | 323 | OBJ_NAME_do_all(type,do_all_sorted_fn,&d); |
319 | 324 | ||
@@ -327,18 +332,16 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), | |||
327 | 332 | ||
328 | static int free_type; | 333 | static int free_type; |
329 | 334 | ||
330 | static void names_lh_free(OBJ_NAME *onp) | 335 | static void names_lh_free_doall(OBJ_NAME *onp) |
331 | { | 336 | { |
332 | if(onp == NULL) | 337 | if (onp == NULL) |
333 | return; | 338 | return; |
334 | 339 | ||
335 | if ((free_type < 0) || (free_type == onp->type)) | 340 | if (free_type < 0 || free_type == onp->type) |
336 | { | ||
337 | OBJ_NAME_remove(onp->name,onp->type); | 341 | OBJ_NAME_remove(onp->name,onp->type); |
338 | } | ||
339 | } | 342 | } |
340 | 343 | ||
341 | static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME *) | 344 | static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME) |
342 | 345 | ||
343 | static void name_funcs_free(NAME_FUNCS *ptr) | 346 | static void name_funcs_free(NAME_FUNCS *ptr) |
344 | { | 347 | { |
@@ -352,18 +355,18 @@ void OBJ_NAME_cleanup(int type) | |||
352 | if (names_lh == NULL) return; | 355 | if (names_lh == NULL) return; |
353 | 356 | ||
354 | free_type=type; | 357 | free_type=type; |
355 | down_load=names_lh->down_load; | 358 | down_load=lh_OBJ_NAME_down_load(names_lh); |
356 | names_lh->down_load=0; | 359 | lh_OBJ_NAME_down_load(names_lh)=0; |
357 | 360 | ||
358 | lh_doall(names_lh,LHASH_DOALL_FN(names_lh_free)); | 361 | lh_OBJ_NAME_doall(names_lh,LHASH_DOALL_FN(names_lh_free)); |
359 | if (type < 0) | 362 | if (type < 0) |
360 | { | 363 | { |
361 | lh_free(names_lh); | 364 | lh_OBJ_NAME_free(names_lh); |
362 | sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free); | 365 | sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free); |
363 | names_lh=NULL; | 366 | names_lh=NULL; |
364 | name_funcs_stack = NULL; | 367 | name_funcs_stack = NULL; |
365 | } | 368 | } |
366 | else | 369 | else |
367 | names_lh->down_load=down_load; | 370 | lh_OBJ_NAME_down_load(names_lh)=down_load; |
368 | } | 371 | } |
369 | 372 | ||
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c index 7fd7433241..8a342ba3eb 100644 --- a/src/lib/libcrypto/objects/obj_dat.c +++ b/src/lib/libcrypto/objects/obj_dat.c | |||
@@ -74,16 +74,17 @@ | |||
74 | #define NUM_SN 0 | 74 | #define NUM_SN 0 |
75 | #define NUM_LN 0 | 75 | #define NUM_LN 0 |
76 | #define NUM_OBJ 0 | 76 | #define NUM_OBJ 0 |
77 | static unsigned char lvalues[1]; | 77 | static const unsigned char lvalues[1]; |
78 | static ASN1_OBJECT nid_objs[1]; | 78 | static const ASN1_OBJECT nid_objs[1]; |
79 | static ASN1_OBJECT *sn_objs[1]; | 79 | static const unsigned int sn_objs[1]; |
80 | static ASN1_OBJECT *ln_objs[1]; | 80 | static const unsigned int ln_objs[1]; |
81 | static ASN1_OBJECT *obj_objs[1]; | 81 | static const unsigned int obj_objs[1]; |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | static int sn_cmp(const void *a, const void *b); | 84 | DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); |
85 | static int ln_cmp(const void *a, const void *b); | 85 | DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); |
86 | static int obj_cmp(const void *a, const void *b); | 86 | DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); |
87 | |||
87 | #define ADDED_DATA 0 | 88 | #define ADDED_DATA 0 |
88 | #define ADDED_SNAME 1 | 89 | #define ADDED_SNAME 1 |
89 | #define ADDED_LNAME 2 | 90 | #define ADDED_LNAME 2 |
@@ -94,30 +95,27 @@ typedef struct added_obj_st | |||
94 | int type; | 95 | int type; |
95 | ASN1_OBJECT *obj; | 96 | ASN1_OBJECT *obj; |
96 | } ADDED_OBJ; | 97 | } ADDED_OBJ; |
98 | DECLARE_LHASH_OF(ADDED_OBJ); | ||
97 | 99 | ||
98 | static int new_nid=NUM_NID; | 100 | static int new_nid=NUM_NID; |
99 | static LHASH *added=NULL; | 101 | static LHASH_OF(ADDED_OBJ) *added=NULL; |
100 | 102 | ||
101 | static int sn_cmp(const void *a, const void *b) | 103 | static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) |
102 | { | 104 | { return(strcmp((*a)->sn,nid_objs[*b].sn)); } |
103 | const ASN1_OBJECT * const *ap = a, * const *bp = b; | ||
104 | return(strcmp((*ap)->sn,(*bp)->sn)); | ||
105 | } | ||
106 | 105 | ||
107 | static int ln_cmp(const void *a, const void *b) | 106 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); |
108 | { | 107 | |
109 | const ASN1_OBJECT * const *ap = a, * const *bp = b; | 108 | static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) |
110 | return(strcmp((*ap)->ln,(*bp)->ln)); | 109 | { return(strcmp((*a)->ln,nid_objs[*b].ln)); } |
111 | } | ||
112 | 110 | ||
113 | /* static unsigned long add_hash(ADDED_OBJ *ca) */ | 111 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); |
114 | static unsigned long add_hash(const void *ca_void) | 112 | |
113 | static unsigned long added_obj_hash(const ADDED_OBJ *ca) | ||
115 | { | 114 | { |
116 | const ASN1_OBJECT *a; | 115 | const ASN1_OBJECT *a; |
117 | int i; | 116 | int i; |
118 | unsigned long ret=0; | 117 | unsigned long ret=0; |
119 | unsigned char *p; | 118 | unsigned char *p; |
120 | const ADDED_OBJ *ca = (const ADDED_OBJ *)ca_void; | ||
121 | 119 | ||
122 | a=ca->obj; | 120 | a=ca->obj; |
123 | switch (ca->type) | 121 | switch (ca->type) |
@@ -145,14 +143,12 @@ static unsigned long add_hash(const void *ca_void) | |||
145 | ret|=ca->type<<30L; | 143 | ret|=ca->type<<30L; |
146 | return(ret); | 144 | return(ret); |
147 | } | 145 | } |
146 | static IMPLEMENT_LHASH_HASH_FN(added_obj, ADDED_OBJ) | ||
148 | 147 | ||
149 | /* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */ | 148 | static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb) |
150 | static int add_cmp(const void *ca_void, const void *cb_void) | ||
151 | { | 149 | { |
152 | ASN1_OBJECT *a,*b; | 150 | ASN1_OBJECT *a,*b; |
153 | int i; | 151 | int i; |
154 | const ADDED_OBJ *ca = (const ADDED_OBJ *)ca_void; | ||
155 | const ADDED_OBJ *cb = (const ADDED_OBJ *)cb_void; | ||
156 | 152 | ||
157 | i=ca->type-cb->type; | 153 | i=ca->type-cb->type; |
158 | if (i) return(i); | 154 | if (i) return(i); |
@@ -179,15 +175,16 @@ static int add_cmp(const void *ca_void, const void *cb_void) | |||
179 | return 0; | 175 | return 0; |
180 | } | 176 | } |
181 | } | 177 | } |
178 | static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ) | ||
182 | 179 | ||
183 | static int init_added(void) | 180 | static int init_added(void) |
184 | { | 181 | { |
185 | if (added != NULL) return(1); | 182 | if (added != NULL) return(1); |
186 | added=lh_new(add_hash,add_cmp); | 183 | added=lh_ADDED_OBJ_new(); |
187 | return(added != NULL); | 184 | return(added != NULL); |
188 | } | 185 | } |
189 | 186 | ||
190 | static void cleanup1(ADDED_OBJ *a) | 187 | static void cleanup1_doall(ADDED_OBJ *a) |
191 | { | 188 | { |
192 | a->obj->nid=0; | 189 | a->obj->nid=0; |
193 | a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC| | 190 | a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC| |
@@ -195,28 +192,46 @@ static void cleanup1(ADDED_OBJ *a) | |||
195 | ASN1_OBJECT_FLAG_DYNAMIC_DATA; | 192 | ASN1_OBJECT_FLAG_DYNAMIC_DATA; |
196 | } | 193 | } |
197 | 194 | ||
198 | static void cleanup2(ADDED_OBJ *a) | 195 | static void cleanup2_doall(ADDED_OBJ *a) |
199 | { a->obj->nid++; } | 196 | { a->obj->nid++; } |
200 | 197 | ||
201 | static void cleanup3(ADDED_OBJ *a) | 198 | static void cleanup3_doall(ADDED_OBJ *a) |
202 | { | 199 | { |
203 | if (--a->obj->nid == 0) | 200 | if (--a->obj->nid == 0) |
204 | ASN1_OBJECT_free(a->obj); | 201 | ASN1_OBJECT_free(a->obj); |
205 | OPENSSL_free(a); | 202 | OPENSSL_free(a); |
206 | } | 203 | } |
207 | 204 | ||
208 | static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ *) | 205 | static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ) |
209 | static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ *) | 206 | static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ) |
210 | static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ *) | 207 | static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ) |
208 | |||
209 | /* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting | ||
210 | * to use freed up OIDs. If neccessary the actual freeing up of OIDs is | ||
211 | * delayed. | ||
212 | */ | ||
213 | |||
214 | int obj_cleanup_defer = 0; | ||
215 | |||
216 | void check_defer(int nid) | ||
217 | { | ||
218 | if (!obj_cleanup_defer && nid >= NUM_NID) | ||
219 | obj_cleanup_defer = 1; | ||
220 | } | ||
211 | 221 | ||
212 | void OBJ_cleanup(void) | 222 | void OBJ_cleanup(void) |
213 | { | 223 | { |
224 | if (obj_cleanup_defer) | ||
225 | { | ||
226 | obj_cleanup_defer = 2; | ||
227 | return ; | ||
228 | } | ||
214 | if (added == NULL) return; | 229 | if (added == NULL) return; |
215 | added->down_load=0; | 230 | lh_ADDED_OBJ_down_load(added) = 0; |
216 | lh_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */ | 231 | lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */ |
217 | lh_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */ | 232 | lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */ |
218 | lh_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */ | 233 | lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */ |
219 | lh_free(added); | 234 | lh_ADDED_OBJ_free(added); |
220 | added=NULL; | 235 | added=NULL; |
221 | } | 236 | } |
222 | 237 | ||
@@ -252,7 +267,7 @@ int OBJ_add_object(const ASN1_OBJECT *obj) | |||
252 | { | 267 | { |
253 | ao[i]->type=i; | 268 | ao[i]->type=i; |
254 | ao[i]->obj=o; | 269 | ao[i]->obj=o; |
255 | aop=(ADDED_OBJ *)lh_insert(added,ao[i]); | 270 | aop=lh_ADDED_OBJ_insert(added,ao[i]); |
256 | /* memory leak, buit should not normally matter */ | 271 | /* memory leak, buit should not normally matter */ |
257 | if (aop != NULL) | 272 | if (aop != NULL) |
258 | OPENSSL_free(aop); | 273 | OPENSSL_free(aop); |
@@ -292,7 +307,7 @@ ASN1_OBJECT *OBJ_nid2obj(int n) | |||
292 | ad.type=ADDED_NID; | 307 | ad.type=ADDED_NID; |
293 | ad.obj= &ob; | 308 | ad.obj= &ob; |
294 | ob.nid=n; | 309 | ob.nid=n; |
295 | adp=(ADDED_OBJ *)lh_retrieve(added,&ad); | 310 | adp=lh_ADDED_OBJ_retrieve(added,&ad); |
296 | if (adp != NULL) | 311 | if (adp != NULL) |
297 | return(adp->obj); | 312 | return(adp->obj); |
298 | else | 313 | else |
@@ -324,7 +339,7 @@ const char *OBJ_nid2sn(int n) | |||
324 | ad.type=ADDED_NID; | 339 | ad.type=ADDED_NID; |
325 | ad.obj= &ob; | 340 | ad.obj= &ob; |
326 | ob.nid=n; | 341 | ob.nid=n; |
327 | adp=(ADDED_OBJ *)lh_retrieve(added,&ad); | 342 | adp=lh_ADDED_OBJ_retrieve(added,&ad); |
328 | if (adp != NULL) | 343 | if (adp != NULL) |
329 | return(adp->obj->sn); | 344 | return(adp->obj->sn); |
330 | else | 345 | else |
@@ -356,7 +371,7 @@ const char *OBJ_nid2ln(int n) | |||
356 | ad.type=ADDED_NID; | 371 | ad.type=ADDED_NID; |
357 | ad.obj= &ob; | 372 | ad.obj= &ob; |
358 | ob.nid=n; | 373 | ob.nid=n; |
359 | adp=(ADDED_OBJ *)lh_retrieve(added,&ad); | 374 | adp=lh_ADDED_OBJ_retrieve(added,&ad); |
360 | if (adp != NULL) | 375 | if (adp != NULL) |
361 | return(adp->obj->ln); | 376 | return(adp->obj->ln); |
362 | else | 377 | else |
@@ -367,9 +382,22 @@ const char *OBJ_nid2ln(int n) | |||
367 | } | 382 | } |
368 | } | 383 | } |
369 | 384 | ||
385 | static int obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp) | ||
386 | { | ||
387 | int j; | ||
388 | const ASN1_OBJECT *a= *ap; | ||
389 | const ASN1_OBJECT *b= &nid_objs[*bp]; | ||
390 | |||
391 | j=(a->length - b->length); | ||
392 | if (j) return(j); | ||
393 | return(memcmp(a->data,b->data,a->length)); | ||
394 | } | ||
395 | |||
396 | IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); | ||
397 | |||
370 | int OBJ_obj2nid(const ASN1_OBJECT *a) | 398 | int OBJ_obj2nid(const ASN1_OBJECT *a) |
371 | { | 399 | { |
372 | ASN1_OBJECT **op; | 400 | const unsigned int *op; |
373 | ADDED_OBJ ad,*adp; | 401 | ADDED_OBJ ad,*adp; |
374 | 402 | ||
375 | if (a == NULL) | 403 | if (a == NULL) |
@@ -381,14 +409,13 @@ int OBJ_obj2nid(const ASN1_OBJECT *a) | |||
381 | { | 409 | { |
382 | ad.type=ADDED_DATA; | 410 | ad.type=ADDED_DATA; |
383 | ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */ | 411 | ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */ |
384 | adp=(ADDED_OBJ *)lh_retrieve(added,&ad); | 412 | adp=lh_ADDED_OBJ_retrieve(added,&ad); |
385 | if (adp != NULL) return (adp->obj->nid); | 413 | if (adp != NULL) return (adp->obj->nid); |
386 | } | 414 | } |
387 | op=(ASN1_OBJECT **)OBJ_bsearch((const char *)&a,(const char *)obj_objs, | 415 | op=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ); |
388 | NUM_OBJ, sizeof(ASN1_OBJECT *),obj_cmp); | ||
389 | if (op == NULL) | 416 | if (op == NULL) |
390 | return(NID_undef); | 417 | return(NID_undef); |
391 | return((*op)->nid); | 418 | return(nid_objs[*op].nid); |
392 | } | 419 | } |
393 | 420 | ||
394 | /* Convert an object name into an ASN1_OBJECT | 421 | /* Convert an object name into an ASN1_OBJECT |
@@ -441,7 +468,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) | |||
441 | int i,n=0,len,nid, first, use_bn; | 468 | int i,n=0,len,nid, first, use_bn; |
442 | BIGNUM *bl; | 469 | BIGNUM *bl; |
443 | unsigned long l; | 470 | unsigned long l; |
444 | unsigned char *p; | 471 | const unsigned char *p; |
445 | char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2]; | 472 | char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2]; |
446 | 473 | ||
447 | if ((a == NULL) || (a->data == NULL)) { | 474 | if ((a == NULL) || (a->data == NULL)) { |
@@ -456,10 +483,13 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) | |||
456 | s=OBJ_nid2ln(nid); | 483 | s=OBJ_nid2ln(nid); |
457 | if (s == NULL) | 484 | if (s == NULL) |
458 | s=OBJ_nid2sn(nid); | 485 | s=OBJ_nid2sn(nid); |
459 | if (buf) | 486 | if (s) |
460 | BUF_strlcpy(buf,s,buf_len); | 487 | { |
461 | n=strlen(s); | 488 | if (buf) |
462 | return n; | 489 | BUF_strlcpy(buf,s,buf_len); |
490 | n=strlen(s); | ||
491 | return n; | ||
492 | } | ||
463 | } | 493 | } |
464 | 494 | ||
465 | 495 | ||
@@ -607,62 +637,56 @@ int OBJ_txt2nid(const char *s) | |||
607 | 637 | ||
608 | int OBJ_ln2nid(const char *s) | 638 | int OBJ_ln2nid(const char *s) |
609 | { | 639 | { |
610 | ASN1_OBJECT o,*oo= &o,**op; | 640 | ASN1_OBJECT o; |
641 | const ASN1_OBJECT *oo= &o; | ||
611 | ADDED_OBJ ad,*adp; | 642 | ADDED_OBJ ad,*adp; |
643 | const unsigned int *op; | ||
612 | 644 | ||
613 | o.ln=s; | 645 | o.ln=s; |
614 | if (added != NULL) | 646 | if (added != NULL) |
615 | { | 647 | { |
616 | ad.type=ADDED_LNAME; | 648 | ad.type=ADDED_LNAME; |
617 | ad.obj= &o; | 649 | ad.obj= &o; |
618 | adp=(ADDED_OBJ *)lh_retrieve(added,&ad); | 650 | adp=lh_ADDED_OBJ_retrieve(added,&ad); |
619 | if (adp != NULL) return (adp->obj->nid); | 651 | if (adp != NULL) return (adp->obj->nid); |
620 | } | 652 | } |
621 | op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs, NUM_LN, | 653 | op=OBJ_bsearch_ln(&oo, ln_objs, NUM_LN); |
622 | sizeof(ASN1_OBJECT *),ln_cmp); | ||
623 | if (op == NULL) return(NID_undef); | 654 | if (op == NULL) return(NID_undef); |
624 | return((*op)->nid); | 655 | return(nid_objs[*op].nid); |
625 | } | 656 | } |
626 | 657 | ||
627 | int OBJ_sn2nid(const char *s) | 658 | int OBJ_sn2nid(const char *s) |
628 | { | 659 | { |
629 | ASN1_OBJECT o,*oo= &o,**op; | 660 | ASN1_OBJECT o; |
661 | const ASN1_OBJECT *oo= &o; | ||
630 | ADDED_OBJ ad,*adp; | 662 | ADDED_OBJ ad,*adp; |
663 | const unsigned int *op; | ||
631 | 664 | ||
632 | o.sn=s; | 665 | o.sn=s; |
633 | if (added != NULL) | 666 | if (added != NULL) |
634 | { | 667 | { |
635 | ad.type=ADDED_SNAME; | 668 | ad.type=ADDED_SNAME; |
636 | ad.obj= &o; | 669 | ad.obj= &o; |
637 | adp=(ADDED_OBJ *)lh_retrieve(added,&ad); | 670 | adp=lh_ADDED_OBJ_retrieve(added,&ad); |
638 | if (adp != NULL) return (adp->obj->nid); | 671 | if (adp != NULL) return (adp->obj->nid); |
639 | } | 672 | } |
640 | op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN, | 673 | op=OBJ_bsearch_sn(&oo, sn_objs, NUM_SN); |
641 | sizeof(ASN1_OBJECT *),sn_cmp); | ||
642 | if (op == NULL) return(NID_undef); | 674 | if (op == NULL) return(NID_undef); |
643 | return((*op)->nid); | 675 | return(nid_objs[*op].nid); |
644 | } | 676 | } |
645 | 677 | ||
646 | static int obj_cmp(const void *ap, const void *bp) | 678 | const void *OBJ_bsearch_(const void *key, const void *base, int num, int size, |
647 | { | 679 | int (*cmp)(const void *, const void *)) |
648 | int j; | ||
649 | const ASN1_OBJECT *a= *(ASN1_OBJECT * const *)ap; | ||
650 | const ASN1_OBJECT *b= *(ASN1_OBJECT * const *)bp; | ||
651 | |||
652 | j=(a->length - b->length); | ||
653 | if (j) return(j); | ||
654 | return(memcmp(a->data,b->data,a->length)); | ||
655 | } | ||
656 | |||
657 | const char *OBJ_bsearch(const char *key, const char *base, int num, int size, | ||
658 | int (*cmp)(const void *, const void *)) | ||
659 | { | 680 | { |
660 | return OBJ_bsearch_ex(key, base, num, size, cmp, 0); | 681 | return OBJ_bsearch_ex_(key, base, num, size, cmp, 0); |
661 | } | 682 | } |
662 | 683 | ||
663 | const char *OBJ_bsearch_ex(const char *key, const char *base, int num, | 684 | const void *OBJ_bsearch_ex_(const void *key, const void *base_, int num, |
664 | int size, int (*cmp)(const void *, const void *), int flags) | 685 | int size, |
686 | int (*cmp)(const void *, const void *), | ||
687 | int flags) | ||
665 | { | 688 | { |
689 | const char *base=base_; | ||
666 | int l,h,i=0,c=0; | 690 | int l,h,i=0,c=0; |
667 | const char *p = NULL; | 691 | const char *p = NULL; |
668 | 692 | ||
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl index 7de2f77afd..c67f71c327 100644 --- a/src/lib/libcrypto/objects/obj_dat.pl +++ b/src/lib/libcrypto/objects/obj_dat.pl | |||
@@ -2,9 +2,7 @@ | |||
2 | 2 | ||
3 | # fixes bug in floating point emulation on sparc64 when | 3 | # fixes bug in floating point emulation on sparc64 when |
4 | # this script produces off-by-one output on sparc64 | 4 | # this script produces off-by-one output on sparc64 |
5 | eval 'use integer;'; | 5 | use integer; |
6 | |||
7 | print STDERR "Warning: perl module integer not found.\n" if ($@); | ||
8 | 6 | ||
9 | sub obj_cmp | 7 | sub obj_cmp |
10 | { | 8 | { |
@@ -150,13 +148,13 @@ for ($i=0; $i<$n; $i++) | |||
150 | @a=grep(defined($sn{$nid{$_}}),0 .. $n); | 148 | @a=grep(defined($sn{$nid{$_}}),0 .. $n); |
151 | foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) | 149 | foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) |
152 | { | 150 | { |
153 | push(@sn,sprintf("&(nid_objs[%2d]),/* \"$sn{$nid{$_}}\" */\n",$_)); | 151 | push(@sn,sprintf("%2d,\t/* \"$sn{$nid{$_}}\" */\n",$_)); |
154 | } | 152 | } |
155 | 153 | ||
156 | @a=grep(defined($ln{$nid{$_}}),0 .. $n); | 154 | @a=grep(defined($ln{$nid{$_}}),0 .. $n); |
157 | foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) | 155 | foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) |
158 | { | 156 | { |
159 | push(@ln,sprintf("&(nid_objs[%2d]),/* \"$ln{$nid{$_}}\" */\n",$_)); | 157 | push(@ln,sprintf("%2d,\t/* \"$ln{$nid{$_}}\" */\n",$_)); |
160 | } | 158 | } |
161 | 159 | ||
162 | @a=grep(defined($obj{$nid{$_}}),0 .. $n); | 160 | @a=grep(defined($obj{$nid{$_}}),0 .. $n); |
@@ -166,7 +164,7 @@ foreach (sort obj_cmp @a) | |||
166 | $v=$objd{$m}; | 164 | $v=$objd{$m}; |
167 | $v =~ s/L//g; | 165 | $v =~ s/L//g; |
168 | $v =~ s/,/ /g; | 166 | $v =~ s/,/ /g; |
169 | push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v)); | 167 | push(@ob,sprintf("%2d,\t/* %-32s %s */\n",$_,$m,$v)); |
170 | } | 168 | } |
171 | 169 | ||
172 | print OUT <<'EOF'; | 170 | print OUT <<'EOF'; |
@@ -241,11 +239,11 @@ printf OUT "#define NUM_SN %d\n",$#sn+1; | |||
241 | printf OUT "#define NUM_LN %d\n",$#ln+1; | 239 | printf OUT "#define NUM_LN %d\n",$#ln+1; |
242 | printf OUT "#define NUM_OBJ %d\n\n",$#ob+1; | 240 | printf OUT "#define NUM_OBJ %d\n\n",$#ob+1; |
243 | 241 | ||
244 | printf OUT "static unsigned char lvalues[%d]={\n",$lvalues+1; | 242 | printf OUT "static const unsigned char lvalues[%d]={\n",$lvalues+1; |
245 | print OUT @lvalues; | 243 | print OUT @lvalues; |
246 | print OUT "};\n\n"; | 244 | print OUT "};\n\n"; |
247 | 245 | ||
248 | printf OUT "static ASN1_OBJECT nid_objs[NUM_NID]={\n"; | 246 | printf OUT "static const ASN1_OBJECT nid_objs[NUM_NID]={\n"; |
249 | foreach (@out) | 247 | foreach (@out) |
250 | { | 248 | { |
251 | if (length($_) > 75) | 249 | if (length($_) > 75) |
@@ -269,15 +267,15 @@ foreach (@out) | |||
269 | } | 267 | } |
270 | print OUT "};\n\n"; | 268 | print OUT "};\n\n"; |
271 | 269 | ||
272 | printf OUT "static ASN1_OBJECT *sn_objs[NUM_SN]={\n"; | 270 | printf OUT "static const unsigned int sn_objs[NUM_SN]={\n"; |
273 | print OUT @sn; | 271 | print OUT @sn; |
274 | print OUT "};\n\n"; | 272 | print OUT "};\n\n"; |
275 | 273 | ||
276 | printf OUT "static ASN1_OBJECT *ln_objs[NUM_LN]={\n"; | 274 | printf OUT "static const unsigned int ln_objs[NUM_LN]={\n"; |
277 | print OUT @ln; | 275 | print OUT @ln; |
278 | print OUT "};\n\n"; | 276 | print OUT "};\n\n"; |
279 | 277 | ||
280 | printf OUT "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n"; | 278 | printf OUT "static const unsigned int obj_objs[NUM_OBJ]={\n"; |
281 | print OUT @ob; | 279 | print OUT @ob; |
282 | print OUT "};\n\n"; | 280 | print OUT "};\n\n"; |
283 | 281 | ||
diff --git a/src/lib/libcrypto/objects/obj_err.c b/src/lib/libcrypto/objects/obj_err.c index 12b48850c6..2e7a034c3f 100644 --- a/src/lib/libcrypto/objects/obj_err.c +++ b/src/lib/libcrypto/objects/obj_err.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* crypto/objects/obj_err.c */ | 1 | /* crypto/objects/obj_err.c */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2006 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 |
diff --git a/src/lib/libcrypto/objects/obj_lib.c b/src/lib/libcrypto/objects/obj_lib.c index 706fa0b0e7..23e9d48cdf 100644 --- a/src/lib/libcrypto/objects/obj_lib.c +++ b/src/lib/libcrypto/objects/obj_lib.c | |||
@@ -66,7 +66,8 @@ ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o) | |||
66 | { | 66 | { |
67 | ASN1_OBJECT *r; | 67 | ASN1_OBJECT *r; |
68 | int i; | 68 | int i; |
69 | char *ln=NULL; | 69 | char *ln=NULL,*sn=NULL; |
70 | unsigned char *data=NULL; | ||
70 | 71 | ||
71 | if (o == NULL) return(NULL); | 72 | if (o == NULL) return(NULL); |
72 | if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC)) | 73 | if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC)) |
@@ -79,42 +80,42 @@ ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o) | |||
79 | OBJerr(OBJ_F_OBJ_DUP,ERR_R_ASN1_LIB); | 80 | OBJerr(OBJ_F_OBJ_DUP,ERR_R_ASN1_LIB); |
80 | return(NULL); | 81 | return(NULL); |
81 | } | 82 | } |
82 | r->data=OPENSSL_malloc(o->length); | 83 | data=OPENSSL_malloc(o->length); |
83 | if (r->data == NULL) | 84 | if (data == NULL) |
84 | goto err; | 85 | goto err; |
85 | if (o->data != NULL) | 86 | if (o->data != NULL) |
86 | memcpy(r->data,o->data,o->length); | 87 | memcpy(data,o->data,o->length); |
88 | /* once data attached to object it remains const */ | ||
89 | r->data = data; | ||
87 | r->length=o->length; | 90 | r->length=o->length; |
88 | r->nid=o->nid; | 91 | r->nid=o->nid; |
89 | r->ln=r->sn=NULL; | 92 | r->ln=r->sn=NULL; |
90 | if (o->ln != NULL) | 93 | if (o->ln != NULL) |
91 | { | 94 | { |
92 | i=strlen(o->ln)+1; | 95 | i=strlen(o->ln)+1; |
93 | r->ln=ln=OPENSSL_malloc(i); | 96 | ln=OPENSSL_malloc(i); |
94 | if (r->ln == NULL) goto err; | 97 | if (ln == NULL) goto err; |
95 | memcpy(ln,o->ln,i); | 98 | memcpy(ln,o->ln,i); |
99 | r->ln=ln; | ||
96 | } | 100 | } |
97 | 101 | ||
98 | if (o->sn != NULL) | 102 | if (o->sn != NULL) |
99 | { | 103 | { |
100 | char *s; | ||
101 | |||
102 | i=strlen(o->sn)+1; | 104 | i=strlen(o->sn)+1; |
103 | r->sn=s=OPENSSL_malloc(i); | 105 | sn=OPENSSL_malloc(i); |
104 | if (r->sn == NULL) goto err; | 106 | if (sn == NULL) goto err; |
105 | memcpy(s,o->sn,i); | 107 | memcpy(sn,o->sn,i); |
108 | r->sn=sn; | ||
106 | } | 109 | } |
107 | r->flags=o->flags|(ASN1_OBJECT_FLAG_DYNAMIC| | 110 | r->flags=o->flags|(ASN1_OBJECT_FLAG_DYNAMIC| |
108 | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|ASN1_OBJECT_FLAG_DYNAMIC_DATA); | 111 | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|ASN1_OBJECT_FLAG_DYNAMIC_DATA); |
109 | return(r); | 112 | return(r); |
110 | err: | 113 | err: |
111 | OBJerr(OBJ_F_OBJ_DUP,ERR_R_MALLOC_FAILURE); | 114 | OBJerr(OBJ_F_OBJ_DUP,ERR_R_MALLOC_FAILURE); |
112 | if (r != NULL) | 115 | if (ln != NULL) OPENSSL_free(ln); |
113 | { | 116 | if (sn != NULL) OPENSSL_free(sn); |
114 | if (ln != NULL) OPENSSL_free(ln); | 117 | if (data != NULL) OPENSSL_free(data); |
115 | if (r->data != NULL) OPENSSL_free(r->data); | 118 | if (r != NULL) OPENSSL_free(r); |
116 | OPENSSL_free(r); | ||
117 | } | ||
118 | return(NULL); | 119 | return(NULL); |
119 | } | 120 | } |
120 | 121 | ||
diff --git a/src/lib/libcrypto/objects/obj_mac.num b/src/lib/libcrypto/objects/obj_mac.num index e3f56bc52c..8c50aac27f 100644 --- a/src/lib/libcrypto/objects/obj_mac.num +++ b/src/lib/libcrypto/objects/obj_mac.num | |||
@@ -856,3 +856,37 @@ hmac 855 | |||
856 | LocalKeySet 856 | 856 | LocalKeySet 856 |
857 | freshest_crl 857 | 857 | freshest_crl 857 |
858 | id_on_permanentIdentifier 858 | 858 | id_on_permanentIdentifier 858 |
859 | searchGuide 859 | ||
860 | businessCategory 860 | ||
861 | postalAddress 861 | ||
862 | postOfficeBox 862 | ||
863 | physicalDeliveryOfficeName 863 | ||
864 | telephoneNumber 864 | ||
865 | telexNumber 865 | ||
866 | teletexTerminalIdentifier 866 | ||
867 | facsimileTelephoneNumber 867 | ||
868 | x121Address 868 | ||
869 | internationaliSDNNumber 869 | ||
870 | registeredAddress 870 | ||
871 | destinationIndicator 871 | ||
872 | preferredDeliveryMethod 872 | ||
873 | presentationAddress 873 | ||
874 | supportedApplicationContext 874 | ||
875 | member 875 | ||
876 | owner 876 | ||
877 | roleOccupant 877 | ||
878 | seeAlso 878 | ||
879 | userPassword 879 | ||
880 | userCertificate 880 | ||
881 | cACertificate 881 | ||
882 | authorityRevocationList 882 | ||
883 | certificateRevocationList 883 | ||
884 | crossCertificatePair 884 | ||
885 | enhancedSearchGuide 885 | ||
886 | protocolInformation 886 | ||
887 | distinguishedName 887 | ||
888 | uniqueMember 888 | ||
889 | houseIdentifier 889 | ||
890 | supportedAlgorithms 890 | ||
891 | deltaRevocationList 891 | ||
892 | dmdName 892 | ||
diff --git a/src/lib/libcrypto/objects/objects.h b/src/lib/libcrypto/objects/objects.h index 7242f76fb0..bd0ee52feb 100644 --- a/src/lib/libcrypto/objects/objects.h +++ b/src/lib/libcrypto/objects/objects.h | |||
@@ -1011,10 +1011,91 @@ int OBJ_txt2nid(const char *s); | |||
1011 | int OBJ_ln2nid(const char *s); | 1011 | int OBJ_ln2nid(const char *s); |
1012 | int OBJ_sn2nid(const char *s); | 1012 | int OBJ_sn2nid(const char *s); |
1013 | int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); | 1013 | int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); |
1014 | const char * OBJ_bsearch(const char *key,const char *base,int num,int size, | 1014 | const void * OBJ_bsearch_(const void *key,const void *base,int num,int size, |
1015 | int (*cmp)(const void *, const void *)); | 1015 | int (*cmp)(const void *, const void *)); |
1016 | const char * OBJ_bsearch_ex(const char *key,const char *base,int num, | 1016 | const void * OBJ_bsearch_ex_(const void *key,const void *base,int num, |
1017 | int size, int (*cmp)(const void *, const void *), int flags); | 1017 | int size, |
1018 | int (*cmp)(const void *, const void *), | ||
1019 | int flags); | ||
1020 | |||
1021 | #define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ | ||
1022 | static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ | ||
1023 | static int nm##_cmp(type1 const *, type2 const *); \ | ||
1024 | scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) | ||
1025 | |||
1026 | #define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ | ||
1027 | _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) | ||
1028 | #define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ | ||
1029 | type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) | ||
1030 | |||
1031 | /* | ||
1032 | * Unsolved problem: if a type is actually a pointer type, like | ||
1033 | * nid_triple is, then its impossible to get a const where you need | ||
1034 | * it. Consider: | ||
1035 | * | ||
1036 | * typedef int nid_triple[3]; | ||
1037 | * const void *a_; | ||
1038 | * const nid_triple const *a = a_; | ||
1039 | * | ||
1040 | * The assignement discards a const because what you really want is: | ||
1041 | * | ||
1042 | * const int const * const *a = a_; | ||
1043 | * | ||
1044 | * But if you do that, you lose the fact that a is an array of 3 ints, | ||
1045 | * which breaks comparison functions. | ||
1046 | * | ||
1047 | * Thus we end up having to cast, sadly, or unpack the | ||
1048 | * declarations. Or, as I finally did in this case, delcare nid_triple | ||
1049 | * to be a struct, which it should have been in the first place. | ||
1050 | * | ||
1051 | * Ben, August 2008. | ||
1052 | * | ||
1053 | * Also, strictly speaking not all types need be const, but handling | ||
1054 | * the non-constness means a lot of complication, and in practice | ||
1055 | * comparison routines do always not touch their arguments. | ||
1056 | */ | ||
1057 | |||
1058 | #define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ | ||
1059 | static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ | ||
1060 | { \ | ||
1061 | type1 const *a = a_; \ | ||
1062 | type2 const *b = b_; \ | ||
1063 | return nm##_cmp(a,b); \ | ||
1064 | } \ | ||
1065 | static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ | ||
1066 | { \ | ||
1067 | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | ||
1068 | nm##_cmp_BSEARCH_CMP_FN); \ | ||
1069 | } \ | ||
1070 | extern void dummy_prototype(void) | ||
1071 | |||
1072 | #define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ | ||
1073 | static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ | ||
1074 | { \ | ||
1075 | type1 const *a = a_; \ | ||
1076 | type2 const *b = b_; \ | ||
1077 | return nm##_cmp(a,b); \ | ||
1078 | } \ | ||
1079 | type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ | ||
1080 | { \ | ||
1081 | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | ||
1082 | nm##_cmp_BSEARCH_CMP_FN); \ | ||
1083 | } \ | ||
1084 | extern void dummy_prototype(void) | ||
1085 | |||
1086 | #define OBJ_bsearch(type1,key,type2,base,num,cmp) \ | ||
1087 | ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ | ||
1088 | num,sizeof(type2), \ | ||
1089 | ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ | ||
1090 | (void)CHECKED_PTR_OF(type2,cmp##_type_2), \ | ||
1091 | cmp##_BSEARCH_CMP_FN))) | ||
1092 | |||
1093 | #define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags) \ | ||
1094 | ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ | ||
1095 | num,sizeof(type2), \ | ||
1096 | ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ | ||
1097 | (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \ | ||
1098 | cmp##_BSEARCH_CMP_FN)),flags) | ||
1018 | 1099 | ||
1019 | int OBJ_new_nid(int num); | 1100 | int OBJ_new_nid(int num); |
1020 | int OBJ_add_object(const ASN1_OBJECT *obj); | 1101 | int OBJ_add_object(const ASN1_OBJECT *obj); |
@@ -1022,6 +1103,14 @@ int OBJ_create(const char *oid,const char *sn,const char *ln); | |||
1022 | void OBJ_cleanup(void ); | 1103 | void OBJ_cleanup(void ); |
1023 | int OBJ_create_objects(BIO *in); | 1104 | int OBJ_create_objects(BIO *in); |
1024 | 1105 | ||
1106 | int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid); | ||
1107 | int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid); | ||
1108 | int OBJ_add_sigid(int signid, int dig_id, int pkey_id); | ||
1109 | void OBJ_sigid_free(void); | ||
1110 | |||
1111 | extern int obj_cleanup_defer; | ||
1112 | void check_defer(int nid); | ||
1113 | |||
1025 | /* BEGIN ERROR CODES */ | 1114 | /* BEGIN ERROR CODES */ |
1026 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 1115 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
1027 | * made after this point may be overwritten when the script is next run. | 1116 | * made after this point may be overwritten when the script is next run. |
diff --git a/src/lib/libcrypto/objects/objects.pl b/src/lib/libcrypto/objects/objects.pl index 76bb8da677..d2bf659d88 100644 --- a/src/lib/libcrypto/objects/objects.pl +++ b/src/lib/libcrypto/objects/objects.pl | |||
@@ -14,6 +14,8 @@ while(<NUMIN>) | |||
14 | $Cname =~ s/^X//; | 14 | $Cname =~ s/^X//; |
15 | if (defined($nidn{$mynum})) | 15 | if (defined($nidn{$mynum})) |
16 | { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; } | 16 | { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; } |
17 | if (defined($nid{$Cname})) | ||
18 | { die "$ARGV[1]:$o:There's already an object with name ",$Cname," on line ",$order{$nid{$Cname}},"\n"; } | ||
17 | $nid{$Cname} = $mynum; | 19 | $nid{$Cname} = $mynum; |
18 | $nidn{$mynum} = $Cname; | 20 | $nidn{$mynum} = $Cname; |
19 | $order{$mynum} = $o; | 21 | $order{$mynum} = $o; |
@@ -102,6 +104,7 @@ while (<IN>) | |||
102 | $max_nid++; | 104 | $max_nid++; |
103 | $nid{$Cname} = $max_nid; | 105 | $nid{$Cname} = $max_nid; |
104 | $nidn{$max_nid} = $Cname; | 106 | $nidn{$max_nid} = $Cname; |
107 | print STDERR "Added OID $Cname\n"; | ||
105 | } | 108 | } |
106 | $Cname=""; | 109 | $Cname=""; |
107 | } | 110 | } |
diff --git a/src/lib/libcrypto/objects/objects.txt b/src/lib/libcrypto/objects/objects.txt index a6a811b8e7..e61fe60cbf 100644 --- a/src/lib/libcrypto/objects/objects.txt +++ b/src/lib/libcrypto/objects/objects.txt | |||
@@ -20,7 +20,7 @@ identified-organization 132 : certicom-arc | |||
20 | joint-iso-itu-t 23 : international-organizations : International Organizations | 20 | joint-iso-itu-t 23 : international-organizations : International Organizations |
21 | 21 | ||
22 | international-organizations 43 : wap | 22 | international-organizations 43 : wap |
23 | wap 13 : wap-wsg | 23 | wap 1 : wap-wsg |
24 | 24 | ||
25 | joint-iso-itu-t 5 1 5 : selected-attribute-types : Selected Attribute Types | 25 | joint-iso-itu-t 5 1 5 : selected-attribute-types : Selected Attribute Types |
26 | 26 | ||
@@ -664,18 +664,52 @@ X509 5 : : serialNumber | |||
664 | X509 6 : C : countryName | 664 | X509 6 : C : countryName |
665 | X509 7 : L : localityName | 665 | X509 7 : L : localityName |
666 | X509 8 : ST : stateOrProvinceName | 666 | X509 8 : ST : stateOrProvinceName |
667 | X509 9 : : streetAddress | 667 | X509 9 : street : streetAddress |
668 | X509 10 : O : organizationName | 668 | X509 10 : O : organizationName |
669 | X509 11 : OU : organizationalUnitName | 669 | X509 11 : OU : organizationalUnitName |
670 | X509 12 : : title | 670 | X509 12 : title : title |
671 | X509 13 : : description | 671 | X509 13 : : description |
672 | X509 17 : : postalCode | 672 | X509 14 : : searchGuide |
673 | X509 15 : : businessCategory | ||
674 | X509 16 : : postalAddress | ||
675 | X509 17 : : postalCode | ||
676 | X509 18 : : postOfficeBox | ||
677 | X509 19 : : physicalDeliveryOfficeName | ||
678 | X509 20 : : telephoneNumber | ||
679 | X509 21 : : telexNumber | ||
680 | X509 22 : : teletexTerminalIdentifier | ||
681 | X509 23 : : facsimileTelephoneNumber | ||
682 | X509 24 : : x121Address | ||
683 | X509 25 : : internationaliSDNNumber | ||
684 | X509 26 : : registeredAddress | ||
685 | X509 27 : : destinationIndicator | ||
686 | X509 28 : : preferredDeliveryMethod | ||
687 | X509 29 : : presentationAddress | ||
688 | X509 30 : : supportedApplicationContext | ||
689 | X509 31 : member : | ||
690 | X509 32 : owner : | ||
691 | X509 33 : : roleOccupant | ||
692 | X509 34 : seeAlso : | ||
693 | X509 35 : : userPassword | ||
694 | X509 36 : : userCertificate | ||
695 | X509 37 : : cACertificate | ||
696 | X509 38 : : authorityRevocationList | ||
697 | X509 39 : : certificateRevocationList | ||
698 | X509 40 : : crossCertificatePair | ||
673 | X509 41 : name : name | 699 | X509 41 : name : name |
674 | X509 42 : GN : givenName | 700 | X509 42 : GN : givenName |
675 | X509 43 : : initials | 701 | X509 43 : initials : initials |
676 | X509 44 : : generationQualifier | 702 | X509 44 : : generationQualifier |
677 | X509 45 : : x500UniqueIdentifier | 703 | X509 45 : : x500UniqueIdentifier |
678 | X509 46 : dnQualifier : dnQualifier | 704 | X509 46 : dnQualifier : dnQualifier |
705 | X509 47 : : enhancedSearchGuide | ||
706 | X509 48 : : protocolInformation | ||
707 | X509 49 : : distinguishedName | ||
708 | X509 50 : : uniqueMember | ||
709 | X509 51 : : houseIdentifier | ||
710 | X509 52 : : supportedAlgorithms | ||
711 | X509 53 : : deltaRevocationList | ||
712 | X509 54 : dmdName : | ||
679 | X509 65 : : pseudonym | 713 | X509 65 : : pseudonym |
680 | X509 72 : role : role | 714 | X509 72 : role : role |
681 | 715 | ||