Coverage Report

Created: 2026-10-28 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl40/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
{
170
    int i;
171
    CONF_VALUE *cnf;
172
    POLICYINFO *pol;
173
    POLICYQUALINFO *qual;
174
175
    if ((pol = POLICYINFO_new()) == NULL) {
176
        ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
177
        goto err;
178
    }
179
    for (i = 0; i < sk_CONF_VALUE_num(polstrs); i++) {
180
        cnf = sk_CONF_VALUE_value(polstrs, i);
181
        if (strcmp(cnf->name, "policyIdentifier") == 0) {
182
            ASN1_OBJECT *pobj;
183
184
            if ((pobj = OBJ_txt2obj(cnf->value, 0)) == NULL) {
185
                ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER);
186
                X509V3_conf_err(cnf);
187
                goto err;
188
            }
189
            pol->policyid = pobj;
190
191
        } else if (!ossl_v3_name_cmp(cnf->name, "CPS")) {
192
            if (pol->qualifiers == NULL)
193
                pol->qualifiers = sk_POLICYQUALINFO_new_null();
194
            if ((qual = POLICYQUALINFO_new()) == NULL) {
195
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
196
                goto err;
197
            }
198
            if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) {
199
                POLICYQUALINFO_free(qual);
200
                ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
201
                goto err;
202
            }
203
            if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_cps)) == NULL) {
204
                ERR_raise(ERR_LIB_X509V3, ERR_R_INTERNAL_ERROR);
205
                goto err;
206
            }
207
            if ((qual->d.cpsuri = ASN1_IA5STRING_new()) == NULL) {
208
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
209
                goto err;
210
            }
211
            if (!ASN1_STRING_set(qual->d.cpsuri, cnf->value,
212
                    (int)strlen(cnf->value))) {
213
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
214
                goto err;
215
            }
216
        } else if (!ossl_v3_name_cmp(cnf->name, "userNotice")) {
217
            STACK_OF(CONF_VALUE) *unot;
218
            if (*cnf->value != '@') {
219
                ERR_raise(ERR_LIB_X509V3, X509V3_R_EXPECTED_A_SECTION_NAME);
220
                X509V3_conf_err(cnf);
221
                goto err;
222
            }
223
            unot = X509V3_get_section(ctx, cnf->value + 1);
224
            if (!unot) {
225
                ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION);
226
227
                X509V3_conf_err(cnf);
228
                goto err;
229
            }
230
            qual = notice_section(ctx, unot, ia5org);
231
            X509V3_section_free(ctx, unot);
232
            if (!qual)
233
                goto err;
234
            if (pol->qualifiers == NULL)
235
                pol->qualifiers = sk_POLICYQUALINFO_new_null();
236
            if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) {
237
                POLICYQUALINFO_free(qual);
238
                ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
239
                goto err;
240
            }
241
        } else {
242
            ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OPTION);
243
            X509V3_conf_err(cnf);
244
            goto err;
245
        }
246
    }
247
    if (pol->policyid == NULL) {
248
        ERR_raise(ERR_LIB_X509V3, X509V3_R_NO_POLICY_IDENTIFIER);
249
        goto err;
250
    }
251
252
    return pol;
253
254
err:
255
    POLICYINFO_free(pol);
256
    return NULL;
257
}
258
259
static int displaytext_get_tag_len(const char *tagstr)
260
1.12k
{
261
1.12k
    const char *colon = strchr(tagstr, ':');
262
263
1.12k
    return (colon == NULL) ? -1 : (int)(colon - tagstr);
264
1.12k
}
265
266
static int displaytext_str2tag(const char *tagstr, unsigned int *tag_len)
267
1.12k
{
268
1.12k
    int len;
269
270
1.12k
    *tag_len = 0;
271
1.12k
    len = displaytext_get_tag_len(tagstr);
272
273
1.12k
    if (len == -1)
274
91
        return V_ASN1_VISIBLESTRING;
275
1.03k
    *tag_len = len;
276
1.03k
    if (len == sizeof("UTF8") - 1 && HAS_PREFIX(tagstr, "UTF8"))
277
66
        return V_ASN1_UTF8STRING;
278
964
    if (len == sizeof("UTF8String") - 1 && HAS_PREFIX(tagstr, "UTF8String"))
279
34
        return V_ASN1_UTF8STRING;
280
930
    if (len == sizeof("BMP") - 1 && HAS_PREFIX(tagstr, "BMP"))
281
66
        return V_ASN1_BMPSTRING;
282
864
    if (len == sizeof("BMPSTRING") - 1 && HAS_PREFIX(tagstr, "BMPSTRING"))
283
66
        return V_ASN1_BMPSTRING;
284
798
    if (len == sizeof("VISIBLE") - 1 && HAS_PREFIX(tagstr, "VISIBLE"))
285
66
        return V_ASN1_VISIBLESTRING;
286
732
    if (len == sizeof("VISIBLESTRING") - 1 && HAS_PREFIX(tagstr, "VISIBLESTRING"))
287
66
        return V_ASN1_VISIBLESTRING;
288
666
    *tag_len = 0;
289
666
    return V_ASN1_VISIBLESTRING;
290
732
}
291
292
static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
293
    STACK_OF(CONF_VALUE) *unot, int ia5org)
