diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/x509v3/v3_crld.c | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/x509v3/v3_crld.c')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_crld.c | 181 |
1 files changed, 29 insertions, 152 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_crld.c b/src/lib/libcrypto/x509v3/v3_crld.c index 67feea4017..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 && 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 && point->distpoint->relativename) | ||
99 | X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts); | ||
100 | } | 98 | } |
101 | return exts; | 99 | return exts; |
102 | } | 100 | } |
@@ -105,7 +103,7 @@ 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; |
@@ -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,149 +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 | M_ASN1_BIT_STRING_free(a->reasons); | ||
215 | sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free); | ||
216 | OPENSSL_free (a); | ||
217 | } | ||
218 | |||
219 | int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp) | ||
220 | { | ||
221 | M_ASN1_I2D_vars(a); | ||
222 | |||
223 | if(a->fullname) { | ||
224 | M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES); | ||
225 | } else { | ||
226 | M_ASN1_I2D_len_IMP_SET_opt_type(X509_NAME_ENTRY, | ||
227 | a->relativename, i2d_X509_NAME_ENTRY, 1); | ||
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_IMP_SET_opt_type(X509_NAME_ENTRY, | ||
238 | a->relativename, i2d_X509_NAME_ENTRY, 1); | ||
239 | } | ||
240 | M_ASN1_I2D_finish(); | ||
241 | } | ||
242 | |||
243 | DIST_POINT_NAME *DIST_POINT_NAME_new(void) | ||
244 | { | ||
245 | DIST_POINT_NAME *ret=NULL; | ||
246 | ASN1_CTX c; | ||
247 | M_ASN1_New_Malloc(ret, DIST_POINT_NAME); | ||
248 | ret->fullname = NULL; | ||
249 | ret->relativename = NULL; | ||
250 | return (ret); | ||
251 | M_ASN1_New_Error(ASN1_F_DIST_POINT_NAME_NEW); | ||
252 | } | ||
253 | |||
254 | void DIST_POINT_NAME_free(DIST_POINT_NAME *a) | ||
255 | { | ||
256 | if (a == NULL) return; | ||
257 | sk_X509_NAME_ENTRY_pop_free(a->relativename, X509_NAME_ENTRY_free); | ||
258 | sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free); | ||
259 | OPENSSL_free (a); | ||
260 | } | ||
261 | |||
262 | DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp, | ||
263 | long length) | ||
264 | { | ||
265 | unsigned char _tmp, tag; | ||
266 | M_ASN1_D2I_vars(a,DIST_POINT_NAME *,DIST_POINT_NAME_new); | ||
267 | M_ASN1_D2I_Init(); | ||
268 | c.slen = length; | ||
269 | |||
270 | _tmp = M_ASN1_next; | ||
271 | tag = _tmp & ~V_ASN1_CONSTRUCTED; | ||
272 | |||
273 | if(tag == (0|V_ASN1_CONTEXT_SPECIFIC)) { | ||
274 | M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES, | ||
275 | V_ASN1_SEQUENCE); | ||
276 | } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) { | ||
277 | M_ASN1_D2I_get_IMP_set_opt_type (X509_NAME_ENTRY, | ||
278 | ret->relativename, d2i_X509_NAME_ENTRY, X509_NAME_ENTRY_free, 1); | ||
279 | } else { | ||
280 | c.error = ASN1_R_BAD_TAG; | ||
281 | goto err; | ||
282 | } | ||
283 | |||
284 | M_ASN1_D2I_Finish(a, DIST_POINT_NAME_free, ASN1_F_D2I_DIST_POINT_NAME); | ||
285 | } | ||