diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2000-12-08 19:09:35 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2000-12-08 19:09:35 +0000 |
commit | 9d6b1ce6441c7cc6aed344f02d9f676ab5e04217 (patch) | |
tree | 7329435a21d3289cb3caad6d3d6c065f484373e1 /crypto/x509v3/v3_crld.c | |
parent | 66ebbb6a56bc1688fa37878e4feec985b0c260d7 (diff) |
Merge from the ASN1 branch of new ASN1 code
to main trunk.
Lets see if the makes it to openssl-cvs :-)
Diffstat (limited to 'crypto/x509v3/v3_crld.c')
-rw-r--r-- | crypto/x509v3/v3_crld.c | 169 |
1 files changed, 24 insertions, 145 deletions
diff --git a/crypto/x509v3/v3_crld.c b/crypto/x509v3/v3_crld.c index 67feea4017..b1963a26e4 100644 --- a/crypto/x509v3/v3_crld.c +++ b/crypto/x509v3/v3_crld.c @@ -60,7 +60,7 @@ #include "cryptlib.h" #include <openssl/conf.h> #include <openssl/asn1.h> -#include <openssl/asn1_mac.h> +#include <openssl/asn1t.h> #include <openssl/x509v3.h> static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, @@ -87,16 +87,16 @@ static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, int i; for(i = 0; i < sk_DIST_POINT_num(crld); i++) { point = sk_DIST_POINT_value(crld, i); - if(point->distpoint && point->distpoint->fullname) { - exts = i2v_GENERAL_NAMES(NULL, - point->distpoint->fullname, exts); + if(point->distpoint) { + if(point->distpoint->type == 0) + exts = i2v_GENERAL_NAMES(NULL, + point->distpoint->name.fullname, exts); + else X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts); } if(point->reasons) X509V3_add_value("reasons","<UNSUPPORTED>", &exts); if(point->CRLissuer) X509V3_add_value("CRLissuer","<UNSUPPORTED>", &exts); - if(point->distpoint && point->distpoint->relativename) - X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts); } return exts; } @@ -105,7 +105,7 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { STACK_OF(DIST_POINT) *crld = NULL; - STACK_OF(GENERAL_NAME) *gens = NULL; + GENERAL_NAMES *gens = NULL; GENERAL_NAME *gen = NULL; CONF_VALUE *cnf; int i; @@ -123,7 +123,8 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, goto merr; } if(!(point->distpoint = DIST_POINT_NAME_new())) goto merr; - point->distpoint->fullname = gens; + point->distpoint->name.fullname = gens; + point->distpoint->type = 0; gens = NULL; } return crld; @@ -137,149 +138,27 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, return NULL; } -int i2d_CRL_DIST_POINTS(STACK_OF(DIST_POINT) *a, unsigned char **pp) -{ - -return i2d_ASN1_SET_OF_DIST_POINT(a, pp, i2d_DIST_POINT, V_ASN1_SEQUENCE, - V_ASN1_UNIVERSAL, IS_SEQUENCE);} - -STACK_OF(DIST_POINT) *CRL_DIST_POINTS_new(void) -{ - return sk_DIST_POINT_new_null(); -} - -void CRL_DIST_POINTS_free(STACK_OF(DIST_POINT) *a) -{ - sk_DIST_POINT_pop_free(a, DIST_POINT_free); -} - -STACK_OF(DIST_POINT) *d2i_CRL_DIST_POINTS(STACK_OF(DIST_POINT) **a, - unsigned char **pp,long length) -{ -return d2i_ASN1_SET_OF_DIST_POINT(a, pp, length, d2i_DIST_POINT, - DIST_POINT_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); - -} - IMPLEMENT_STACK_OF(DIST_POINT) IMPLEMENT_ASN1_SET_OF(DIST_POINT) -int i2d_DIST_POINT(DIST_POINT *a, unsigned char **pp) -{ - int v = 0; - M_ASN1_I2D_vars(a); - /* NB: underlying type is a CHOICE so need EXPLICIT tagging */ - M_ASN1_I2D_len_EXP_opt (a->distpoint, i2d_DIST_POINT_NAME, 0, v); - M_ASN1_I2D_len_IMP_opt (a->reasons, i2d_ASN1_BIT_STRING); - M_ASN1_I2D_len_IMP_opt (a->CRLissuer, i2d_GENERAL_NAMES); - M_ASN1_I2D_seq_total(); +ASN1_CHOICE(DIST_POINT_NAME) = { + ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0), + ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1) +} ASN1_CHOICE_END(DIST_POINT_NAME); - M_ASN1_I2D_put_EXP_opt (a->distpoint, i2d_DIST_POINT_NAME, 0, v); - M_ASN1_I2D_put_IMP_opt (a->reasons, i2d_ASN1_BIT_STRING, 1); - M_ASN1_I2D_put_IMP_opt (a->CRLissuer, i2d_GENERAL_NAMES, 2); +IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME) - M_ASN1_I2D_finish(); -} +ASN1_SEQUENCE(DIST_POINT) = { + ASN1_EXP_OPT(DIST_POINT, distpoint, DIST_POINT_NAME, 0), + ASN1_IMP_OPT(DIST_POINT, reasons, ASN1_BIT_STRING, 1), + ASN1_IMP_SEQUENCE_OF_OPT(DIST_POINT, distpoint, GENERAL_NAME, 2) +} ASN1_SEQUENCE_END(DIST_POINT); -DIST_POINT *DIST_POINT_new(void) -{ - DIST_POINT *ret=NULL; - ASN1_CTX c; - M_ASN1_New_Malloc(ret, DIST_POINT); - ret->distpoint = NULL; - ret->reasons = NULL; - ret->CRLissuer = NULL; - return (ret); - M_ASN1_New_Error(ASN1_F_DIST_POINT_NEW); -} +IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT) -DIST_POINT *d2i_DIST_POINT(DIST_POINT **a, unsigned char **pp, long length) -{ - M_ASN1_D2I_vars(a,DIST_POINT *,DIST_POINT_new); - M_ASN1_D2I_Init(); - M_ASN1_D2I_start_sequence(); - M_ASN1_D2I_get_EXP_opt (ret->distpoint, d2i_DIST_POINT_NAME, 0); - M_ASN1_D2I_get_IMP_opt (ret->reasons, d2i_ASN1_BIT_STRING, 1, - V_ASN1_BIT_STRING); - M_ASN1_D2I_get_IMP_opt (ret->CRLissuer, d2i_GENERAL_NAMES, 2, - V_ASN1_SEQUENCE); - M_ASN1_D2I_Finish(a, DIST_POINT_free, ASN1_F_D2I_DIST_POINT); -} +ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, DIST_POINT, DIST_POINT) +ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS); -void DIST_POINT_free(DIST_POINT *a) -{ - if (a == NULL) return; - DIST_POINT_NAME_free(a->distpoint); - M_ASN1_BIT_STRING_free(a->reasons); - sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free); - OPENSSL_free (a); -} - -int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp) -{ - M_ASN1_I2D_vars(a); - - if(a->fullname) { - M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES); - } else { - M_ASN1_I2D_len_IMP_SET_opt_type(X509_NAME_ENTRY, - a->relativename, i2d_X509_NAME_ENTRY, 1); - } - - /* Don't want a SEQUENCE so... */ - if(pp == NULL) return ret; - p = *pp; - - if(a->fullname) { - M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0); - } else { - M_ASN1_I2D_put_IMP_SET_opt_type(X509_NAME_ENTRY, - a->relativename, i2d_X509_NAME_ENTRY, 1); - } - M_ASN1_I2D_finish(); -} - -DIST_POINT_NAME *DIST_POINT_NAME_new(void) -{ - DIST_POINT_NAME *ret=NULL; - ASN1_CTX c; - M_ASN1_New_Malloc(ret, DIST_POINT_NAME); - ret->fullname = NULL; - ret->relativename = NULL; - return (ret); - M_ASN1_New_Error(ASN1_F_DIST_POINT_NAME_NEW); -} - -void DIST_POINT_NAME_free(DIST_POINT_NAME *a) -{ - if (a == NULL) return; - sk_X509_NAME_ENTRY_pop_free(a->relativename, X509_NAME_ENTRY_free); - sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free); - OPENSSL_free (a); -} - -DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, - long length) -{ - unsigned char _tmp, tag; - M_ASN1_D2I_vars(a,DIST_POINT_NAME *,DIST_POINT_NAME_new); - M_ASN1_D2I_Init(); - c.slen = length; - - _tmp = M_ASN1_next; - tag = _tmp & ~V_ASN1_CONSTRUCTED; - - if(tag == (0|V_ASN1_CONTEXT_SPECIFIC)) { - 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_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; - } - - M_ASN1_D2I_Finish(a, DIST_POINT_NAME_free, ASN1_F_D2I_DIST_POINT_NAME); -} +IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS) |