294
0
{
295
0
    int i, ret, len, tag;
296
0
    unsigned int tag_len;
297
0
    CONF_VALUE *cnf;
298
0
    USERNOTICE *not;
299
0
    POLICYQUALINFO *qual;
300
0
    char *value = NULL;
301
302
0
    if ((qual = POLICYQUALINFO_new()) == NULL) {
303
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
304
0
        goto err;
305
0
    }
306
0
    if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice)) == NULL) {
307
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_INTERNAL_ERROR);
308
0
        goto err;
309
0
    }
310
0
    if ((not = USERNOTICE_new()) == NULL) {
311
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
312
0
        goto err;
313
0
    }
314
0
    qual->d.usernotice = not;
315
0
    for (i = 0; i < sk_CONF_VALUE_num(unot); i++) {
316
0
        cnf = sk_CONF_VALUE_value(unot, i);
317
318
0
        value = cnf->value;
319
0
        if (strcmp(cnf->name, "explicitText") == 0) {
320
0
            tag = displaytext_str2tag(value, &tag_len);
321
0
            if ((not->exptext = ASN1_STRING_type_new(tag)) == NULL) {
322
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
323
0
                goto err;
324
0
            }
325
0
            if (tag_len != 0)
326
0
                value += tag_len + 1;
327
0
            len = (int)strlen(value);
328
0
            if (!ASN1_STRING_set(not->exptext, value, len)) {
329
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
330
0
                goto err;
331
0
            }
332
0
        } else if (strcmp(cnf->name, "organization") == 0) {
333
0
            NOTICEREF *nref;
334
335
0
            if (!not->noticeref) {
336
0
                if ((nref = NOTICEREF_new()) == NULL) {
337
0
                    ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
338
0
                    goto err;
339
0
                }
340
0
                not->noticeref = nref;
341
0
            } else
342
0
                nref = not->noticeref;
343
0
            if (ia5org)
344
0
                nref->organization->type = V_ASN1_IA5STRING;
345
0
            else
346
0
                nref->organization->type = V_ASN1_VISIBLESTRING;
347
0
            if (!ASN1_STRING_set(nref->organization, cnf->value,
348
0
                    (int)strlen(cnf->value))) {
349
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
350
0
                goto err;
351
0
            }
352
0
        } else if (strcmp(cnf->name, "noticeNumbers") == 0) {
353
0
            NOTICEREF *nref;
354
355
0
            STACK_OF(CONF_VALUE) *nos;
356
0
            if (!not->noticeref) {
357
0
                if ((nref = NOTICEREF_new()) == NULL) {
358
0
                    ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
359
0
                    goto err;
360
0
                }
361
0
                not->noticeref = nref;
362
0
            } else
363
0
                nref = not->noticeref;
364
0
            nos = X509V3_parse_list(cnf->value);
365
0
            if (!nos || !sk_CONF_VALUE_num(nos)) {
366
0
                ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NUMBERS);
367
0
                X509V3_conf_add_error_name_value(cnf);
368
0
                sk_CONF_VALUE_pop_free(nos, X509V3_conf_free);
369
0
                goto err;
370
0
            }
371
0
            ret = nref_nos(nref->noticenos, nos);
372
0
            sk_CONF_VALUE_pop_free(nos, X509V3_conf_free);
373
0
            if (!ret)
374
0
                goto err;
375
0
        } else {
376
0
            ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OPTION);
377
0
            X509V3_conf_add_error_name_value(cnf);
378
0
            goto err;
379
0
        }
380
0
    }
381
382
0
    if (not->noticeref && (!not->noticeref->noticenos || !not->noticeref->organization)) {
383
0
        ERR_raise(ERR_LIB_X509V3, X509V3_R_NEED_ORGANIZATION_AND_NUMBERS);
384
0
        goto err;
385
0
    }
386
387
0
    return qual;
388
389
0
err:
390
0
    POLICYQUALINFO_free(qual);
391
0
    return NULL;
392
0
}
393
394
static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos)
395
404
{
396
404
    CONF_VALUE *cnf;
397
404
    ASN1_INTEGER *aint;
398
399
404
    int i;
400
401
2.87k
    for (i = 0; i < sk_CONF_VALUE_num(nos); i++) {
402
2.49k
        cnf = sk_CONF_VALUE_value(nos, i);
403
2.49k
        if ((aint = s2i_ASN1_INTEGER(NULL, cnf->name)) == NULL) {
404
27
            ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NUMBER);
405
27
            return 0;
406
27
        }
407
2.47k
        if (!sk_ASN1_INTEGER_push(nnums, aint)) {
408
0
            ASN1_INTEGER_free(aint);
409
0
            ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
410
0
            return 0;
411
0
        }
412
2.47k
    }
