X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fx509v3%2Fv3_crld.c;h=67feea40171fbe1e3fd1537d86e0dabab74c7983;hp=c0b63ee23cdf1dc60d7e83f53604e6987ff77f82;hb=62324627aa3309e4f72e3ff0241801f4286fa242;hpb=d943e3724162cb7668b90a34f689e7c2b89ebc64 diff --git a/crypto/x509v3/v3_crld.c b/crypto/x509v3/v3_crld.c index c0b63ee23c..67feea4017 100644 --- a/crypto/x509v3/v3_crld.c +++ b/crypto/x509v3/v3_crld.c @@ -58,43 +58,36 @@ #include #include "cryptlib.h" -#include "conf.h" -#include "asn1.h" -#include "asn1_mac.h" -#include "x509v3.h" +#include +#include +#include +#include -static STACK *i2v_crld(X509V3_EXT_METHOD *method, STACK_OF(DIST_POINT) *crld, - STACK *extlist); +static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, + STACK_OF(DIST_POINT) *crld, STACK_OF(CONF_VALUE) *extlist); static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK *nval); + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); X509V3_EXT_METHOD v3_crld = { NID_crl_distribution_points, X509V3_EXT_MULTILINE, (X509V3_EXT_NEW)CRL_DIST_POINTS_new, -CRL_DIST_POINTS_free, +(X509V3_EXT_FREE)CRL_DIST_POINTS_free, (X509V3_EXT_D2I)d2i_CRL_DIST_POINTS, -i2d_CRL_DIST_POINTS, +(X509V3_EXT_I2D)i2d_CRL_DIST_POINTS, NULL, NULL, (X509V3_EXT_I2V)i2v_crld, (X509V3_EXT_V2I)v2i_crld, NULL, NULL, NULL }; -/* - * ASN1err(ASN1_F_DIST_POINT_NEW,ERR_R_MALLOC_FAILURE); - * ASN1err(ASN1_F_D2I_DIST_POINT,ERR_R_MALLOC_FAILURE); - * ASN1err(ASN1_F_DIST_POINT_NAME_NEW,ERR_R_MALLOC_FAILURE); - * ASN1err(ASN1_F_D2I_DIST_POINT_NAME,ERR_R_MALLOC_FAILURE); - */ - -static STACK *i2v_crld(X509V3_EXT_METHOD *method, STACK_OF(DIST_POINT) *crld, - STACK *exts) +static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, + STACK_OF(DIST_POINT) *crld, STACK_OF(CONF_VALUE) *exts) { DIST_POINT *point; int i; for(i = 0; i < sk_DIST_POINT_num(crld); i++) { point = sk_DIST_POINT_value(crld, i); - if(point->distpoint->fullname) { + if(point->distpoint && point->distpoint->fullname) { exts = i2v_GENERAL_NAMES(NULL, point->distpoint->fullname, exts); } @@ -102,24 +95,24 @@ static STACK *i2v_crld(X509V3_EXT_METHOD *method, STACK_OF(DIST_POINT) *crld, X509V3_add_value("reasons","", &exts); if(point->CRLissuer) X509V3_add_value("CRLissuer","", &exts); - if(point->distpoint->relativename) + if(point->distpoint && point->distpoint->relativename) X509V3_add_value("RelativeName","", &exts); } return exts; } static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK *nval) + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { STACK_OF(DIST_POINT) *crld = NULL; STACK_OF(GENERAL_NAME) *gens = NULL; GENERAL_NAME *gen = NULL; CONF_VALUE *cnf; int i; - if(!(crld = sk_DIST_POINT_new(NULL))) goto merr; - for(i = 0; i < sk_num(nval); i++) { + if(!(crld = sk_DIST_POINT_new_null())) goto merr; + for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { DIST_POINT *point; - cnf = (CONF_VALUE *)sk_value(nval, i); + cnf = sk_CONF_VALUE_value(nval, i); if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; if(!(gens = GENERAL_NAMES_new())) goto merr; if(!sk_GENERAL_NAME_push(gens, gen)) goto merr; @@ -218,20 +211,20 @@ void DIST_POINT_free(DIST_POINT *a) { if (a == NULL) return; DIST_POINT_NAME_free(a->distpoint); - ASN1_BIT_STRING_free(a->reasons); + M_ASN1_BIT_STRING_free(a->reasons); sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free); - Free ((char *)a); + OPENSSL_free (a); } int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp) { - int v = 0; M_ASN1_I2D_vars(a); if(a->fullname) { M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES); } else { - M_ASN1_I2D_len_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); + M_ASN1_I2D_len_IMP_SET_opt_type(X509_NAME_ENTRY, + a->relativename, i2d_X509_NAME_ENTRY, 1); } /* Don't want a SEQUENCE so... */ @@ -241,7 +234,8 @@ int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp) if(a->fullname) { M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0); } else { - M_ASN1_I2D_put_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); + M_ASN1_I2D_put_IMP_SET_opt_type(X509_NAME_ENTRY, + a->relativename, i2d_X509_NAME_ENTRY, 1); } M_ASN1_I2D_finish(); } @@ -260,9 +254,9 @@ DIST_POINT_NAME *DIST_POINT_NAME_new(void) void DIST_POINT_NAME_free(DIST_POINT_NAME *a) { if (a == NULL) return; - X509_NAME_free(a->relativename); + sk_X509_NAME_ENTRY_pop_free(a->relativename, X509_NAME_ENTRY_free); sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free); - Free ((char *)a); + OPENSSL_free (a); } DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, @@ -280,7 +274,8 @@ DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES, V_ASN1_SEQUENCE); } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) { - M_ASN1_D2I_get_EXP_opt (ret->relativename, d2i_X509_NAME, 1); + M_ASN1_D2I_get_IMP_set_opt_type (X509_NAME_ENTRY, + ret->relativename, d2i_X509_NAME_ENTRY, X509_NAME_ENTRY_free, 1); } else { c.error = ASN1_R_BAD_TAG; goto err;