/src/openssl34/crypto/x509/v3_crld.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (the "License"). You may not use |
5 | | * this file except in compliance with the License. You can obtain a copy |
6 | | * in the file LICENSE in the source distribution or at |
7 | | * https://www.openssl.org/source/license.html |
8 | | */ |
9 | | |
10 | | #include <stdio.h> |
11 | | #include "internal/cryptlib.h" |
12 | | #include <openssl/conf.h> |
13 | | #include <openssl/asn1.h> |
14 | | #include <openssl/asn1t.h> |
15 | | #include <openssl/x509v3.h> |
16 | | |
17 | | #include "crypto/x509.h" |
18 | | #include "ext_dat.h" |
19 | | #include "x509_local.h" |
20 | | |
21 | | static void *v2i_crld(const X509V3_EXT_METHOD *method, |
22 | | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); |
23 | | static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out, |
24 | | int indent); |
25 | | |
26 | | const X509V3_EXT_METHOD ossl_v3_crld = { |
27 | | NID_crl_distribution_points, 0, ASN1_ITEM_ref(CRL_DIST_POINTS), |
28 | | 0, 0, 0, 0, |
29 | | 0, 0, |
30 | | 0, |
31 | | v2i_crld, |
32 | | i2r_crldp, 0, |
33 | | NULL |
34 | | }; |
35 | | |
36 | | const X509V3_EXT_METHOD ossl_v3_freshest_crl = { |
37 | | NID_freshest_crl, 0, ASN1_ITEM_ref(CRL_DIST_POINTS), |
38 | | 0, 0, 0, 0, |
39 | | 0, 0, |
40 | | 0, |
41 | | v2i_crld, |
42 | | i2r_crldp, 0, |
43 | | NULL |
44 | | }; |
45 | | |
46 | | static STACK_OF(GENERAL_NAME) *gnames_from_sectname(X509V3_CTX *ctx, |
47 | | char *sect) |
48 | 0 | { |
49 | 0 | STACK_OF(CONF_VALUE) *gnsect; |
50 | 0 | STACK_OF(GENERAL_NAME) *gens; |
51 | 0 | if (*sect == '@') |
52 | 0 | gnsect = X509V3_get_section(ctx, sect + 1); |
53 | 0 | else |
54 | 0 | gnsect = X509V3_parse_list(sect); |
55 | 0 | if (!gnsect) { |
56 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND); |
57 | 0 | return NULL; |
58 | 0 | } |
59 | 0 | gens = v2i_GENERAL_NAMES(NULL, ctx, gnsect); |
60 | 0 | if (*sect == '@') |
61 | 0 | X509V3_section_free(ctx, gnsect); |
62 | 0 | else |
63 | 0 | sk_CONF_VALUE_pop_free(gnsect, X509V3_conf_free); |
64 | 0 | return gens; |
65 | 0 | } |
66 | | |
67 | | static int set_dist_point_name(DIST_POINT_NAME **pdp, X509V3_CTX *ctx, |
68 | | CONF_VALUE *cnf) |
69 | 0 | { |
70 | 0 | STACK_OF(GENERAL_NAME) *fnm = NULL; |
71 | 0 | STACK_OF(X509_NAME_ENTRY) *rnm = NULL; |
72 | |
|
73 | 0 | if (cnf->value == NULL) { |
74 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_MISSING_VALUE); |
75 | 0 | goto err; |
76 | 0 | } |
77 | | |
78 | 0 | if (HAS_PREFIX(cnf->name, "fullname")) { |
79 | 0 | fnm = gnames_from_sectname(ctx, cnf->value); |
80 | 0 | if (!fnm) |
81 | 0 | goto err; |
82 | 0 | } else if (strcmp(cnf->name, "relativename") == 0) { |
83 | 0 | int ret; |
84 | 0 | STACK_OF(CONF_VALUE) *dnsect; |
85 | 0 | X509_NAME *nm; |
86 | 0 | nm = X509_NAME_new(); |
87 | 0 | if (nm == NULL) |
88 | 0 | return -1; |
89 | 0 | dnsect = X509V3_get_section(ctx, cnf->value); |
90 | 0 | if (!dnsect) { |
91 | 0 | X509_NAME_free(nm); |
92 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND); |
93 | 0 | return -1; |
94 | 0 | } |
95 | 0 | ret = X509V3_NAME_from_section(nm, dnsect, MBSTRING_ASC); |
96 | 0 | X509V3_section_free(ctx, dnsect); |
97 | 0 | rnm = nm->entries; |
98 | 0 | nm->entries = NULL; |
99 | 0 | X509_NAME_free(nm); |
100 | 0 | if (!ret || sk_X509_NAME_ENTRY_num(rnm) <= 0) |
101 | 0 | goto err; |
102 | | /* |
103 | | * Since its a name fragment can't have more than one RDNSequence |
104 | | */ |
105 | 0 | if (sk_X509_NAME_ENTRY_value(rnm, |
106 | 0 | sk_X509_NAME_ENTRY_num(rnm) - 1) |
107 | 0 | ->set) { |
108 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_MULTIPLE_RDNS); |
109 | 0 | goto err; |
110 | 0 | } |
111 | 0 | } else |
112 | 0 | return 0; |
113 | | |
114 | 0 | if (*pdp) { |
115 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_DISTPOINT_ALREADY_SET); |
116 | 0 | goto err; |
117 | 0 | } |
118 | | |
119 | 0 | *pdp = DIST_POINT_NAME_new(); |
120 | 0 | if (*pdp == NULL) |
121 | 0 | goto err; |
122 | 0 | if (fnm) { |
123 | 0 | (*pdp)->type = 0; |
124 | 0 | (*pdp)->name.fullname = fnm; |
125 | 0 | } else { |
126 | 0 | (*pdp)->type = 1; |
127 | 0 | (*pdp)->name.relativename = rnm; |
128 | 0 | } |
129 | |
|
130 | 0 | return 1; |
131 | | |
132 | 0 | err: |
133 | 0 | sk_GENERAL_NAME_pop_free(fnm, GENERAL_NAME_free); |
134 | 0 | sk_X509_NAME_ENTRY_pop_free(rnm, X509_NAME_ENTRY_free); |
135 | 0 | return -1; |
136 | 0 | } |
137 | | |
138 | | static const BIT_STRING_BITNAME reason_flags[] = { |
139 | | { 0, "Unused", "unused" }, |
140 | | { 1, "Key Compromise", "keyCompromise" }, |
141 | | { 2, "CA Compromise", "CACompromise" }, |
142 | | { 3, "Affiliation Changed", "affiliationChanged" }, |
143 | | { 4, "Superseded", "superseded" }, |
144 | | { 5, "Cessation Of Operation", "cessationOfOperation" }, |
145 | | { 6, "Certificate Hold", "certificateHold" }, |
146 | | { 7, "Privilege Withdrawn", "privilegeWithdrawn" }, |
147 | | { 8, "AA Compromise", "AACompromise" }, |
148 | | { -1, NULL, NULL } |
149 | | }; |
150 | | |
151 | | static int set_reasons(ASN1_BIT_STRING **preas, char *value) |
152 | 0 | { |
153 | 0 | STACK_OF(CONF_VALUE) *rsk = NULL; |
154 | 0 | const BIT_STRING_BITNAME *pbn; |
155 | 0 | const char *bnam; |
156 | 0 | int i, ret = 0; |
157 | 0 | rsk = X509V3_parse_list(value); |
158 | 0 | if (rsk == NULL) |
159 | 0 | return 0; |
160 | 0 | if (*preas != NULL) |
161 | 0 | goto err; |
162 | 0 | for (i = 0; i < sk_CONF_VALUE_num(rsk); i++) { |
163 | 0 | bnam = sk_CONF_VALUE_value(rsk, i)->name; |
164 | 0 | if (*preas == NULL) { |
165 | 0 | *preas = ASN1_BIT_STRING_new(); |
166 | 0 | if (*preas == NULL) |
167 | 0 | goto err; |
168 | 0 | } |
169 | 0 | for (pbn = reason_flags; pbn->lname; pbn++) { |
170 | 0 | if (strcmp(pbn->sname, bnam) == 0) { |
171 | 0 | if (!ASN1_BIT_STRING_set_bit(*preas, pbn->bitnum, 1)) |
172 | 0 | goto err; |
173 | 0 | break; |
174 | 0 | } |
175 | 0 | } |
176 | 0 | if (pbn->lname == NULL) |
177 | 0 | goto err; |
178 | 0 | } |
179 | 0 | ret = 1; |
180 | |
|
181 | 0 | err: |
182 | 0 | sk_CONF_VALUE_pop_free(rsk, X509V3_conf_free); |
183 | 0 | return ret; |
184 | 0 | } |
185 | | |
186 | | static int print_reasons(BIO *out, const char *rname, |
187 | | ASN1_BIT_STRING *rflags, int indent) |
188 | 66.3k | { |
189 | 66.3k | int first = 1; |
190 | 66.3k | const BIT_STRING_BITNAME *pbn; |
191 | 66.3k | BIO_printf(out, "%*s%s:\n%*s", indent, "", rname, indent + 2, ""); |
192 | 663k | for (pbn = reason_flags; pbn->lname; pbn++) { |
193 | 596k | if (ASN1_BIT_STRING_get_bit(rflags, pbn->bitnum)) { |
194 | 262k | if (first) |
195 | 57.4k | first = 0; |
196 | 204k | else |
197 | 204k | BIO_puts(out, ", "); |
198 | 262k | BIO_puts(out, pbn->lname); |
199 | 262k | } |
200 | 596k | } |
201 | 66.3k | if (first) |
202 | 8.90k | BIO_puts(out, "<EMPTY>\n"); |
203 | 57.4k | else |
204 | 57.4k | BIO_puts(out, "\n"); |
205 | 66.3k | return 1; |
206 | 66.3k | } |
207 | | |
208 | | static DIST_POINT *crldp_from_section(X509V3_CTX *ctx, |
209 | | STACK_OF(CONF_VALUE) *nval) |
210 | 0 | { |
211 | 0 | int i; |
212 | 0 | CONF_VALUE *cnf; |
213 | 0 | DIST_POINT *point = DIST_POINT_new(); |
214 | |
|
215 | 0 | if (point == NULL) |
216 | 0 | goto err; |
217 | 0 | for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { |
218 | 0 | int ret; |
219 | 0 | cnf = sk_CONF_VALUE_value(nval, i); |
220 | 0 | ret = set_dist_point_name(&point->distpoint, ctx, cnf); |
221 | 0 | if (ret > 0) |
222 | 0 | continue; |
223 | 0 | if (ret < 0) |
224 | 0 | goto err; |
225 | 0 | if (strcmp(cnf->name, "reasons") == 0) { |
226 | 0 | if (!set_reasons(&point->reasons, cnf->value)) |
227 | 0 | goto err; |
228 | 0 | } else if (strcmp(cnf->name, "CRLissuer") == 0) { |
229 | 0 | point->CRLissuer = gnames_from_sectname(ctx, cnf->value); |
230 | 0 | if (point->CRLissuer == NULL) |
231 | 0 | goto err; |
232 | 0 | } |
233 | 0 | } |
234 | | |
235 | 0 | return point; |
236 | | |
237 | 0 | err: |
238 | 0 | DIST_POINT_free(point); |
239 | 0 | return NULL; |
240 | 0 | } |
241 | | |
242 | | static void *v2i_crld(const X509V3_EXT_METHOD *method, |
243 | | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) |
244 | 0 | { |
245 | 0 | STACK_OF(DIST_POINT) *crld; |
246 | 0 | GENERAL_NAMES *gens = NULL; |
247 | 0 | GENERAL_NAME *gen = NULL; |
248 | 0 | CONF_VALUE *cnf; |
249 | 0 | const int num = sk_CONF_VALUE_num(nval); |
250 | 0 | int i; |
251 | |
|
252 | 0 | crld = sk_DIST_POINT_new_reserve(NULL, num); |
253 | 0 | if (crld == NULL) { |
254 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB); |
255 | 0 | goto err; |
256 | 0 | } |
257 | 0 | for (i = 0; i < num; i++) { |
258 | 0 | DIST_POINT *point; |
259 | |
|
260 | 0 | cnf = sk_CONF_VALUE_value(nval, i); |
261 | 0 | if (cnf->value == NULL) { |
262 | 0 | STACK_OF(CONF_VALUE) *dpsect; |
263 | 0 | dpsect = X509V3_get_section(ctx, cnf->name); |
264 | 0 | if (!dpsect) |
265 | 0 | goto err; |
266 | 0 | point = crldp_from_section(ctx, dpsect); |
267 | 0 | X509V3_section_free(ctx, dpsect); |
268 | 0 | if (point == NULL) |
269 | 0 | goto err; |
270 | 0 | sk_DIST_POINT_push(crld, point); /* no failure as it was reserved */ |
271 | 0 | } else { |
272 | 0 | if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL) |
273 | 0 | goto err; |
274 | 0 | if ((gens = GENERAL_NAMES_new()) == NULL) { |
275 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB); |
276 | 0 | goto err; |
277 | 0 | } |
278 | 0 | if (!sk_GENERAL_NAME_push(gens, gen)) { |
279 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB); |
280 | 0 | goto err; |
281 | 0 | } |
282 | 0 | gen = NULL; |
283 | 0 | if ((point = DIST_POINT_new()) == NULL) { |
284 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB); |
285 | 0 | goto err; |
286 | 0 | } |
287 | 0 | sk_DIST_POINT_push(crld, point); /* no failure as it was reserved */ |
288 | 0 | if ((point->distpoint = DIST_POINT_NAME_new()) == NULL) { |
289 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB); |
290 | 0 | goto err; |
291 | 0 | } |
292 | 0 | point->distpoint->name.fullname = gens; |
293 | 0 | point->distpoint->type = 0; |
294 | 0 | gens = NULL; |
295 | 0 | } |
296 | 0 | } |
297 | 0 | return crld; |
298 | | |
299 | 0 | err: |
300 | 0 | GENERAL_NAME_free(gen); |
301 | 0 | GENERAL_NAMES_free(gens); |
302 | 0 | sk_DIST_POINT_pop_free(crld, DIST_POINT_free); |
303 | 0 | return NULL; |
304 | 0 | } |
305 | | |
306 | | static int dpn_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
307 | | void *exarg) |
308 | 2.02M | { |
309 | 2.02M | DIST_POINT_NAME *dpn = (DIST_POINT_NAME *)*pval; |
310 | | |
311 | 2.02M | switch (operation) { |
312 | 371k | case ASN1_OP_NEW_POST: |
313 | 371k | dpn->dpname = NULL; |
314 | 371k | break; |
315 | | |
316 | 371k | case ASN1_OP_FREE_POST: |
317 | 371k | X509_NAME_free(dpn->dpname); |
318 | 371k | break; |
319 | 2.02M | } |
320 | 2.02M | return 1; |
321 | 2.02M | } |
322 | | |
323 | | ASN1_CHOICE_cb(DIST_POINT_NAME, dpn_cb) = { |
324 | | ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0), |
325 | | ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1) |
326 | 4.02M | } ASN1_CHOICE_END_cb(DIST_POINT_NAME, DIST_POINT_NAME, type) |
327 | | |
328 | | IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME) |
329 | | IMPLEMENT_ASN1_DUP_FUNCTION(DIST_POINT_NAME) |
330 | | |
331 | | ASN1_SEQUENCE(DIST_POINT) = { |
332 | | ASN1_EXP_OPT(DIST_POINT, distpoint, DIST_POINT_NAME, 0), |
333 | | ASN1_IMP_OPT(DIST_POINT, reasons, ASN1_BIT_STRING, 1), |
334 | | ASN1_IMP_SEQUENCE_OF_OPT(DIST_POINT, CRLissuer, GENERAL_NAME, 2) |
335 | 1.24M | } ASN1_SEQUENCE_END(DIST_POINT) |
336 | 1.24M | |
337 | 1.24M | IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT) |
338 | 1.24M | |
339 | 1.24M | ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CRLDistributionPoints, DIST_POINT) |
340 | 2.27M | ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS) |
341 | | |
342 | | IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS) |
343 | | |
344 | | ASN1_SEQUENCE(ISSUING_DIST_POINT) = { |
345 | | ASN1_EXP_OPT(ISSUING_DIST_POINT, distpoint, DIST_POINT_NAME, 0), |
346 | | ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyuser, ASN1_FBOOLEAN, 1), |
347 | | ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyCA, ASN1_FBOOLEAN, 2), |
348 | | ASN1_IMP_OPT(ISSUING_DIST_POINT, onlysomereasons, ASN1_BIT_STRING, 3), |
349 | | ASN1_IMP_OPT(ISSUING_DIST_POINT, indirectCRL, ASN1_FBOOLEAN, 4), |
350 | | ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyattr, ASN1_FBOOLEAN, 5) |
351 | 1.17M | } ASN1_SEQUENCE_END(ISSUING_DIST_POINT) |
352 | 1.17M | |
353 | 1.17M | IMPLEMENT_ASN1_FUNCTIONS(ISSUING_DIST_POINT) |
354 | 1.17M | |
355 | 1.17M | static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out, |
356 | 1.17M | int indent); |
357 | 1.17M | static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
358 | 1.17M | STACK_OF(CONF_VALUE) *nval); |
359 | 1.17M | |
360 | 1.17M | const X509V3_EXT_METHOD ossl_v3_idp = { |
361 | 1.17M | NID_issuing_distribution_point, X509V3_EXT_MULTILINE, |
362 | 1.17M | ASN1_ITEM_ref(ISSUING_DIST_POINT), |
363 | 1.17M | 0, 0, 0, 0, |
364 | 1.17M | 0, 0, |
365 | 1.17M | 0, |
366 | 1.17M | v2i_idp, |
367 | 1.17M | i2r_idp, 0, |
368 | 1.17M | NULL |
369 | 1.17M | }; |
370 | 1.17M | |
371 | 1.17M | static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
372 | 1.17M | STACK_OF(CONF_VALUE) *nval) |
373 | 1.17M | { |
374 | 0 | ISSUING_DIST_POINT *idp = NULL; |
375 | 0 | CONF_VALUE *cnf; |
376 | 0 | char *name, *val; |
377 | 0 | int i, ret; |
378 | 0 | idp = ISSUING_DIST_POINT_new(); |
379 | 0 | if (idp == NULL) { |
380 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB); |
381 | 0 | goto err; |
382 | 0 | } |
383 | 0 | for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { |
384 | 0 | cnf = sk_CONF_VALUE_value(nval, i); |
385 | 0 | name = cnf->name; |
386 | 0 | val = cnf->value; |
387 | 0 | ret = set_dist_point_name(&idp->distpoint, ctx, cnf); |
388 | 0 | if (ret > 0) |
389 | 0 | continue; |
390 | 0 | if (ret < 0) |
391 | 0 | goto err; |
392 | 0 | if (strcmp(name, "onlyuser") == 0) { |
393 | 0 | if (!X509V3_get_value_bool(cnf, &idp->onlyuser)) |
394 | 0 | goto err; |
395 | 0 | } else if (strcmp(name, "onlyCA") == 0) { |
396 | 0 | if (!X509V3_get_value_bool(cnf, &idp->onlyCA)) |
397 | 0 | goto err; |
398 | 0 | } else if (strcmp(name, "onlyAA") == 0) { |
399 | 0 | if (!X509V3_get_value_bool(cnf, &idp->onlyattr)) |
400 | 0 | goto err; |
401 | 0 | } else if (strcmp(name, "indirectCRL") == 0) { |
402 | 0 | if (!X509V3_get_value_bool(cnf, &idp->indirectCRL)) |
403 | 0 | goto err; |
404 | 0 | } else if (strcmp(name, "onlysomereasons") == 0) { |
405 | 0 | if (!set_reasons(&idp->onlysomereasons, val)) |
406 | 0 | goto err; |
407 | 0 | } else { |
408 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NAME); |
409 | 0 | X509V3_conf_add_error_name_value(cnf); |
410 | 0 | goto err; |
411 | 0 | } |
412 | 0 | } |
413 | 0 | return idp; |
414 | | |
415 | 0 | err: |
416 | 0 | ISSUING_DIST_POINT_free(idp); |
417 | 0 | return NULL; |
418 | 0 | } |
419 | | |
420 | | static int print_distpoint(BIO *out, DIST_POINT_NAME *dpn, int indent) |
421 | 91.6k | { |
422 | 91.6k | if (dpn->type == 0) { |
423 | 19.9k | BIO_printf(out, "%*sFull Name:\n", indent, ""); |
424 | 19.9k | OSSL_GENERAL_NAMES_print(out, dpn->name.fullname, indent); |
425 | 19.9k | BIO_puts(out, "\n"); |
426 | 71.7k | } else { |
427 | 71.7k | X509_NAME ntmp; |
428 | 71.7k | ntmp.entries = dpn->name.relativename; |
429 | 71.7k | BIO_printf(out, "%*sRelative Name:\n%*s", indent, "", indent + 2, ""); |
430 | 71.7k | X509_NAME_print_ex(out, &ntmp, 0, XN_FLAG_ONELINE); |
431 | 71.7k | BIO_puts(out, "\n"); |
432 | 71.7k | } |
433 | 91.6k | return 1; |
434 | 91.6k | } |
435 | | |
436 | | static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out, |
437 | | int indent) |
438 | 126k | { |
439 | 126k | ISSUING_DIST_POINT *idp = pidp; |
440 | 126k | if (idp->distpoint) |
441 | 77.3k | print_distpoint(out, idp->distpoint, indent); |
442 | 126k | if (idp->onlyuser > 0) |
443 | 7.41k | BIO_printf(out, "%*sOnly User Certificates\n", indent, ""); |
444 | 126k | if (idp->onlyCA > 0) |
445 | 1.90k | BIO_printf(out, "%*sOnly CA Certificates\n", indent, ""); |
446 | 126k | if (idp->indirectCRL > 0) |
447 | 3.99k | BIO_printf(out, "%*sIndirect CRL\n", indent, ""); |
448 | 126k | if (idp->onlysomereasons) |
449 | 16.2k | print_reasons(out, "Only Some Reasons", idp->onlysomereasons, indent); |
450 | 126k | if (idp->onlyattr > 0) |
451 | 9.61k | BIO_printf(out, "%*sOnly Attribute Certificates\n", indent, ""); |
452 | 126k | if (!idp->distpoint && (idp->onlyuser <= 0) && (idp->onlyCA <= 0) |
453 | 40.1k | && (idp->indirectCRL <= 0) && !idp->onlysomereasons |
454 | 20.0k | && (idp->onlyattr <= 0)) |
455 | 10.4k | BIO_printf(out, "%*s<EMPTY>\n", indent, ""); |
456 | | |
457 | 126k | return 1; |
458 | 126k | } |
459 | | |
460 | | static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out, |
461 | | int indent) |
462 | 110k | { |
463 | 110k | STACK_OF(DIST_POINT) *crld = pcrldp; |
464 | 110k | DIST_POINT *point; |
465 | 110k | int i; |
466 | 298k | for (i = 0; i < sk_DIST_POINT_num(crld); i++) { |
467 | 188k | if (i > 0) |
468 | 101k | BIO_puts(out, "\n"); |
469 | 188k | point = sk_DIST_POINT_value(crld, i); |
470 | 188k | if (point->distpoint) |
471 | 12.5k | print_distpoint(out, point->distpoint, indent); |
472 | 188k | if (point->reasons) |
473 | 49.6k | print_reasons(out, "Reasons", point->reasons, indent); |
474 | 188k | if (point->CRLissuer) { |
475 | 11.0k | BIO_printf(out, "%*sCRL Issuer:\n", indent, ""); |
476 | 11.0k | OSSL_GENERAL_NAMES_print(out, point->CRLissuer, indent); |
477 | 11.0k | } |
478 | 188k | } |
479 | 110k | return 1; |
480 | 110k | } |
481 | | |
482 | | static int i2r_crl_invdate(const X509V3_EXT_METHOD *method, void *date, |
483 | | BIO *out, int indent); |
484 | | static int i2r_object(const X509V3_EXT_METHOD *method, void *obj, BIO *out, |
485 | | int indent); |
486 | | |
487 | | const X509V3_EXT_METHOD ossl_v3_crl_invdate = { |
488 | | NID_invalidity_date, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME), |
489 | | 0, 0, 0, 0, |
490 | | 0, 0, |
491 | | 0, 0, |
492 | | i2r_crl_invdate, 0, |
493 | | NULL |
494 | | }; |
495 | | |
496 | | const X509V3_EXT_METHOD ossl_v3_crl_hold = { |
497 | | NID_hold_instruction_code, 0, ASN1_ITEM_ref(ASN1_OBJECT), |
498 | | 0, 0, 0, 0, |
499 | | 0, 0, |
500 | | 0, 0, |
501 | | i2r_object, 0, |
502 | | NULL |
503 | | }; |
504 | | |
505 | | static int i2r_crl_invdate(const X509V3_EXT_METHOD *method, void *date, |
506 | | BIO *bp, int ind) |
507 | 32.1k | { |
508 | 32.1k | if (BIO_printf(bp, "%*s", ind, "") <= 0) |
509 | 0 | return 0; |
510 | 32.1k | if (!ASN1_GENERALIZEDTIME_print(bp, date)) |
511 | 28.6k | return 0; |
512 | 3.50k | return 1; |
513 | 32.1k | } |
514 | | |
515 | | static int i2r_object(const X509V3_EXT_METHOD *method, void *oid, BIO *bp, |
516 | | int ind) |
517 | 1.72k | { |
518 | 1.72k | if (BIO_printf(bp, "%*s", ind, "") <= 0) |
519 | 0 | return 0; |
520 | 1.72k | if (i2a_ASN1_OBJECT(bp, oid) <= 0) |
521 | 0 | return 0; |
522 | 1.72k | return 1; |
523 | 1.72k | } |
524 | | |
525 | | /* Append any nameRelativeToCRLIssuer in dpn to iname, set in dpn->dpname */ |
526 | | int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, const X509_NAME *iname) |
527 | 26.5k | { |
528 | 26.5k | int i; |
529 | 26.5k | STACK_OF(X509_NAME_ENTRY) *frag; |
530 | 26.5k | X509_NAME_ENTRY *ne; |
531 | | |
532 | 26.5k | if (dpn == NULL || dpn->type != 1) |
533 | 10.7k | return 1; |
534 | 15.7k | frag = dpn->name.relativename; |
535 | 15.7k | X509_NAME_free(dpn->dpname); /* just in case it was already set */ |
536 | 15.7k | dpn->dpname = X509_NAME_dup(iname); |
537 | 15.7k | if (dpn->dpname == NULL) |
538 | 2.29k | return 0; |
539 | 34.2k | for (i = 0; i < sk_X509_NAME_ENTRY_num(frag); i++) { |
540 | 20.8k | ne = sk_X509_NAME_ENTRY_value(frag, i); |
541 | 20.8k | if (!X509_NAME_add_entry(dpn->dpname, ne, -1, i ? 0 : 1)) |
542 | 110 | goto err; |
543 | 20.8k | } |
544 | | /* generate cached encoding of name */ |
545 | 13.3k | if (i2d_X509_NAME(dpn->dpname, NULL) >= 0) |
546 | 11.0k | return 1; |
547 | | |
548 | 2.46k | err: |
549 | 2.46k | X509_NAME_free(dpn->dpname); |
550 | | dpn->dpname = NULL; |
551 | 2.46k | return 0; |
552 | 13.3k | } |