diff options
author | Matt Caswell <matt@openssl.org> | 2015-01-22 03:29:12 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-01-22 09:31:38 +0000 |
commit | ae5c8664e587f2445c8e4eb436cffbb64af4f6b8 (patch) | |
tree | 6d5b2cbee6396484f83126f8c7e7a36b9777a652 /crypto/objects | |
parent | aae3233e1e08e9f11742f8f351af5c98cd8add16 (diff) |
Run util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/objects')
-rw-r--r-- | crypto/objects/o_names.c | 579 | ||||
-rw-r--r-- | crypto/objects/obj_dat.c | 1308 | ||||
-rw-r--r-- | crypto/objects/obj_err.c | 54 | ||||
-rw-r--r-- | crypto/objects/obj_lib.c | 134 | ||||
-rw-r--r-- | crypto/objects/obj_mac.h | 7667 | ||||
-rw-r--r-- | crypto/objects/obj_xref.c | 276 | ||||
-rw-r--r-- | crypto/objects/obj_xref.h | 185 | ||||
-rw-r--r-- | crypto/objects/objects.h | 1765 |
8 files changed, 5971 insertions, 5997 deletions
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index 4a548c2ed4..e1e13a6131 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -8,7 +8,8 @@ #include <openssl/safestack.h> #include <openssl/e_os2.h> -/* Later versions of DEC C has started to add lnkage information to certain +/* + * Later versions of DEC C has started to add lnkage information to certain * functions, which makes it tricky to use them as values to regular function * pointers. One way is to define a macro that takes care of casting them * correctly. @@ -19,354 +20,344 @@ # define OPENSSL_strcmp strcmp #endif -/* I use the ex_data stuff to manage the identifiers for the obj_name_types +/* + * I use the ex_data stuff to manage the identifiers for the obj_name_types * that applications may define. I only really use the free function field. */ DECLARE_LHASH_OF(OBJ_NAME); -static LHASH_OF(OBJ_NAME) *names_lh=NULL; -static int names_type_num=OBJ_NAME_TYPE_NUM; +static LHASH_OF(OBJ_NAME) *names_lh = NULL; +static int names_type_num = OBJ_NAME_TYPE_NUM; -typedef struct name_funcs_st - { - unsigned long (*hash_func)(const char *name); - int (*cmp_func)(const char *a,const char *b); - void (*free_func)(const char *, int, const char *); - } NAME_FUNCS; +typedef struct name_funcs_st { + unsigned long (*hash_func) (const char *name); + int (*cmp_func) (const char *a, const char *b); + void (*free_func) (const char *, int, const char *); +} NAME_FUNCS; DECLARE_STACK_OF(NAME_FUNCS) IMPLEMENT_STACK_OF(NAME_FUNCS) static STACK_OF(NAME_FUNCS) *name_funcs_stack; -/* The LHASH callbacks now use the raw "void *" prototypes and do per-variable - * casting in the functions. This prevents function pointer casting without the - * need for macro-generated wrapper functions. */ +/* + * The LHASH callbacks now use the raw "void *" prototypes and do + * per-variable casting in the functions. This prevents function pointer + * casting without the need for macro-generated wrapper functions. + */ /* static unsigned long obj_name_hash(OBJ_NAME *a); */ static unsigned long obj_name_hash(const void *a_void); /* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */ -static int obj_name_cmp(const void *a_void,const void *b_void); +static int obj_name_cmp(const void *a_void, const void *b_void); static IMPLEMENT_LHASH_HASH_FN(obj_name, OBJ_NAME) static IMPLEMENT_LHASH_COMP_FN(obj_name, OBJ_NAME) int OBJ_NAME_init(void) - { - if (names_lh != NULL) return(1); - MemCheck_off(); - names_lh=lh_OBJ_NAME_new(); - MemCheck_on(); - return(names_lh != NULL); - } - -int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), - int (*cmp_func)(const char *, const char *), - void (*free_func)(const char *, int, const char *)) - { - int ret; - int i; - NAME_FUNCS *name_funcs; - - if (name_funcs_stack == NULL) - { - MemCheck_off(); - name_funcs_stack=sk_NAME_FUNCS_new_null(); - MemCheck_on(); - } - if (name_funcs_stack == NULL) - { - /* ERROR */ - return(0); - } - ret=names_type_num; - names_type_num++; - for (i=sk_NAME_FUNCS_num(name_funcs_stack); i<names_type_num; i++) - { - MemCheck_off(); - name_funcs = OPENSSL_malloc(sizeof(NAME_FUNCS)); - MemCheck_on(); - if (!name_funcs) - { - OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX,ERR_R_MALLOC_FAILURE); - return(0); - } - name_funcs->hash_func = lh_strhash; - name_funcs->cmp_func = OPENSSL_strcmp; - name_funcs->free_func = 0; /* NULL is often declared to - * ((void *)0), which according - * to Compaq C is not really - * compatible with a function - * pointer. -- Richard Levitte*/ - MemCheck_off(); - sk_NAME_FUNCS_push(name_funcs_stack,name_funcs); - MemCheck_on(); - } - name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret); - if (hash_func != NULL) - name_funcs->hash_func = hash_func; - if (cmp_func != NULL) - name_funcs->cmp_func = cmp_func; - if (free_func != NULL) - name_funcs->free_func = free_func; - return(ret); - } +{ + if (names_lh != NULL) + return (1); + MemCheck_off(); + names_lh = lh_OBJ_NAME_new(); + MemCheck_on(); + return (names_lh != NULL); +} + +int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *), + int (*cmp_func) (const char *, const char *), + void (*free_func) (const char *, int, const char *)) +{ + int ret; + int i; + NAME_FUNCS *name_funcs; + + if (name_funcs_stack == NULL) { + MemCheck_off(); + name_funcs_stack = sk_NAME_FUNCS_new_null(); + MemCheck_on(); + } + if (name_funcs_stack == NULL) { + /* ERROR */ + return (0); + } + ret = names_type_num; + names_type_num++; + for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) { + MemCheck_off(); + name_funcs = OPENSSL_malloc(sizeof(NAME_FUNCS)); + MemCheck_on(); + if (!name_funcs) { + OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE); + return (0); + } + name_funcs->hash_func = lh_strhash; + name_funcs->cmp_func = OPENSSL_strcmp; + name_funcs->free_func = 0; /* NULL is often declared to * ((void + * *)0), which according * to Compaq C is + * not really * compatible with a function + * * pointer. -- Richard Levitte */ + MemCheck_off(); + sk_NAME_FUNCS_push(name_funcs_stack, name_funcs); + MemCheck_on(); + } + name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret); + if (hash_func != NULL) + name_funcs->hash_func = hash_func; + if (cmp_func != NULL) + name_funcs->cmp_func = cmp_func; + if (free_func != NULL) + name_funcs->free_func = free_func; + return (ret); +} /* static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) */ static int obj_name_cmp(const void *a_void, const void *b_void) - { - int ret; - const OBJ_NAME *a = (const OBJ_NAME *)a_void; - const OBJ_NAME *b = (const OBJ_NAME *)b_void; - - ret=a->type-b->type; - if (ret == 0) - { - if ((name_funcs_stack != NULL) - && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) - { - ret=sk_NAME_FUNCS_value(name_funcs_stack, - a->type)->cmp_func(a->name,b->name); - } - else - ret=strcmp(a->name,b->name); - } - return(ret); - } +{ + int ret; + const OBJ_NAME *a = (const OBJ_NAME *)a_void; + const OBJ_NAME *b = (const OBJ_NAME *)b_void; + + ret = a->type - b->type; + if (ret == 0) { + if ((name_funcs_stack != NULL) + && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) { + ret = sk_NAME_FUNCS_value(name_funcs_stack, + a->type)->cmp_func(a->name, b->name); + } else + ret = strcmp(a->name, b->name); + } + return (ret); +} /* static unsigned long obj_name_hash(OBJ_NAME *a) */ static unsigned long obj_name_hash(const void *a_void) - { - unsigned long ret; - const OBJ_NAME *a = (const OBJ_NAME *)a_void; - - if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) - { - ret=sk_NAME_FUNCS_value(name_funcs_stack, - a->type)->hash_func(a->name); - } - else - { - ret=lh_strhash(a->name); - } - ret^=a->type; - return(ret); - } +{ + unsigned long ret; + const OBJ_NAME *a = (const OBJ_NAME *)a_void; + + if ((name_funcs_stack != NULL) + && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) { + ret = + sk_NAME_FUNCS_value(name_funcs_stack, + a->type)->hash_func(a->name); + } else { + ret = lh_strhash(a->name); + } + ret ^= a->type; + return (ret); +} const char *OBJ_NAME_get(const char *name, int type) - { - OBJ_NAME on,*ret; - int num=0,alias; - - if (name == NULL) return(NULL); - if ((names_lh == NULL) && !OBJ_NAME_init()) return(NULL); - - alias=type&OBJ_NAME_ALIAS; - type&= ~OBJ_NAME_ALIAS; - - on.name=name; - on.type=type; - - for (;;) - { - ret=lh_OBJ_NAME_retrieve(names_lh,&on); - if (ret == NULL) return(NULL); - if ((ret->alias) && !alias) - { - if (++num > 10) return(NULL); - on.name=ret->data; - } - else - { - return(ret->data); - } - } - } +{ + OBJ_NAME on, *ret; + int num = 0, alias; + + if (name == NULL) + return (NULL); + if ((names_lh == NULL) && !OBJ_NAME_init()) + return (NULL); + + alias = type & OBJ_NAME_ALIAS; + type &= ~OBJ_NAME_ALIAS; + + on.name = name; + on.type = type; + + for (;;) { + ret = lh_OBJ_NAME_retrieve(names_lh, &on); + if (ret == NULL) + return (NULL); + if ((ret->alias) && !alias) { + if (++num > 10) + return (NULL); + on.name = ret->data; + } else { + return (ret->data); + } + } +} int OBJ_NAME_add(const char *name, int type, const char *data) - { - OBJ_NAME *onp,*ret; - int alias; - - if ((names_lh == NULL) && !OBJ_NAME_init()) return(0); - - alias=type&OBJ_NAME_ALIAS; - type&= ~OBJ_NAME_ALIAS; - - onp=(OBJ_NAME *)OPENSSL_malloc(sizeof(OBJ_NAME)); - if (onp == NULL) - { - /* ERROR */ - return(0); - } - - onp->name=name; - onp->alias=alias; - onp->type=type; - onp->data=data; - - ret=lh_OBJ_NAME_insert(names_lh,onp); - if (ret != NULL) - { - /* free things */ - if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) - { - /* XXX: I'm not sure I understand why the free - * function should get three arguments... - * -- Richard Levitte - */ - sk_NAME_FUNCS_value(name_funcs_stack, - ret->type)->free_func(ret->name,ret->type,ret->data); - } - OPENSSL_free(ret); - } - else - { - if (lh_OBJ_NAME_error(names_lh)) - { - /* ERROR */ - return(0); - } - } - return(1); - } +{ + OBJ_NAME *onp, *ret; + int alias; + + if ((names_lh == NULL) && !OBJ_NAME_init()) + return (0); + + alias = type & OBJ_NAME_ALIAS; + type &= ~OBJ_NAME_ALIAS; + + onp = (OBJ_NAME *)OPENSSL_malloc(sizeof(OBJ_NAME)); + if (onp == NULL) { + /* ERROR */ + return (0); + } + + onp->name = name; + onp->alias = alias; + onp->type = type; + onp->data = data; + + ret = lh_OBJ_NAME_insert(names_lh, onp); + if (ret != NULL) { + /* free things */ + if ((name_funcs_stack != NULL) + && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) { + /* + * XXX: I'm not sure I understand why the free function should + * get three arguments... -- Richard Levitte + */ + sk_NAME_FUNCS_value(name_funcs_stack, + ret->type)->free_func(ret->name, ret->type, + ret->data); + } + OPENSSL_free(ret); + } else { + if (lh_OBJ_NAME_error(names_lh)) { + /* ERROR */ + return (0); + } + } + return (1); +} int OBJ_NAME_remove(const char *name, int type) - { - OBJ_NAME on,*ret; - - if (names_lh == NULL) return(0); - - type&= ~OBJ_NAME_ALIAS; - on.name=name; - on.type=type; - ret=lh_OBJ_NAME_delete(names_lh,&on); - if (ret != NULL) - { - /* free things */ - if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) - { - /* XXX: I'm not sure I understand why the free - * function should get three arguments... - * -- Richard Levitte - */ - sk_NAME_FUNCS_value(name_funcs_stack, - ret->type)->free_func(ret->name,ret->type,ret->data); - } - OPENSSL_free(ret); - return(1); - } - else - return(0); - } - -struct doall - { - int type; - void (*fn)(const OBJ_NAME *,void *arg); - void *arg; - }; - -static void do_all_fn_doall_arg(const OBJ_NAME *name,struct doall *d) - { - if(name->type == d->type) - d->fn(name,d->arg); - } +{ + OBJ_NAME on, *ret; + + if (names_lh == NULL) + return (0); + + type &= ~OBJ_NAME_ALIAS; + on.name = name; + on.type = type; + ret = lh_OBJ_NAME_delete(names_lh, &on); + if (ret != NULL) { + /* free things */ + if ((name_funcs_stack != NULL) + && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) { + /* + * XXX: I'm not sure I understand why the free function should + * get three arguments... -- Richard Levitte + */ + sk_NAME_FUNCS_value(name_funcs_stack, + ret->type)->free_func(ret->name, ret->type, + ret->data); + } + OPENSSL_free(ret); + return (1); + } else + return (0); +} + +struct doall { + int type; + void (*fn) (const OBJ_NAME *, void *arg); + void *arg; +}; + +static void do_all_fn_doall_arg(const OBJ_NAME *name, struct doall *d) +{ + if (name->type == d->type) + d->fn(name, d->arg); +} static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME, struct doall) -void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) - { - struct doall d; +void OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg), + void *arg) +{ + struct doall d; - d.type=type; - d.fn=fn; - d.arg=arg; + d.type = type; + d.fn = fn; + d.arg = arg; - lh_OBJ_NAME_doall_arg(names_lh, LHASH_DOALL_ARG_FN(do_all_fn), - struct doall, &d); - } + lh_OBJ_NAME_doall_arg(names_lh, LHASH_DOALL_ARG_FN(do_all_fn), + struct doall, &d); +} -struct doall_sorted - { - int type; - int n; - const OBJ_NAME **names; - }; +struct doall_sorted { + int type; + int n; + const OBJ_NAME **names; +}; -static void do_all_sorted_fn(const OBJ_NAME *name,void *d_) - { - struct doall_sorted *d=d_; +static void do_all_sorted_fn(const OBJ_NAME *name, void *d_) +{ + struct doall_sorted *d = d_; - if(name->type != d->type) - return; + if (name->type != d->type) + return; - d->names[d->n++]=name; - } + d->names[d->n++] = name; +} -static int do_all_sorted_cmp(const void *n1_,const void *n2_) - { - const OBJ_NAME * const *n1=n1_; - const OBJ_NAME * const *n2=n2_; +static int do_all_sorted_cmp(const void *n1_, const void *n2_) +{ + const OBJ_NAME *const *n1 = n1_; + const OBJ_NAME *const *n2 = n2_; - return strcmp((*n1)->name,(*n2)->name); - } + return strcmp((*n1)->name, (*n2)->name); +} -void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), - void *arg) - { - struct doall_sorted d; - int n; +void OBJ_NAME_do_all_sorted(int type, + void (*fn) (const OBJ_NAME *, void *arg), + void *arg) +{ + struct doall_sorted d; + int n; - d.type=type; - d.names=OPENSSL_malloc(lh_OBJ_NAME_num_items(names_lh)*sizeof *d.names); - d.n=0; - OBJ_NAME_do_all(type,do_all_sorted_fn,&d); + d.type = type; + d.names = + OPENSSL_malloc(lh_OBJ_NAME_num_items(names_lh) * sizeof *d.names); + d.n = 0; + OBJ_NAME_do_all(type, do_all_sorted_fn, &d); - qsort((void *)d.names,d.n,sizeof *d.names,do_all_sorted_cmp); + qsort((void *)d.names, d.n, sizeof *d.names, do_all_sorted_cmp); - for(n=0 ; n < d.n ; ++n) - fn(d.names[n],arg); + for (n = 0; n < d.n; ++n) + fn(d.names[n], arg); - OPENSSL_free((void *)d.names); - } + OPENSSL_free((void *)d.names); +} static int free_type; static void names_lh_free_doall(OBJ_NAME *onp) - { - if (onp == NULL) - return; +{ + if (onp == NULL) + return; - if (free_type < 0 || free_type == onp->type) - OBJ_NAME_remove(onp->name,onp->type); - } + if (free_type < 0 || free_type == onp->type) + OBJ_NAME_remove(onp->name, onp->type); +} static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME) static void name_funcs_free(NAME_FUNCS *ptr) - { - OPENSSL_free(ptr); - } +{ + OPENSSL_free(ptr); +} void OBJ_NAME_cleanup(int type) - { - unsigned long down_load; - - if (names_lh == NULL) return; - - free_type=type; - down_load=lh_OBJ_NAME_down_load(names_lh); - lh_OBJ_NAME_down_load(names_lh)=0; - - lh_OBJ_NAME_doall(names_lh,LHASH_DOALL_FN(names_lh_free)); - if (type < 0) - { - lh_OBJ_NAME_free(names_lh); - sk_NAME_FUNCS_pop_free(name_funcs_stack,name_funcs_free); - names_lh=NULL; - name_funcs_stack = NULL; - } - else - lh_OBJ_NAME_down_load(names_lh)=down_load; - } - +{ + unsigned long down_load; + + if (names_lh == NULL) + return; + + free_type = type; + down_load = lh_OBJ_NAME_down_load(names_lh); + lh_OBJ_NAME_down_load(names_lh) = 0; + + lh_OBJ_NAME_doall(names_lh, LHASH_DOALL_FN(names_lh_free)); + if (type < 0) { + lh_OBJ_NAME_free(names_lh); + sk_NAME_FUNCS_pop_free(name_funcs_stack, name_funcs_free); + names_lh = NULL; + name_funcs_stack = NULL; + } else + lh_OBJ_NAME_down_load(names_lh) = down_load; +} diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 146173b978..5cd755d77d 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -67,13 +67,13 @@ /* obj_dat.h is generated from objects.h by obj_dat.pl */ #ifndef OPENSSL_NO_OBJECT -#include "obj_dat.h" +# include "obj_dat.h" #else /* You will have to load all the objects needed manually in the application */ -#define NUM_NID 0 -#define NUM_SN 0 -#define NUM_LN 0 -#define NUM_OBJ 0 +# define NUM_NID 0 +# define NUM_SN 0 +# define NUM_LN 0 +# define NUM_OBJ 0 static const unsigned char lvalues[1]; static const ASN1_OBJECT nid_objs[1]; static const unsigned int sn_objs[1]; @@ -85,728 +85,712 @@ DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); -#define ADDED_DATA 0 -#define ADDED_SNAME 1 -#define ADDED_LNAME 2 -#define ADDED_NID 3 +#define ADDED_DATA 0 +#define ADDED_SNAME 1 +#define ADDED_LNAME 2 +#define ADDED_NID 3 -typedef struct added_obj_st - { - int type; - ASN1_OBJECT *obj; - } ADDED_OBJ; +typedef struct added_obj_st { + int type; + ASN1_OBJECT *obj; +} ADDED_OBJ; DECLARE_LHASH_OF(ADDED_OBJ); -static int new_nid=NUM_NID; -static LHASH_OF(ADDED_OBJ) *added=NULL; +static int new_nid = NUM_NID; +static LHASH_OF(ADDED_OBJ) *added = NULL; -static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) - { return(strcmp((*a)->sn,nid_objs[*b].sn)); } +static int sn_cmp(const ASN1_OBJECT *const *a, const unsigned int *b) +{ + return (strcmp((*a)->sn, nid_objs[*b].sn)); +} IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); -static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) - { return(strcmp((*a)->ln,nid_objs[*b].ln)); } +static int ln_cmp(const ASN1_OBJECT *const *a, const unsigned int *b) +{ + return (strcmp((*a)->ln, nid_objs[*b].ln)); +} IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); static unsigned long added_obj_hash(const ADDED_OBJ *ca) - { - const ASN1_OBJECT *a; - int i; - unsigned long ret=0; - unsigned char *p; - - a=ca->obj; - switch (ca->type) - { - case ADDED_DATA: - ret=a->length<<20L; - p=(unsigned char *)a->data; - for (i=0; i<a->length; i++) - ret^=p[i]<<((i*3)%24); - break; - case ADDED_SNAME: - ret=lh_strhash(a->sn); - break; - case ADDED_LNAME: - ret=lh_strhash(a->ln); - break; - case ADDED_NID: - ret=a->nid; - break; - default: - /* abort(); */ - return 0; - } - ret&=0x3fffffffL; - ret|=((unsigned long)ca->type)<<30L; - return(ret); - } +{ + const ASN1_OBJECT *a; + int i; + unsigned long ret = 0; + unsigned char *p; + + a = ca->obj; + switch (ca->type) { + case ADDED_DATA: + ret = a->length << 20L; + p = (unsigned char *)a->data; + for (i = 0; i < a->length; i++) + ret ^= p[i] << ((i * 3) % 24); + break; + case ADDED_SNAME: + ret = lh_strhash(a->sn); + break; + case ADDED_LNAME: + ret = lh_strhash(a->ln); + break; + case ADDED_NID: + ret = a->nid; + break; + default: + /* abort(); */ + return 0; + } + ret &= 0x3fffffffL; + ret |= ((unsigned long)ca->type) << 30L; + return (ret); +} + static IMPLEMENT_LHASH_HASH_FN(added_obj, ADDED_OBJ) static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb) - { - ASN1_OBJECT *a,*b; - int i; - - i=ca->type-cb->type; - if (i) return(i); - a=ca->obj; - b=cb->obj; - switch (ca->type) - { - case ADDED_DATA: - i=(a->length - b->length); - if (i) return(i); - return(memcmp(a->data,b->data,(size_t)a->length)); - case ADDED_SNAME: - if (a->sn == NULL) return(-1); - else if (b->sn == NULL) return(1); - else return(strcmp(a->sn,b->sn)); - case ADDED_LNAME: - if (a->ln == NULL) return(-1); - else if (b->ln == NULL) return(1); - else return(strcmp(a->ln,b->ln)); - case ADDED_NID: - return(a->nid-b->nid); - default: - /* abort(); */ - return 0; - } - } +{ + ASN1_OBJECT *a, *b; + int i; + + i = ca->type - cb->type; + if (i) + return (i); + a = ca->obj; + b = cb->obj; + switch (ca->type) { + case ADDED_DATA: + i = (a->length - b->length); + if (i) + return (i); + return (memcmp(a->data, b->data, (size_t)a->length)); + case ADDED_SNAME: + if (a->sn == NULL) + return (-1); + else if (b->sn == NULL) + return (1); + else + return (strcmp(a->sn, b->sn)); + case ADDED_LNAME: + if (a->ln == NULL) + return (-1); + else if (b->ln == NULL) + return (1); + else + return (strcmp(a->ln, b->ln)); + case ADDED_NID: + return (a->nid - b->nid); + default: + /* abort(); */ + return 0; + } +} + static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ) static int init_added(void) - { - if (added != NULL) return(1); - added=lh_ADDED_OBJ_new(); - return(added != NULL); - } +{ + if (added != NULL) + return (1); + added = lh_ADDED_OBJ_new(); + return (added != NULL); +} static void cleanup1_doall(ADDED_OBJ *a) - { - a->obj->nid=0; - a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC| - ASN1_OBJECT_FLAG_DYNAMIC_STRINGS| - ASN1_OBJECT_FLAG_DYNAMIC_DATA; - } +{ + a->obj->nid = 0; + a->obj->flags |= ASN1_OBJECT_FLAG_DYNAMIC | + ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA; +} static void cleanup2_doall(ADDED_OBJ *a) - { a->obj->nid++; } +{ + a->obj->nid++; +} static void cleanup3_doall(ADDED_OBJ *a) - { - if (--a->obj->nid == 0) - ASN1_OBJECT_free(a->obj); - OPENSSL_free(a); - } +{ + if (--a->obj->nid == 0) + ASN1_OBJECT_free(a->obj); + OPENSSL_free(a); +} static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ) static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ) static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ) -/* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting - * to use freed up OIDs. If neccessary the actual freeing up of OIDs is - * delayed. +/* + * The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting to + * use freed up OIDs. If neccessary the actual freeing up of OIDs is delayed. */ - int obj_cleanup_defer = 0; void check_defer(int nid) - { - if (!obj_cleanup_defer && nid >= NUM_NID) - obj_cleanup_defer = 1; - } +{ + if (!obj_cleanup_defer && nid >= NUM_NID) + obj_cleanup_defer = 1; +} void OBJ_cleanup(void) - { - if (obj_cleanup_defer) - { - obj_cleanup_defer = 2; - return ; - } - if (added == NULL) return; - lh_ADDED_OBJ_down_load(added) = 0; - lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */ - lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */ - lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */ - lh_ADDED_OBJ_free(added); - added=NULL; - } +{ + if (obj_cleanup_defer) { + obj_cleanup_defer = 2; + return; + } + if (added == NULL) + return; + lh_ADDED_OBJ_down_load(added) = 0; + lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */ + lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */ + lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */ + lh_ADDED_OBJ_free(added); + added = NULL; +} int OBJ_new_nid(int num) - { - int i; +{ + int i; - i=new_nid; - new_nid+=num; - return(i); - } + i = new_nid; + new_nid += num; + return (i); +} int OBJ_add_object(const ASN1_OBJECT *obj) - { - ASN1_OBJECT *o; - ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop; - int i; - - if (added == NULL) - if (!init_added()) return(0); - if ((o=OBJ_dup(obj)) == NULL) goto err; - if (!(ao[ADDED_NID]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; - if ((o->length != 0) && (obj->data != NULL)) - if (!(ao[ADDED_DATA]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; - if (o->sn != NULL) - if (!(ao[ADDED_SNAME]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; - if (o->ln != NULL) - if (!(ao[ADDED_LNAME]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; - - for (i=ADDED_DATA; i<=ADDED_NID; i++) - { - if (ao[i] != NULL) - { - ao[i]->type=i; - ao[i]->obj=o; - aop=lh_ADDED_OBJ_insert(added,ao[i]); - /* memory leak, buit should not normally matter */ - if (aop != NULL) - OPENSSL_free(aop); - } - } - o->flags&= ~(ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS| - ASN1_OBJECT_FLAG_DYNAMIC_DATA); - - return(o->nid); -err2: - OBJerr(OBJ_F_OBJ_ADD_OBJECT,ERR_R_MALLOC_FAILURE); -err: - for (i=ADDED_DATA; i<=ADDED_NID; i++) - if (ao[i] != NULL) OPENSSL_free(ao[i]); - if (o != NULL) OPENSSL_free(o); - return(NID_undef); - } +{ + ASN1_OBJECT *o; + ADDED_OBJ *ao[4] = { NULL, NULL, NULL, NULL }, *aop; + int i; + + if (added == NULL) + if (!init_added()) + return (0); + if ((o = OBJ_dup(obj)) == NULL) + goto err; + if (!(ao[ADDED_NID] = (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) + goto err2; + if ((o->length != 0) && (obj->data != NULL)) + if (! + (ao[ADDED_DATA] = (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) + goto err2; + if (o->sn != NULL) + if (! + (ao[ADDED_SNAME] = + (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED |