/src/openssl30/crypto/x509/v3_cpols.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 1999-2021 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 "x509_local.h" |
18 | | #include "pcy_local.h" |
19 | | #include "ext_dat.h" |
20 | | |
21 | | /* Certificate policies extension support: this one is a bit complex... */ |
22 | | |
23 | | static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, |
24 | | BIO *out, int indent); |
25 | | static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, |
26 | | X509V3_CTX *ctx, const char *value); |
27 | | static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, |
28 | | int indent); |
29 | | static void print_notice(BIO *out, USERNOTICE *notice, int indent); |
30 | | static POLICYINFO *policy_section(X509V3_CTX *ctx, |
31 | | STACK_OF(CONF_VALUE) *polstrs, int ia5org); |
32 | | static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, |
33 | | STACK_OF(CONF_VALUE) *unot, int ia5org); |
34 | | static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos); |
35 | | static int displaytext_str2tag(const char *tagstr, unsigned int *tag_len); |
36 | | static int displaytext_get_tag_len(const char *tagstr); |
37 | | |
38 | | const X509V3_EXT_METHOD ossl_v3_cpols = { |
39 | | NID_certificate_policies, 0, ASN1_ITEM_ref(CERTIFICATEPOLICIES), |
40 | | 0, 0, 0, 0, |
41 | | 0, 0, |
42 | | 0, 0, |
43 | | (X509V3_EXT_I2R)i2r_certpol, |
44 | | (X509V3_EXT_R2I)r2i_certpol, |
45 | | NULL |
46 | | }; |
47 | | |
48 | | ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CERTIFICATEPOLICIES, POLICYINFO) |
49 | 245k | ASN1_ITEM_TEMPLATE_END(CERTIFICATEPOLICIES) |
50 | | |
51 | | IMPLEMENT_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) |
52 | | |
53 | | ASN1_SEQUENCE(POLICYINFO) = { |
54 | | ASN1_SIMPLE(POLICYINFO, policyid, ASN1_OBJECT), |
55 | | ASN1_SEQUENCE_OF_OPT(POLICYINFO, qualifiers, POLICYQUALINFO) |
56 | 665k | } ASN1_SEQUENCE_END(POLICYINFO) |
57 | 665k | |
58 | 665k | IMPLEMENT_ASN1_FUNCTIONS(POLICYINFO) |
59 | 665k | |
60 | 665k | ASN1_ADB_TEMPLATE(policydefault) = ASN1_SIMPLE(POLICYQUALINFO, d.other, ASN1_ANY); |
61 | 665k | |
62 | 665k | ASN1_ADB(POLICYQUALINFO) = { |
63 | 665k | ADB_ENTRY(NID_id_qt_cps, ASN1_SIMPLE(POLICYQUALINFO, d.cpsuri, ASN1_IA5STRING)), |
64 | 665k | ADB_ENTRY(NID_id_qt_unotice, ASN1_SIMPLE(POLICYQUALINFO, d.usernotice, USERNOTICE)) |
65 | 768k | } ASN1_ADB_END(POLICYQUALINFO, 0, pqualid, 0, &policydefault_tt, NULL); |
66 | | |
67 | | ASN1_SEQUENCE(POLICYQUALINFO) = { |
68 | | ASN1_SIMPLE(POLICYQUALINFO, pqualid, ASN1_OBJECT), |
69 | | ASN1_ADB_OBJECT(POLICYQUALINFO) |
70 | 621k | } ASN1_SEQUENCE_END(POLICYQUALINFO) |
71 | 621k | |
72 | 621k | IMPLEMENT_ASN1_FUNCTIONS(POLICYQUALINFO) |
73 | 621k | |
74 | 621k | ASN1_SEQUENCE(USERNOTICE) = { |
75 | 621k | ASN1_OPT(USERNOTICE, noticeref, NOTICEREF), |
76 | 621k | ASN1_OPT(USERNOTICE, exptext, DISPLAYTEXT) |
77 | 621k | } ASN1_SEQUENCE_END(USERNOTICE) |
78 | 137k | |
79 | 137k | IMPLEMENT_ASN1_FUNCTIONS(USERNOTICE) |
80 | 137k | |
81 | 137k | ASN1_SEQUENCE(NOTICEREF) = { |
82 | 137k | ASN1_SIMPLE(NOTICEREF, organization, DISPLAYTEXT), |
83 | 137k | ASN1_SEQUENCE_OF(NOTICEREF, noticenos, ASN1_INTEGER) |
84 | 477k | } ASN1_SEQUENCE_END(NOTICEREF) |
85 | 477k | |
86 | 477k | IMPLEMENT_ASN1_FUNCTIONS(NOTICEREF) |
87 | 477k | |
88 | 477k | static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, |
89 | 477k | X509V3_CTX *ctx, const char *value) |
90 | 477k | { |
91 | 0 | STACK_OF(POLICYINFO) *pols; |
92 | 0 | char *pstr; |
93 | 0 | POLICYINFO *pol; |
94 | 0 | ASN1_OBJECT *pobj; |
95 | 0 | STACK_OF(CONF_VALUE) *vals = X509V3_parse_list(value); |
96 | 0 | CONF_VALUE *cnf; |
97 | 0 | const int num = sk_CONF_VALUE_num(vals); |
98 | 0 | int i, ia5org; |
99 | |
|
100 | 0 | if (vals == NULL) { |
101 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_X509V3_LIB); |
102 | 0 | return NULL; |
103 | 0 | } |
104 | | |
105 | 0 | pols = sk_POLICYINFO_new_reserve(NULL, num); |
106 | 0 | if (pols == NULL) { |
107 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); |
108 | 0 | goto err; |
109 | 0 | } |
110 | | |
111 | 0 | ia5org = 0; |
112 | 0 | for (i = 0; i < num; i++) { |
113 | 0 | cnf = sk_CONF_VALUE_value(vals, i); |
114 | 0 | if (cnf->value != NULL || cnf->name == NULL) { |
115 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_POLICY_IDENTIFIER); |
116 | 0 | X509V3_conf_add_error_name_value(cnf); |
117 | 0 | goto err; |
118 | 0 | } |
119 | 0 | pstr = cnf->name; |
120 | 0 | if (strcmp(pstr, "ia5org") == 0) { |
121 | 0 | ia5org = 1; |
122 | 0 | continue; |
123 | 0 | } else if (*pstr == '@') { |
124 | 0 | STACK_OF(CONF_VALUE) *polsect; |
125 | |
|
126 | 0 | polsect = X509V3_get_section(ctx, pstr + 1); |
127 | 0 | if (polsect == NULL) { |
128 | 0 | ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION, |
129 | 0 | "%s", cnf->name); |
130 | 0 | goto err; |
131 | 0 | } |
132 | 0 | pol = policy_section(ctx, polsect, ia5org); |
133 | 0 | X509V3_section_free(ctx, polsect); |
134 | 0 | if (pol == NULL) |
135 | 0 | goto err; |
136 | 0 | } else { |
137 | 0 | if ((pobj = OBJ_txt2obj(cnf->name, 0)) == NULL) { |
138 | 0 | ERR_raise_data(ERR_LIB_X509V3, |
139 | 0 | X509V3_R_INVALID_OBJECT_IDENTIFIER, |
140 | 0 | "%s", cnf->name); |
141 | 0 | goto err; |
142 | 0 | } |
143 | 0 | pol = POLICYINFO_new(); |
144 | 0 | if (pol == NULL) { |
145 | 0 | ASN1_OBJECT_free(pobj); |
146 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); |
147 | 0 | goto err; |
148 | 0 | } |
149 | 0 | pol->policyid = pobj; |
150 | 0 | } |
151 | 0 | if (!sk_POLICYINFO_push(pols, pol)) { |
152 | 0 | POLICYINFO_free(pol); |
153 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); |
154 | 0 | goto err; |
155 | 0 | } |
156 | 0 | } |
157 | 0 | sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); |
158 | 0 | return pols; |
159 | 0 | err: |
160 | 0 | sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); |
161 | 0 | sk_POLICYINFO_pop_free(pols, POLICYINFO_free); |
162 | 0 | return NULL; |
163 | 0 | } |
164 | | |
165 | | static POLICYINFO *policy_section(X509V3_CTX *ctx, |
166 | | STACK_OF(CONF_VALUE) *polstrs, int ia5org) |
167 | 0 | { |
168 | 0 | int i; |
169 | 0 | CONF_VALUE *cnf; |
170 | 0 | POLICYINFO *pol; |
171 | 0 | POLICYQUALINFO *qual; |
172 | |
|
173 | 0 | if ((pol = POLICYINFO_new()) == NULL) |
174 | 0 | goto merr; |
175 | 0 | for (i = 0; i < sk_CONF_VALUE_num(polstrs); i++) { |
176 | 0 | cnf = sk_CONF_VALUE_value(polstrs, i); |
177 | 0 | if (strcmp(cnf->name, "policyIdentifier") == 0) { |
178 | 0 | ASN1_OBJECT *pobj; |
179 | |
|
180 | 0 | if ((pobj = OBJ_txt2obj(cnf->value, 0)) == NULL) { |
181 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER); |
182 | 0 | X509V3_conf_err(cnf); |
183 | 0 | goto err; |
184 | 0 | } |
185 | 0 | pol->policyid = pobj; |
186 | |
|
187 | 0 | } else if (!ossl_v3_name_cmp(cnf->name, "CPS")) { |
188 | 0 | if (pol->qualifiers == NULL) |
189 | 0 | pol->qualifiers = sk_POLICYQUALINFO_new_null(); |
190 | 0 | if ((qual = POLICYQUALINFO_new()) == NULL) |
191 | 0 | goto merr; |
192 | 0 | if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) |
193 | 0 | goto merr; |
194 | 0 | if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_cps)) == NULL) { |
195 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_INTERNAL_ERROR); |
196 | 0 | goto err; |
197 | 0 | } |
198 | 0 | if ((qual->d.cpsuri = ASN1_IA5STRING_new()) == NULL) |
199 | 0 | goto merr; |
200 | 0 | if (!ASN1_STRING_set(qual->d.cpsuri, cnf->value, |
201 | 0 | strlen(cnf->value))) |
202 | 0 | goto merr; |
203 | 0 | } else if (!ossl_v3_name_cmp(cnf->name, "userNotice")) { |
204 | 0 | STACK_OF(CONF_VALUE) *unot; |
205 | 0 | if (*cnf->value != '@') { |
206 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_EXPECTED_A_SECTION_NAME); |
207 | 0 | X509V3_conf_err(cnf); |
208 | 0 | goto err; |
209 | 0 | } |
210 | 0 | unot = X509V3_get_section(ctx, cnf->value + 1); |
211 | 0 | if (!unot) { |
212 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION); |
213 | |
|
214 | 0 | X509V3_conf_err(cnf); |
215 | 0 | goto err; |
216 | 0 | } |
217 | 0 | qual = notice_section(ctx, unot, ia5org); |
218 | 0 | X509V3_section_free(ctx, unot); |
219 | 0 | if (!qual) |
220 | 0 | goto err; |
221 | 0 | if (pol->qualifiers == NULL) |
222 | 0 | pol->qualifiers = sk_POLICYQUALINFO_new_null(); |
223 | 0 | if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) |
224 | 0 | goto merr; |
225 | 0 | } else { |
226 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OPTION); |
227 | 0 | X509V3_conf_err(cnf); |
228 | 0 | goto err; |
229 | 0 | } |
230 | 0 | } |
231 | 0 | if (pol->policyid == NULL) { |
232 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_NO_POLICY_IDENTIFIER); |
233 | 0 | goto err; |
234 | 0 | } |
235 | | |
236 | 0 | return pol; |
237 | | |
238 | 0 | merr: |
239 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); |
240 | |
|
241 | 0 | err: |
242 | 0 | POLICYINFO_free(pol); |
243 | 0 | return NULL; |
244 | 0 | } |
245 | | |
246 | | static int displaytext_get_tag_len(const char *tagstr) |
247 | 0 | { |
248 | 0 | char *colon = strchr(tagstr, ':'); |
249 | |
|
250 | 0 | return (colon == NULL) ? -1 : colon - tagstr; |
251 | 0 | } |
252 | | |
253 | | static int displaytext_str2tag(const char *tagstr, unsigned int *tag_len) |
254 | 0 | { |
255 | 0 | int len; |
256 | |
|
257 | 0 | *tag_len = 0; |
258 | 0 | len = displaytext_get_tag_len(tagstr); |
259 | |
|
260 | 0 | if (len == -1) |
261 | 0 | return V_ASN1_VISIBLESTRING; |
262 | 0 | *tag_len = len; |
263 | 0 | if (len == sizeof("UTF8") - 1 && strncmp(tagstr, "UTF8", len) == 0) |
264 | 0 | return V_ASN1_UTF8STRING; |
265 | 0 | if (len == sizeof("UTF8String") - 1 && strncmp(tagstr, "UTF8String", len) == 0) |
266 | 0 | return V_ASN1_UTF8STRING; |
267 | 0 | if (len == sizeof("BMP") - 1 && strncmp(tagstr, "BMP", len) == 0) |
268 | 0 | return V_ASN1_BMPSTRING; |
269 | 0 | if (len == sizeof("BMPSTRING") - 1 && strncmp(tagstr, "BMPSTRING", len) == 0) |
270 | 0 | return V_ASN1_BMPSTRING; |
271 | 0 | if (len == sizeof("VISIBLE") - 1 && strncmp(tagstr, "VISIBLE", len) == 0) |
272 | 0 | return V_ASN1_VISIBLESTRING; |
273 | 0 | if (len == sizeof("VISIBLESTRING") - 1 && strncmp(tagstr, "VISIBLESTRING", len) == 0) |
274 | 0 | return V_ASN1_VISIBLESTRING; |
275 | 0 | *tag_len = 0; |
276 | 0 | return V_ASN1_VISIBLESTRING; |
277 | 0 | } |
278 | | |
279 | | static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, |
280 | | STACK_OF(CONF_VALUE) *unot, int ia5org) |
281 | 0 | { |
282 | 0 | int i, ret, len, tag; |
283 | 0 | unsigned int tag_len; |
284 | 0 | CONF_VALUE *cnf; |
285 | 0 | USERNOTICE *not; |
286 | 0 | POLICYQUALINFO *qual; |
287 | 0 | char *value = NULL; |
288 | |
|
289 | 0 | if ((qual = POLICYQUALINFO_new()) == NULL) |
290 | 0 | goto merr; |
291 | 0 | if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice)) == NULL) { |
292 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_INTERNAL_ERROR); |
293 | 0 | goto err; |
294 | 0 | } |
295 | 0 | if ((not = USERNOTICE_new()) == NULL) |
296 | 0 | goto merr; |
297 | 0 | qual->d.usernotice = not; |
298 | 0 | for (i = 0; i < sk_CONF_VALUE_num(unot); i++) { |
299 | 0 | cnf = sk_CONF_VALUE_value(unot, i); |
300 | |
|
301 | 0 | value = cnf->value; |
302 | 0 | if (strcmp(cnf->name, "explicitText") == 0) { |
303 | 0 | tag = displaytext_str2tag(value, &tag_len); |
304 | 0 | if ((not->exptext = ASN1_STRING_type_new(tag)) == NULL) |
305 | 0 | goto merr; |
306 | 0 | if (tag_len != 0) |
307 | 0 | value += tag_len + 1; |
308 | 0 | len = strlen(value); |
309 | 0 | if (!ASN1_STRING_set(not->exptext, value, len)) |
310 | 0 | goto merr; |
311 | 0 | } else if (strcmp(cnf->name, "organization") == 0) { |
312 | 0 | NOTICEREF *nref; |
313 | |
|
314 | 0 | if (!not->noticeref) { |
315 | 0 | if ((nref = NOTICEREF_new()) == NULL) |
316 | 0 | goto merr; |
317 | 0 | not->noticeref = nref; |
318 | 0 | } else |
319 | 0 | nref = not->noticeref; |
320 | 0 | if (ia5org) |
321 | 0 | nref->organization->type = V_ASN1_IA5STRING; |
322 | 0 | else |
323 | 0 | nref->organization->type = V_ASN1_VISIBLESTRING; |
324 | 0 | if (!ASN1_STRING_set(nref->organization, cnf->value, |
325 | 0 | strlen(cnf->value))) |
326 | 0 | goto merr; |
327 | 0 | } else if (strcmp(cnf->name, "noticeNumbers") == 0) { |
328 | 0 | NOTICEREF *nref; |
329 | |
|
330 | 0 | STACK_OF(CONF_VALUE) *nos; |
331 | 0 | if (!not->noticeref) { |
332 | 0 | if ((nref = NOTICEREF_new()) == NULL) |
333 | 0 | goto merr; |
334 | 0 | not->noticeref = nref; |
335 | 0 | } else |
336 | 0 | nref = not->noticeref; |
337 | 0 | nos = X509V3_parse_list(cnf->value); |
338 | 0 | if (!nos || !sk_CONF_VALUE_num(nos)) { |
339 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NUMBERS); |
340 | 0 | X509V3_conf_add_error_name_value(cnf); |
341 | 0 | sk_CONF_VALUE_pop_free(nos, X509V3_conf_free); |
342 | 0 | goto err; |
343 | 0 | } |
344 | 0 | ret = nref_nos(nref->noticenos, nos); |
345 | 0 | sk_CONF_VALUE_pop_free(nos, X509V3_conf_free); |
346 | 0 | if (!ret) |
347 | 0 | goto err; |
348 | 0 | } else { |
349 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OPTION); |
350 | 0 | X509V3_conf_add_error_name_value(cnf); |
351 | 0 | goto err; |
352 | 0 | } |
353 | 0 | } |
354 | | |
355 | 0 | if (not->noticeref && (!not->noticeref->noticenos || !not->noticeref->organization)) { |
356 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_NEED_ORGANIZATION_AND_NUMBERS); |
357 | 0 | goto err; |
358 | 0 | } |
359 | | |
360 | 0 | return qual; |
361 | | |
362 | 0 | merr: |
363 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); |
364 | |
|
365 | 0 | err: |
366 | 0 | POLICYQUALINFO_free(qual); |
367 | 0 | return NULL; |
368 | 0 | } |
369 | | |
370 | | static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos) |
371 | 0 | { |
372 | 0 | CONF_VALUE *cnf; |
373 | 0 | ASN1_INTEGER *aint; |
374 | |
|
375 | 0 | int i; |
376 | |
|
377 | 0 | for (i = 0; i < sk_CONF_VALUE_num(nos); i++) { |
378 | 0 | cnf = sk_CONF_VALUE_value(nos, i); |
379 | 0 | if ((aint = s2i_ASN1_INTEGER(NULL, cnf->name)) == NULL) { |
380 | 0 | ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NUMBER); |
381 | 0 | goto err; |
382 | 0 | } |
383 | 0 | if (!sk_ASN1_INTEGER_push(nnums, aint)) |
384 | 0 | goto merr; |
385 | 0 | } |
386 | 0 | return 1; |
387 | | |
388 | 0 | merr: |
389 | 0 | ASN1_INTEGER_free(aint); |
390 | 0 | ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); |
391 | |
|
392 | 0 | err: |
393 | 0 | return 0; |
394 | 0 | } |
395 | | |
396 | | static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, |
397 | | BIO *out, int indent) |
398 | 27.5k | { |
399 | 27.5k | int i; |
400 | 27.5k | POLICYINFO *pinfo; |
401 | | /* First print out the policy OIDs */ |
402 | 58.4k | for (i = 0; i < sk_POLICYINFO_num(pol); i++) { |
403 | 30.9k | if (i > 0) |
404 | 7.43k | BIO_puts(out, "\n"); |
405 | 30.9k | pinfo = sk_POLICYINFO_value(pol, i); |
406 | 30.9k | BIO_printf(out, "%*sPolicy: ", indent, ""); |
407 | 30.9k | i2a_ASN1_OBJECT(out, pinfo->policyid); |
408 | 30.9k | if (pinfo->qualifiers) { |
409 | 22.3k | BIO_puts(out, "\n"); |
410 | 22.3k | print_qualifiers(out, pinfo->qualifiers, indent + 2); |
411 | 22.3k | } |
412 | 30.9k | } |
413 | 27.5k | return 1; |
414 | 27.5k | } |
415 | | |
416 | | static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, |
417 | | int indent) |
418 | 22.3k | { |
419 | 22.3k | POLICYQUALINFO *qualinfo; |
420 | 22.3k | int i; |
421 | 60.6k | for (i = 0; i < sk_POLICYQUALINFO_num(quals); i++) { |
422 | 38.2k | if (i > 0) |
423 | 19.8k | BIO_puts(out, "\n"); |
424 | 38.2k | qualinfo = sk_POLICYQUALINFO_value(quals, i); |
425 | 38.2k | switch (OBJ_obj2nid(qualinfo->pqualid)) { |
426 | 4.78k | case NID_id_qt_cps: |
427 | 4.78k | BIO_printf(out, "%*sCPS: %.*s", indent, "", |
428 | 4.78k | qualinfo->d.cpsuri->length, |
429 | 4.78k | qualinfo->d.cpsuri->data); |
430 | 4.78k | break; |
431 | | |
432 | 8.18k | case NID_id_qt_unotice: |
433 | 8.18k | BIO_printf(out, "%*sUser Notice:\n", indent, ""); |
434 | 8.18k | print_notice(out, qualinfo->d.usernotice, indent + 2); |
435 | 8.18k | break; |
436 | | |
437 | 25.2k | default: |
438 | 25.2k | BIO_printf(out, "%*sUnknown Qualifier: ", indent + 2, ""); |
439 | | |
440 | 25.2k | i2a_ASN1_OBJECT(out, qualinfo->pqualid); |
441 | 25.2k | break; |
442 | 38.2k | } |
443 | 38.2k | } |
444 | 22.3k | } |
445 | | |
446 | | static void print_notice(BIO *out, USERNOTICE *notice, int indent) |
447 | 8.18k | { |
448 | 8.18k | int i; |
449 | 8.18k | if (notice->noticeref) { |
450 | 2.87k | NOTICEREF *ref; |
451 | 2.87k | ref = notice->noticeref; |
452 | 2.87k | BIO_printf(out, "%*sOrganization: %.*s\n", indent, "", |
453 | 2.87k | ref->organization->length, |
454 | 2.87k | ref->organization->data); |
455 | 2.87k | BIO_printf(out, "%*sNumber%s: ", indent, "", |
456 | 2.87k | sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); |
457 | 7.98k | for (i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) { |
458 | 5.11k | ASN1_INTEGER *num; |
459 | 5.11k | char *tmp; |
460 | 5.11k | num = sk_ASN1_INTEGER_value(ref->noticenos, i); |
461 | 5.11k | if (i) |
462 | 4.12k | BIO_puts(out, ", "); |
463 | 5.11k | if (num == NULL) |
464 | 0 | BIO_puts(out, "(null)"); |
465 | 5.11k | else { |
466 | 5.11k | tmp = i2s_ASN1_INTEGER(NULL, num); |
467 | 5.11k | if (tmp == NULL) |
468 | 0 | return; |
469 | 5.11k | BIO_puts(out, tmp); |
470 | 5.11k | OPENSSL_free(tmp); |
471 | 5.11k | } |
472 | 5.11k | } |
473 | 2.87k | if (notice->exptext) |
474 | 815 | BIO_puts(out, "\n"); |
475 | 2.87k | } |
476 | 8.18k | if (notice->exptext) |
477 | 5.80k | BIO_printf(out, "%*sExplicit Text: %.*s", indent, "", |
478 | 5.80k | notice->exptext->length, |
479 | 5.80k | notice->exptext->data); |
480 | 8.18k | } |
481 | | |
482 | | void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) |
483 | 0 | { |
484 | 0 | const X509_POLICY_DATA *dat = node->data; |
485 | |
|
486 | 0 | BIO_printf(out, "%*sPolicy: ", indent, ""); |
487 | |
|
488 | 0 | i2a_ASN1_OBJECT(out, dat->valid_policy); |
489 | 0 | BIO_puts(out, "\n"); |
490 | 0 | BIO_printf(out, "%*s%s\n", indent + 2, "", |
491 | 0 | node_data_critical(dat) ? "Critical" : "Non Critical"); |
492 | 0 | if (dat->qualifier_set) { |
493 | 0 | print_qualifiers(out, dat->qualifier_set, indent + 2); |
494 | 0 | BIO_puts(out, "\n"); |
495 | 0 | } else |
496 | 0 | BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); |
497 | 0 | } |