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