413
377
    return 1;
414
404
}
415
416
static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol,
417
    BIO *out, int indent)
418
28.2k
{
419
28.2k
    int i;
420
28.2k
    POLICYINFO *pinfo;
421
    /* First print out the policy OIDs */
422
57.0k
    for (i = 0; i < sk_POLICYINFO_num(pol); i++) {
423
28.7k
        if (i > 0)
424
7.94k
            BIO_puts(out, "\n");
425
28.7k
        pinfo = sk_POLICYINFO_value(pol, i);
426
28.7k
        BIO_printf(out, "%*sPolicy: ", indent, "");
427
28.7k
        i2a_ASN1_OBJECT(out, pinfo->policyid);
428
28.7k
        if (pinfo->qualifiers) {
429
19.3k
            BIO_puts(out, "\n");
430
19.3k
            print_qualifiers(out, pinfo->qualifiers, indent + 2);
431
19.3k
        }
432
28.7k
    }
433
28.2k
    return 1;
434
28.2k
}
435
436
static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals,
437
    int indent)
438
13.5k
{
439
13.5k
    POLICYQUALINFO *qualinfo;
440
13.5k
    int i;
441
35.0k
    for (i = 0; i < sk_POLICYQUALINFO_num(quals); i++) {
442
21.5k
        if (i > 0)
443
10.8k
            BIO_puts(out, "\n");
444
21.5k
        qualinfo = sk_POLICYQUALINFO_value(quals, i);
445
21.5k
        switch (OBJ_obj2nid(qualinfo->pqualid)) {
446
1.78k
        case NID_id_qt_cps:
447
1.78k
            BIO_printf(out, "%*sCPS: %.*s", indent, "",
448
1.78k
                qualinfo->d.cpsuri->length,
449
1.78k
                qualinfo->d.cpsuri->data);
450
1.78k
            break;
451
452
3.28k
        case NID_id_qt_unotice:
453
3.28k
            BIO_printf(out, "%*sUser Notice:\n", indent, "");
454
3.28k
            print_notice(out, qualinfo->d.usernotice, indent + 2);
455
3.28k
            break;
456
457
16.4k
        default:
458
16.4k
            BIO_printf(out, "%*sUnknown Qualifier: ", indent + 2, "");
459
460
16.4k
            i2a_ASN1_OBJECT(out, qualinfo->pqualid);
461
16.4k
            break;
462
21.5k
        }
463
21.5k
    }
464
13.5k
}
465
466
static void print_notice(BIO *out, USERNOTICE *notice, int indent)
467
3.28k
{
468
3.28k
    int i;
469
3.28k
    if (notice->noticeref) {
470
1.43k
        NOTICEREF *ref;
471
1.43k
        ref = notice->noticeref;
472
1.43k
        BIO_printf(out, "%*sOrganization: %.*s\n", indent, "",
473
1.43k
            ref->organization->length,
474
1.43k
            ref->organization->data);
475
1.43k
        BIO_printf(out, "%*sNumber%s: ", indent, "",
476
1.43k
            sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : "");
477
3.72k
        for (i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) {
478
2.28k
            ASN1_INTEGER *num;
479
2.28k
            char *tmp;
480
2.28k
            num = sk_ASN1_INTEGER_value(ref->noticenos, i);
481
2.28k
            if (i)
482
1.34k
                BIO_puts(out, ", ");
483
2.28k
            if (num == NULL)
484
0
                BIO_puts(out, "(null)");
485
2.28k
            else {
486
2.28k
                tmp = i2s_ASN1_INTEGER(NULL, num);
487
2.28k
                if (tmp == NULL)
488
0
                    return;
489
2.28k
                BIO_puts(out, tmp);
490
2.28k
                OPENSSL_free(tmp);
491
2.28k
            }
492
2.28k
        }
493
1.43k
        if (notice->exptext)
494
237
            BIO_puts(out, "\n");
495
1.43k
    }
496
3.28k
    if (notice->exptext)
497
2.08k
        BIO_printf(out, "%*sExplicit Text: %.*s", indent, "",
498
2.08k
            notice->exptext->length,
499
2.08k
            notice->exptext->data);
500
3.28k
}
501
502
void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent)
503
0
{
504
0
    const X509_POLICY_DATA *dat = node->data;
505
506
0
    BIO_printf(out, "%*sPolicy: ", indent, "");
507
508
0
    i2a_ASN1_OBJECT(out, dat->valid_policy);
509
0
    BIO_puts(out, "\n");
510
0
    BIO_printf(out, "%*s%s\n", indent + 2, "",
511
0
        node_data_critical(dat) ? "Critical" : "Non Critical");
512
0
    if (dat->qualifier_set) {
513
0
        print_qualifiers(out, dat->qualifier_set, indent + 2);
514
0
        BIO_puts(out, "\n");
515
0
    } else
516
0
        BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, "");
517
0
}