summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects/obj_dat.c
diff options
context:
space:
mode:
authorbeck <>2002-05-15 02:29:21 +0000
committerbeck <>2002-05-15 02:29:21 +0000
commitb64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch)
treefa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/objects/obj_dat.c
parente471e1ea98d673597b182ea85f29e30c97cd08b5 (diff)
downloadopenbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/objects/obj_dat.c')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 4b1bb9583a..8779ba7d1d 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -64,7 +64,7 @@
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65 65
66/* obj_dat.h is generated from objects.h by obj_dat.pl */ 66/* obj_dat.h is generated from objects.h by obj_dat.pl */
67#ifndef NO_OBJECT 67#ifndef OPENSSL_NO_OBJECT
68#include "obj_dat.h" 68#include "obj_dat.h"
69#else 69#else
70/* You will have to load all the objects needed manually in the application */ 70/* You will have to load all the objects needed manually in the application */
@@ -108,12 +108,14 @@ static int ln_cmp(const void *a, const void *b)
108 return(strcmp((*ap)->ln,(*bp)->ln)); 108 return(strcmp((*ap)->ln,(*bp)->ln));
109 } 109 }
110 110
111static unsigned long add_hash(ADDED_OBJ *ca) 111/* static unsigned long add_hash(ADDED_OBJ *ca) */
112static unsigned long add_hash(const void *ca_void)
112 { 113 {
113 ASN1_OBJECT *a; 114 const ASN1_OBJECT *a;
114 int i; 115 int i;
115 unsigned long ret=0; 116 unsigned long ret=0;
116 unsigned char *p; 117 unsigned char *p;
118 ADDED_OBJ *ca = (ADDED_OBJ *)ca_void;
117 119
118 a=ca->obj; 120 a=ca->obj;
119 switch (ca->type) 121 switch (ca->type)
@@ -142,10 +144,13 @@ static unsigned long add_hash(ADDED_OBJ *ca)
142 return(ret); 144 return(ret);
143 } 145 }
144 146
145static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) 147/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */
148static int add_cmp(const void *ca_void, const void *cb_void)
146 { 149 {
147 ASN1_OBJECT *a,*b; 150 ASN1_OBJECT *a,*b;
148 int i; 151 int i;
152 ADDED_OBJ *ca = (ADDED_OBJ *)ca_void;
153 ADDED_OBJ *cb = (ADDED_OBJ *)cb_void;
149 154
150 i=ca->type-cb->type; 155 i=ca->type-cb->type;
151 if (i) return(i); 156 if (i) return(i);
@@ -171,7 +176,6 @@ static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb)
171 /* abort(); */ 176 /* abort(); */
172 return 0; 177 return 0;
173 } 178 }
174 return(1); /* should not get here */
175 } 179 }
176 180
177static int init_added(void) 181static int init_added(void)
@@ -199,13 +203,17 @@ static void cleanup3(ADDED_OBJ *a)
199 OPENSSL_free(a); 203 OPENSSL_free(a);
200 } 204 }
201 205
206static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ *)
207static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ *)
208static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ *)
209
202void OBJ_cleanup(void) 210void OBJ_cleanup(void)
203 { 211 {
204 if (added == NULL) return; 212 if (added == NULL) return;
205 added->down_load=0; 213 added->down_load=0;
206 lh_doall(added,cleanup1); /* zero counters */ 214 lh_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */
207 lh_doall(added,cleanup2); /* set counters */ 215 lh_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */
208 lh_doall(added,cleanup3); /* free objects */ 216 lh_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */
209 lh_free(added); 217 lh_free(added);
210 added=NULL; 218 added=NULL;
211 } 219 }
@@ -219,7 +227,7 @@ int OBJ_new_nid(int num)
219 return(i); 227 return(i);
220 } 228 }
221 229
222int OBJ_add_object(ASN1_OBJECT *obj) 230int OBJ_add_object(const ASN1_OBJECT *obj)
223 { 231 {
224 ASN1_OBJECT *o; 232 ASN1_OBJECT *o;
225 ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop; 233 ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop;
@@ -355,7 +363,7 @@ const char *OBJ_nid2ln(int n)
355 } 363 }
356 } 364 }
357 365
358int OBJ_obj2nid(ASN1_OBJECT *a) 366int OBJ_obj2nid(const ASN1_OBJECT *a)
359 { 367 {
360 ASN1_OBJECT **op; 368 ASN1_OBJECT **op;
361 ADDED_OBJ ad,*adp; 369 ADDED_OBJ ad,*adp;
@@ -368,7 +376,7 @@ int OBJ_obj2nid(ASN1_OBJECT *a)
368 if (added != NULL) 376 if (added != NULL)
369 { 377 {
370 ad.type=ADDED_DATA; 378 ad.type=ADDED_DATA;
371 ad.obj=a; 379 ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
372 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 380 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
373 if (adp != NULL) return (adp->obj->nid); 381 if (adp != NULL) return (adp->obj->nid);
374 } 382 }
@@ -422,7 +430,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
422 return op; 430 return op;
423 } 431 }
424 432
425int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name) 433int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
426{ 434{
427 int i,idx=0,n=0,len,nid; 435 int i,idx=0,n=0,len,nid;
428 unsigned long l; 436 unsigned long l;
@@ -437,8 +445,7 @@ int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name)
437 return(0); 445 return(0);
438 } 446 }
439 447
440 nid=OBJ_obj2nid(a); 448 if (no_name || (nid=OBJ_obj2nid(a)) == NID_undef) {
441 if ((nid == NID_undef) || no_name) {
442 len=a->length; 449 len=a->length;
443 p=a->data; 450 p=a->data;
444 451
@@ -488,7 +495,7 @@ int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name)
488 return(n); 495 return(n);
489} 496}
490 497
491int OBJ_txt2nid(char *s) 498int OBJ_txt2nid(const char *s)
492{ 499{
493 ASN1_OBJECT *obj; 500 ASN1_OBJECT *obj;
494 int nid; 501 int nid;
@@ -547,10 +554,11 @@ static int obj_cmp(const void *ap, const void *bp)
547 return(memcmp(a->data,b->data,a->length)); 554 return(memcmp(a->data,b->data,a->length));
548 } 555 }
549 556
550char *OBJ_bsearch(char *key, char *base, int num, int size, int (*cmp)(const void *, const void *)) 557const char *OBJ_bsearch(const char *key, const char *base, int num, int size,
558 int (*cmp)(const void *, const void *))
551 { 559 {
552 int l,h,i,c; 560 int l,h,i,c;
553 char *p; 561 const char *p;
554 562
555 if (num == 0) return(NULL); 563 if (num == 0) return(NULL);
556 l=0; 564 l=0;
@@ -629,7 +637,7 @@ int OBJ_create_objects(BIO *in)
629 /* return(num); */ 637 /* return(num); */
630 } 638 }
631 639
632int OBJ_create(char *oid, char *sn, char *ln) 640int OBJ_create(const char *oid, const char *sn, const char *ln)
633 { 641 {
634 int ok=0; 642 int ok=0;
635 ASN1_OBJECT *op=NULL; 643 ASN1_OBJECT *op=NULL;
@@ -645,6 +653,8 @@ int OBJ_create(char *oid, char *sn, char *ln)
645 return(0); 653 return(0);
646 } 654 }
647 i=a2d_ASN1_OBJECT(buf,i,oid,-1); 655 i=a2d_ASN1_OBJECT(buf,i,oid,-1);
656 if (i == 0)
657 goto err;
648 op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln); 658 op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);
649 if (op == NULL) 659 if (op == NULL)
650 goto err; 660 goto err;