Coverage Report

Created: 2026-10-28 06:28

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