diff options
author | Dr. Stephen Henson <steve@openssl.org> | 1999-04-20 01:10:33 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 1999-04-20 01:10:33 +0000 |
commit | f5fedc0497ef4a7b4d60d404f9b37020967eab94 (patch) | |
tree | 2a11ceff0837be591b43c2c10936bdd8c921c524 /crypto/x509v3 | |
parent | e4aac1cb684a630d4e55bf5960d4fd8d1dbcccd1 (diff) |
Various fixes so Win32 compile may work. Convert GeneralNames to use safe stack.
Diffstat (limited to 'crypto/x509v3')
-rw-r--r-- | crypto/x509v3/v3_akey.c | 10 | ||||
-rw-r--r-- | crypto/x509v3/v3_alt.c | 75 | ||||
-rw-r--r-- | crypto/x509v3/v3_conf.c | 8 | ||||
-rw-r--r-- | crypto/x509v3/v3_genn.c | 25 | ||||
-rw-r--r-- | crypto/x509v3/v3_lib.c | 2 | ||||
-rw-r--r-- | crypto/x509v3/x509v3.h | 30 |
6 files changed, 82 insertions, 68 deletions
diff --git a/crypto/x509v3/v3_akey.c b/crypto/x509v3/v3_akey.c index 7d54d0c235..3bb31869a1 100644 --- a/crypto/x509v3/v3_akey.c +++ b/crypto/x509v3/v3_akey.c @@ -141,7 +141,7 @@ void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a) { if (a == NULL) return; ASN1_OCTET_STRING_free(a->keyid); - sk_pop_free(a->issuer, GENERAL_NAME_free); + sk_GENERAL_NAME_pop_free(a->issuer, GENERAL_NAME_free); ASN1_INTEGER_free (a->serial); Free ((char *)a); } @@ -182,7 +182,7 @@ int i; CONF_VALUE *cnf; ASN1_OCTET_STRING *ikeyid = NULL; X509_NAME *isname = NULL; -STACK * gens = NULL; +STACK_OF(GENERAL_NAME) * gens = NULL; GENERAL_NAME *gen = NULL; ASN1_INTEGER *serial = NULL; X509_EXTENSION *ext; @@ -216,7 +216,7 @@ cert = ctx->issuer_cert; if(keyid) { i = X509_get_ext_by_NID(cert, NID_subject_key_identifier, -1); if((i >= 0) && (ext = X509_get_ext(cert, i))) - ikeyid = (ASN1_OCTET_STRING *) X509V3_EXT_d2i(ext); + ikeyid = X509V3_EXT_d2i(ext); if(keyid==2 && !ikeyid) { X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNABLE_TO_GET_ISSUER_KEYID); return NULL; @@ -235,8 +235,8 @@ if((issuer && !ikeyid) || (issuer == 2)) { if(!(akeyid = AUTHORITY_KEYID_new())) goto err; if(isname) { - if(!(gens = sk_new(NULL)) || !(gen = GENERAL_NAME_new()) - || !sk_push(gens, (char *)gen)) { + if(!(gens = sk_GENERAL_NAME_new(NULL)) || !(gen = GENERAL_NAME_new()) + || !sk_GENERAL_NAME_push(gens, gen)) { X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,ERR_R_MALLOC_FAILURE); goto err; } diff --git a/crypto/x509v3/v3_alt.c b/crypto/x509v3/v3_alt.c index b8054eb636..e9bfad8025 100644 --- a/crypto/x509v3/v3_alt.c +++ b/crypto/x509v3/v3_alt.c @@ -62,10 +62,10 @@ #include "x509v3.h" #ifndef NOPROTO -static STACK *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK *nval); -static STACK *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK *nval); -static int copy_email(X509V3_CTX *ctx, STACK *gens); -static int copy_issuer(X509V3_CTX *ctx, STACK *gens); +static STACK_OF(GENERAL_NAME) *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK *nval); +static STACK_OF(GENERAL_NAME) *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK *nval); +static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens); +static int copy_issuer(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens); #else static STACK *v2i_issuer_alt(); static STACK *v2i_subject_alt(); @@ -95,19 +95,20 @@ NULL, NULL, NULL}, EXT_END }; -STACK *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, STACK *gens, STACK *ret) +STACK *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, + STACK_OF(GENERAL_NAME) *gens, STACK *ret) { int i; GENERAL_NAME *gen; - for(i = 0; i < sk_num(gens); i++) { - gen = (GENERAL_NAME *)sk_value(gens, i); + for(i = 0; i < sk_GENERAL_NAME_num(gens); i++) { + gen = sk_GENERAL_NAME_value(gens, i); ret = i2v_GENERAL_NAME(method, gen, ret); } return ret; } STACK *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, - STACK *ret) + STACK *ret) { char oline[256]; unsigned char *p; @@ -161,13 +162,13 @@ STACK *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, return ret; } -static STACK *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - STACK *nval) +static STACK_OF(GENERAL_NAME) *v2i_issuer_alt(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK *nval) { - STACK *gens = NULL; + STACK_OF(GENERAL_NAME) *gens = NULL; CONF_VALUE *cnf; int i; - if(!(gens = sk_new(NULL))) { + if(!(gens = sk_GENERAL_NAME_new(NULL))) { X509V3err(X509V3_F_V2I_GENERAL_NAMES,ERR_R_MALLOC_FAILURE); return NULL; } @@ -180,21 +181,21 @@ static STACK *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, GENERAL_NAME *gen; if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; - sk_push(gens, (char *)gen); + sk_GENERAL_NAME_push(gens, gen); } } return gens; err: - sk_pop_free(gens, GENERAL_NAME_free); + sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return NULL; } /* Append subject altname of issuer to issuer alt name of subject */ -static int copy_issuer(X509V3_CTX *ctx, STACK *gens) +static int copy_issuer(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens) { - STACK *ialt; - char *gen; + STACK_OF(GENERAL_NAME) *ialt; + GENERAL_NAME *gen; X509_EXTENSION *ext; int i; if(ctx && (ctx->flags == CTX_TEST)) return 1; @@ -205,19 +206,19 @@ static int copy_issuer(X509V3_CTX *ctx, STACK *gens) i = X509_get_ext_by_NID(ctx->issuer_cert, NID_subject_alt_name, -1); if(i < 0) return 1; if(!(ext = X509_get_ext(ctx->issuer_cert, i)) || - !(ialt = (STACK *) X509V3_EXT_d2i(ext)) ) { + !(ialt = X509V3_EXT_d2i(ext)) ) { X509V3err(X509V3_F_COPY_ISSUER,X509V3_R_ISSUER_DECODE_ERROR); goto err; } - for(i = 0; i < sk_num(ialt); i++) { - gen = sk_value(ialt, i); - if(!sk_push(gens, gen)) { + for(i = 0; i < sk_GENERAL_NAME_num(ialt); i++) { + gen = sk_GENERAL_NAME_value(ialt, i); + if(!sk_GENERAL_NAME_push(gens, gen)) { X509V3err(X509V3_F_COPY_ISSUER,ERR_R_MALLOC_FAILURE); goto err; } } - sk_free(ialt); + sk_GENERAL_NAME_free(ialt); return 1; @@ -226,13 +227,13 @@ static int copy_issuer(X509V3_CTX *ctx, STACK *gens) } -static STACK *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - STACK *nval) +static STACK_OF(GENERAL_NAME) *v2i_subject_alt(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK *nval) { - STACK *gens = NULL; + STACK_OF(GENERAL_NAME) *gens = NULL; CONF_VALUE *cnf; int i; - if(!(gens = sk_new(NULL))) { + if(!(gens = sk_GENERAL_NAME_new(NULL))) { X509V3err(X509V3_F_V2I_GENERAL_NAMES,ERR_R_MALLOC_FAILURE); return NULL; } @@ -245,12 +246,12 @@ static STACK *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, GENERAL_NAME *gen; if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; - sk_push(gens, (char *)gen); + sk_GENERAL_NAME_push(gens, gen); } } return gens; err: - sk_pop_free(gens, GENERAL_NAME_free); + sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return NULL; } @@ -258,7 +259,7 @@ static STACK *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, * GENERAL_NAMES */ -static int copy_email(X509V3_CTX *ctx, STACK *gens) +static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens) { X509_NAME *nm; ASN1_IA5STRING *email = NULL; @@ -287,7 +288,7 @@ static int copy_email(X509V3_CTX *ctx, STACK *gens) gen->d.ia5 = email; email = NULL; gen->type = GEN_EMAIL; - if(!sk_push(gens, (char *)gen)) { + if(!sk_GENERAL_NAME_push(gens, gen)) { X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE); goto err; } @@ -304,30 +305,30 @@ static int copy_email(X509V3_CTX *ctx, STACK *gens) } -STACK *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - STACK *nval) +STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK *nval) { GENERAL_NAME *gen; - STACK *gens = NULL; + STACK_OF(GENERAL_NAME) *gens = NULL; CONF_VALUE *cnf; int i; - if(!(gens = sk_new(NULL))) { + if(!(gens = sk_GENERAL_NAME_new(NULL))) { X509V3err(X509V3_F_V2I_GENERAL_NAMES,ERR_R_MALLOC_FAILURE); return NULL; } for(i = 0; i < sk_num(nval); i++) { cnf = (CONF_VALUE *)sk_value(nval, i); if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; - sk_push(gens, (char *)gen); + sk_GENERAL_NAME_push(gens, gen); } return gens; err: - sk_pop_free(gens, GENERAL_NAME_free); + sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return NULL; } GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - CONF_VALUE *cnf) + CONF_VALUE *cnf) { char is_string = 0; int type; diff --git a/crypto/x509v3/v3_conf.c b/crypto/x509v3/v3_conf.c index 59a24ef871..d2485827da 100644 --- a/crypto/x509v3/v3_conf.c +++ b/crypto/x509v3/v3_conf.c @@ -71,11 +71,15 @@ static int v3_check_critical(char **value); static int v3_check_generic(char **value); static X509_EXTENSION *do_ext_conf(LHASH *conf, X509V3_CTX *ctx, int ext_nid, int crit, char *value); static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, int crit, int type); +static char *conf_lhash_get_string(void *db, char *section, char *value); +static STACK *conf_lhash_get_section(void *db, char *section); #else static int v3_check_critical(); static int v3_check_generic(); static X509_EXTENSION *do_ext_conf(); static X509V3_EXTENSION *v3_generic_extension(); +static char *conf_lhash_get_string(); +static STACK *conf_lhash_get_section(); #endif /* LHASH *conf: Config file */ @@ -299,14 +303,14 @@ void X509V3_string_free(X509V3_CTX *ctx, char *str) { if(!str) return; if(ctx->db_meth->free_string) - return ctx->db_meth->free_string(ctx->db, str); + ctx->db_meth->free_string(ctx->db, str); } void X509V3_section_free(X509V3_CTX *ctx, STACK *section) { if(!section) return; if(ctx->db_meth->free_section) - return ctx->db_meth->free_section(ctx->db, section); + ctx->db_meth->free_section(ctx->db, section); } static char *conf_lhash_get_string(void *db, char *section, char *value) diff --git a/crypto/x509v3/v3_genn.c b/crypto/x509v3/v3_genn.c index d2804c3353..fb0d47280b 100644 --- a/crypto/x509v3/v3_genn.c +++ b/crypto/x509v3/v3_genn.c @@ -118,7 +118,7 @@ int i2d_GENERAL_NAME(GENERAL_NAME *a, unsigned char **pp) return ret; } -GENERAL_NAME *GENERAL_NAME_new(void) +GENERAL_NAME *GENERAL_NAME_new() { GENERAL_NAME *ret=NULL; ASN1_CTX c; @@ -130,7 +130,7 @@ GENERAL_NAME *GENERAL_NAME_new(void) } GENERAL_NAME *d2i_GENERAL_NAME(GENERAL_NAME **a, unsigned char **pp, - long length) + long length) { unsigned char _tmp; M_ASN1_D2I_vars(a,GENERAL_NAME *,GENERAL_NAME_new); @@ -214,24 +214,29 @@ void GENERAL_NAME_free(GENERAL_NAME *a) * an explicit functions. */ -STACK *GENERAL_NAMES_new(void) +STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new() { - return sk_new(NULL); + return sk_GENERAL_NAME_new(NULL); } -void GENERAL_NAMES_free(STACK *a) +void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *a) { - sk_pop_free(a, GENERAL_NAME_free); + sk_GENERAL_NAME_pop_free(a, GENERAL_NAME_free); } -STACK *d2i_GENERAL_NAMES(STACK **a, unsigned char **pp, long length) +STACK_OF(GENERAL_NAME) *d2i_GENERAL_NAMES(STACK_OF(GENERAL_NAME) **a, + unsigned char **pp, long length) { -return d2i_ASN1_SET(a, pp, length, (char *(*)())d2i_GENERAL_NAME, +return d2i_ASN1_SET_OF_GENERAL_NAME(a, pp, length, d2i_GENERAL_NAME, GENERAL_NAME_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); } -int i2d_GENERAL_NAMES(STACK *a, unsigned char **pp) +int i2d_GENERAL_NAMES(STACK_OF(GENERAL_NAME) *a, unsigned char **pp) { -return i2d_ASN1_SET(a, pp, i2d_GENERAL_NAME, V_ASN1_SEQUENCE, +return i2d_ASN1_SET_OF_GENERAL_NAME(a, pp, i2d_GENERAL_NAME, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE); } + +IMPLEMENT_STACK_OF(GENERAL_NAME) +IMPLEMENT_ASN1_SET_OF(GENERAL_NAME) + diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c index af105723a2..55b807c1c8 100644 --- a/crypto/x509v3/v3_lib.c +++ b/crypto/x509v3/v3_lib.c @@ -164,7 +164,7 @@ int X509V3_add_standard_extensions(void) /* Return an extension internal structure */ -char *X509V3_EXT_d2i(X509_EXTENSION *ext) +void *X509V3_EXT_d2i(X509_EXTENSION *ext) { X509V3_EXT_METHOD *method; unsigned char *p; diff --git a/crypto/x509v3/x509v3.h b/crypto/x509v3/x509v3.h index 6c3937d0f3..84443cb786 100644 --- a/crypto/x509v3/x509v3.h +++ b/crypto/x509v3/x509v3.h @@ -148,11 +148,6 @@ int ca; ASN1_INTEGER *pathlen; } BASIC_CONSTRAINTS; -typedef struct AUTHORITY_KEYID_st { -ASN1_OCTET_STRING *keyid; -STACK *issuer; -ASN1_INTEGER *serial; -} AUTHORITY_KEYID; typedef struct PKEY_USAGE_PERIOD_st { ASN1_GENERALIZEDTIME *notBefore; @@ -182,6 +177,15 @@ union { } d; } GENERAL_NAME; +DECLARE_STACK_OF(GENERAL_NAME) +DECLARE_ASN1_SET_OF(GENERAL_NAME) + +typedef struct AUTHORITY_KEYID_st { +ASN1_OCTET_STRING *keyid; +STACK_OF(GENERAL_NAME) *issuer; +ASN1_INTEGER *serial; +} AUTHORITY_KEYID; + /* Strong extranet structures */ typedef struct SXNET_ID_st { @@ -298,12 +302,12 @@ PKEY_USAGE_PERIOD *d2i_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD **a, unsigned char ** PKEY_USAGE_PERIOD *PKEY_USAGE_PERIOD_new(void); void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a); -STACK *GENERAL_NAMES_new(void); -void GENERAL_NAMES_free(STACK *a); -STACK *d2i_GENERAL_NAMES(STACK **a, unsigned char **pp, long length); -int i2d_GENERAL_NAMES(STACK *a, unsigned char **pp); -STACK *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, STACK *gen, STACK *extlist); -STACK *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK *nval); +STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new(void); +void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *a); +STACK_OF(GENERAL_NAME) *d2i_GENERAL_NAMES(STACK_OF(GENERAL_NAME) **a, unsigned char **pp, long length); +int i2d_GENERAL_NAMES(STACK_OF(GENERAL_NAME) *a, unsigned char **pp); +STACK *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, STACK_OF(GENERAL_NAME) *gen, STACK *extlist); +STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK *nval); char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); @@ -373,7 +377,7 @@ X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); int X509V3_add_standard_extensions(void); STACK *X509V3_parse_list(char *line); -char *X509V3_EXT_d2i(X509_EXTENSION *ext); +void *X509V3_EXT_d2i(X509_EXTENSION *ext); char *hex_to_string(unsigned char *buffer, long len); unsigned char *string_to_hex(char *str, long *len); @@ -495,7 +499,7 @@ X509V3_EXT_METHOD *X509V3_EXT_get(); X509V3_EXT_METHOD *X509V3_EXT_get_nid(); int X509V3_add_standard_extensions(); STACK *X509V3_parse_list(); -char *X509V3_EXT_d2i(); +void *X509V3_EXT_d2i(); char *hex_to_string(); unsigned char *string_to_hex(); |