Coverage Report

Created: 2026-09-12 06:55

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