diff options
| author | markus <> | 2002-09-05 12:51:50 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 12:51:50 +0000 |
| commit | 15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch) | |
| tree | bf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/x509v3/v3_crld.c | |
| parent | 027351f729b9e837200dae6e1520cda6577ab930 (diff) | |
| download | openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2 openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip | |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/x509v3/v3_crld.c')
| -rw-r--r-- | src/lib/libcrypto/x509v3/v3_crld.c | 181 |
1 files changed, 30 insertions, 151 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_crld.c b/src/lib/libcrypto/x509v3/v3_crld.c index 897ffb63e4..894a8b94d8 100644 --- a/src/lib/libcrypto/x509v3/v3_crld.c +++ b/src/lib/libcrypto/x509v3/v3_crld.c | |||
| @@ -60,7 +60,7 @@ | |||
| 60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
| 61 | #include <openssl/conf.h> | 61 | #include <openssl/conf.h> |
| 62 | #include <openssl/asn1.h> | 62 | #include <openssl/asn1.h> |
| 63 | #include <openssl/asn1_mac.h> | 63 | #include <openssl/asn1t.h> |
| 64 | #include <openssl/x509v3.h> | 64 | #include <openssl/x509v3.h> |
| 65 | 65 | ||
| 66 | static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, | 66 | static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, |
| @@ -69,15 +69,13 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, | |||
| 69 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | 69 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); |
| 70 | 70 | ||
| 71 | X509V3_EXT_METHOD v3_crld = { | 71 | X509V3_EXT_METHOD v3_crld = { |
| 72 | NID_crl_distribution_points, X509V3_EXT_MULTILINE, | 72 | NID_crl_distribution_points, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(CRL_DIST_POINTS), |
| 73 | (X509V3_EXT_NEW)CRL_DIST_POINTS_new, | 73 | 0,0,0,0, |
| 74 | (X509V3_EXT_FREE)CRL_DIST_POINTS_free, | 74 | 0,0, |
| 75 | (X509V3_EXT_D2I)d2i_CRL_DIST_POINTS, | ||
| 76 | (X509V3_EXT_I2D)i2d_CRL_DIST_POINTS, | ||
| 77 | NULL, NULL, | ||
| 78 | (X509V3_EXT_I2V)i2v_crld, | 75 | (X509V3_EXT_I2V)i2v_crld, |
| 79 | (X509V3_EXT_V2I)v2i_crld, | 76 | (X509V3_EXT_V2I)v2i_crld, |
| 80 | NULL, NULL, NULL | 77 | 0,0, |
| 78 | NULL | ||
| 81 | }; | 79 | }; |
| 82 | 80 | ||
| 83 | static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, | 81 | static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, |
| @@ -87,16 +85,16 @@ static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, | |||
| 87 | int i; | 85 | int i; |
| 88 | for(i = 0; i < sk_DIST_POINT_num(crld); i++) { | 86 | for(i = 0; i < sk_DIST_POINT_num(crld); i++) { |
| 89 | point = sk_DIST_POINT_value(crld, i); | 87 | point = sk_DIST_POINT_value(crld, i); |
| 90 | if(point->distpoint->fullname) { | 88 | if(point->distpoint) { |
| 91 | exts = i2v_GENERAL_NAMES(NULL, | 89 | if(point->distpoint->type == 0) |
| 92 | point->distpoint->fullname, exts); | 90 | exts = i2v_GENERAL_NAMES(NULL, |
| 91 | point->distpoint->name.fullname, exts); | ||
| 92 | else X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts); | ||
| 93 | } | 93 | } |
| 94 | if(point->reasons) | 94 | if(point->reasons) |
| 95 | X509V3_add_value("reasons","<UNSUPPORTED>", &exts); | 95 | X509V3_add_value("reasons","<UNSUPPORTED>", &exts); |
| 96 | if(point->CRLissuer) | 96 | if(point->CRLissuer) |
| 97 | X509V3_add_value("CRLissuer","<UNSUPPORTED>", &exts); | 97 | X509V3_add_value("CRLissuer","<UNSUPPORTED>", &exts); |
| 98 | if(point->distpoint->relativename) | ||
| 99 | X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts); | ||
| 100 | } | 98 | } |
| 101 | return exts; | 99 | return exts; |
| 102 | } | 100 | } |
| @@ -105,11 +103,11 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, | |||
| 105 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | 103 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) |
| 106 | { | 104 | { |
| 107 | STACK_OF(DIST_POINT) *crld = NULL; | 105 | STACK_OF(DIST_POINT) *crld = NULL; |
| 108 | STACK_OF(GENERAL_NAME) *gens = NULL; | 106 | GENERAL_NAMES *gens = NULL; |
| 109 | GENERAL_NAME *gen = NULL; | 107 | GENERAL_NAME *gen = NULL; |
| 110 | CONF_VALUE *cnf; | 108 | CONF_VALUE *cnf; |
| 111 | int i; | 109 | int i; |
| 112 | if(!(crld = sk_DIST_POINT_new(NULL))) goto merr; | 110 | if(!(crld = sk_DIST_POINT_new_null())) goto merr; |
| 113 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | 111 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { |
| 114 | DIST_POINT *point; | 112 | DIST_POINT *point; |
| 115 | cnf = sk_CONF_VALUE_value(nval, i); | 113 | cnf = sk_CONF_VALUE_value(nval, i); |
| @@ -123,7 +121,8 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, | |||
| 123 | goto merr; | 121 | goto merr; |
| 124 | } | 122 | } |
| 125 | if(!(point->distpoint = DIST_POINT_NAME_new())) goto merr; | 123 | if(!(point->distpoint = DIST_POINT_NAME_new())) goto merr; |
| 126 | point->distpoint->fullname = gens; | 124 | point->distpoint->name.fullname = gens; |
| 125 | point->distpoint->type = 0; | ||
| 127 | gens = NULL; | 126 | gens = NULL; |
| 128 | } | 127 | } |
| 129 | return crld; | 128 | return crld; |
| @@ -137,147 +136,27 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, | |||
| 137 | return NULL; | 136 | return NULL; |
| 138 | } | 137 | } |
| 139 | 138 | ||
| 140 | int i2d_CRL_DIST_POINTS(STACK_OF(DIST_POINT) *a, unsigned char **pp) | ||
| 141 | { | ||
| 142 | |||
| 143 | return i2d_ASN1_SET_OF_DIST_POINT(a, pp, i2d_DIST_POINT, V_ASN1_SEQUENCE, | ||
| 144 | V_ASN1_UNIVERSAL, IS_SEQUENCE);} | ||
| 145 | |||
| 146 | STACK_OF(DIST_POINT) *CRL_DIST_POINTS_new(void) | ||
| 147 | { | ||
| 148 | return sk_DIST_POINT_new_null(); | ||
| 149 | } | ||
| 150 | |||
| 151 | void CRL_DIST_POINTS_free(STACK_OF(DIST_POINT) *a) | ||
| 152 | { | ||
| 153 | sk_DIST_POINT_pop_free(a, DIST_POINT_free); | ||
| 154 | } | ||
| 155 | |||
| 156 | STACK_OF(DIST_POINT) *d2i_CRL_DIST_POINTS(STACK_OF(DIST_POINT) **a, | ||
| 157 | unsigned char **pp,long length) | ||
| 158 | { | ||
| 159 | return d2i_ASN1_SET_OF_DIST_POINT(a, pp, length, d2i_DIST_POINT, | ||
| 160 | DIST_POINT_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); | ||
| 161 | |||
| 162 | } | ||
| 163 | |||
| 164 | IMPLEMENT_STACK_OF(DIST_POINT) | 139 | IMPLEMENT_STACK_OF(DIST_POINT) |
| 165 | IMPLEMENT_ASN1_SET_OF(DIST_POINT) | 140 | IMPLEMENT_ASN1_SET_OF(DIST_POINT) |
| 166 | 141 | ||
| 167 | int i2d_DIST_POINT(DIST_POINT *a, unsigned char **pp) | ||
| 168 | { | ||
| 169 | int v = 0; | ||
| 170 | M_ASN1_I2D_vars(a); | ||
| 171 | /* NB: underlying type is a CHOICE so need EXPLICIT tagging */ | ||
| 172 | M_ASN1_I2D_len_EXP_opt (a->distpoint, i2d_DIST_POINT_NAME, 0, v); | ||
| 173 | M_ASN1_I2D_len_IMP_opt (a->reasons, i2d_ASN1_BIT_STRING); | ||
| 174 | M_ASN1_I2D_len_IMP_opt (a->CRLissuer, i2d_GENERAL_NAMES); | ||
| 175 | 142 | ||
| 176 | M_ASN1_I2D_seq_total(); | 143 | ASN1_CHOICE(DIST_POINT_NAME) = { |
| 144 | ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0), | ||
| 145 | ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1) | ||
| 146 | } ASN1_CHOICE_END(DIST_POINT_NAME) | ||
| 177 | 147 | ||
| 178 | M_ASN1_I2D_put_EXP_opt (a->distpoint, i2d_DIST_POINT_NAME, 0, v); | 148 | IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME) |
| 179 | M_ASN1_I2D_put_IMP_opt (a->reasons, i2d_ASN1_BIT_STRING, 1); | ||
| 180 | M_ASN1_I2D_put_IMP_opt (a->CRLissuer, i2d_GENERAL_NAMES, 2); | ||
| 181 | 149 | ||
| 182 | M_ASN1_I2D_finish(); | 150 | ASN1_SEQUENCE(DIST_POINT) = { |
| 183 | } | 151 | ASN1_EXP_OPT(DIST_POINT, distpoint, DIST_POINT_NAME, 0), |
| 152 | ASN1_IMP_OPT(DIST_POINT, reasons, ASN1_BIT_STRING, 1), | ||
| 153 | ASN1_IMP_SEQUENCE_OF_OPT(DIST_POINT, CRLissuer, GENERAL_NAME, 2) | ||
| 154 | } ASN1_SEQUENCE_END(DIST_POINT) | ||
| 184 | 155 | ||
| 185 | DIST_POINT *DIST_POINT_new(void) | 156 | IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT) |
| 186 | { | ||
| 187 | DIST_POINT *ret=NULL; | ||
| 188 | ASN1_CTX c; | ||
| 189 | M_ASN1_New_Malloc(ret, DIST_POINT); | ||
| 190 | ret->distpoint = NULL; | ||
| 191 | ret->reasons = NULL; | ||
| 192 | ret->CRLissuer = NULL; | ||
| 193 | return (ret); | ||
| 194 | M_ASN1_New_Error(ASN1_F_DIST_POINT_NEW); | ||
| 195 | } | ||
| 196 | 157 | ||
| 197 | DIST_POINT *d2i_DIST_POINT(DIST_POINT **a, unsigned char **pp, long length) | 158 | ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) = |
| 198 | { | 159 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, DIST_POINT, DIST_POINT) |
| 199 | M_ASN1_D2I_vars(a,DIST_POINT *,DIST_POINT_new); | 160 | ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS) |
| 200 | M_ASN1_D2I_Init(); | ||
| 201 | M_ASN1_D2I_start_sequence(); | ||
| 202 | M_ASN1_D2I_get_EXP_opt (ret->distpoint, d2i_DIST_POINT_NAME, 0); | ||
| 203 | M_ASN1_D2I_get_IMP_opt (ret->reasons, d2i_ASN1_BIT_STRING, 1, | ||
| 204 | V_ASN1_BIT_STRING); | ||
| 205 | M_ASN1_D2I_get_IMP_opt (ret->CRLissuer, d2i_GENERAL_NAMES, 2, | ||
| 206 | V_ASN1_SEQUENCE); | ||
| 207 | M_ASN1_D2I_Finish(a, DIST_POINT_free, ASN1_F_D2I_DIST_POINT); | ||
| 208 | } | ||
| 209 | 161 | ||
| 210 | void DIST_POINT_free(DIST_POINT *a) | 162 | IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS) |
| 211 | { | ||
| 212 | if (a == NULL) return; | ||
| 213 | DIST_POINT_NAME_free(a->distpoint); | ||
| 214 | ASN1_BIT_STRING_free(a->reasons); | ||
| 215 | sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free); | ||
| 216 | Free ((char *)a); | ||
| 217 | } | ||
| 218 | |||
| 219 | int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp) | ||
| 220 | { | ||
| 221 | int v = 0; | ||
| 222 | M_ASN1_I2D_vars(a); | ||
| 223 | |||
| 224 | if(a->fullname) { | ||
| 225 | M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES); | ||
| 226 | } else { | ||
| 227 | M_ASN1_I2D_len_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); | ||
| 228 | } | ||
| 229 | |||
| 230 | /* Don't want a SEQUENCE so... */ | ||
| 231 | if(pp == NULL) return ret; | ||
| 232 | p = *pp; | ||
| 233 | |||
| 234 | if(a->fullname) { | ||
| 235 | M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0); | ||
| 236 | } else { | ||
| 237 | M_ASN1_I2D_put_EXP_opt (a->relativename, i2d_X509_NAME, 1, v); | ||
| 238 | } | ||
| 239 | M_ASN1_I2D_finish(); | ||
| 240 | } | ||
| 241 | |||
| 242 | DIST_POINT_NAME *DIST_POINT_NAME_new(void) | ||
| 243 | { | ||
| 244 | DIST_POINT_NAME *ret=NULL; | ||
| 245 | ASN1_CTX c; | ||
| 246 | M_ASN1_New_Malloc(ret, DIST_POINT_NAME); | ||
| 247 | ret->fullname = NULL; | ||
| 248 | ret->relativename = NULL; | ||
| 249 | return (ret); | ||
| 250 | M_ASN1_New_Error(ASN1_F_DIST_POINT_NAME_NEW); | ||
| 251 | } | ||
| 252 | |||
| 253 | void DIST_POINT_NAME_free(DIST_POINT_NAME *a) | ||
| 254 | { | ||
| 255 | if (a == NULL) return; | ||
| 256 | X509_NAME_free(a->relativename); | ||
| 257 | sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free); | ||
| 258 | Free ((char *)a); | ||
| 259 | } | ||
| 260 | |||
| 261 | DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, | ||
| 262 | long length) | ||
| 263 | { | ||
| 264 | unsigned char _tmp, tag; | ||
| 265 | M_ASN1_D2I_vars(a,DIST_POINT_NAME *,DIST_POINT_NAME_new); | ||
| 266 | M_ASN1_D2I_Init(); | ||
| 267 | c.slen = length; | ||
| 268 | |||
| 269 | _tmp = M_ASN1_next; | ||
| 270 | tag = _tmp & ~V_ASN1_CONSTRUCTED; | ||
| 271 | |||
| 272 | if(tag == (0|V_ASN1_CONTEXT_SPECIFIC)) { | ||
| 273 | M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES, | ||
| 274 | V_ASN1_SEQUENCE); | ||
| 275 | } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) { | ||
| 276 | M_ASN1_D2I_get_EXP_opt (ret->relativename, d2i_X509_NAME, 1); | ||
| 277 | } else { | ||
| 278 | c.error = ASN1_R_BAD_TAG; | ||
| 279 | goto err; | ||
| 280 | } | ||
| 281 | |||
| 282 | M_ASN1_D2I_Finish(a, DIST_POINT_NAME_free, ASN1_F_D2I_DIST_POINT_NAME); | ||
| 283 | } | ||
