Coverage Report

Created: 2026-09-12 06:55

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
174k
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
501k
} ASN1_SEQUENCE_END(POLICYINFO)
59
501k
60
501k
IMPLEMENT_ASN1_FUNCTIONS(POLICYINFO)
61
501k
62
501k
ASN1_ADB_TEMPLATE(policydefault) = ASN1_SIMPLE(POLICYQUALINFO, d.other, ASN1_ANY);
63
501k
64
501k
ASN1_ADB(POLICYQUALINFO) = {
65
501k
    ADB_ENTRY(NID_id_qt_cps, ASN1_SIMPLE(POLICYQUALINFO, d.cpsuri, ASN1_IA5STRING)),
66
501k
    ADB_ENTRY(NID_id_qt_unotice, ASN1_SIMPLE(POLICYQUALINFO, d.usernotice, USERNOTICE))
67
526k
} 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
437k
} ASN1_SEQUENCE_END(POLICYQUALINFO)
73
437k
74
437k
IMPLEMENT_ASN1_FUNCTIONS(POLICYQUALINFO)
75
437k
76
437k
ASN1_SEQUENCE(USERNOTICE) = {
77
437k
    ASN1_OPT(USERNOTICE, noticeref, NOTICEREF),
78
437k
    ASN1_OPT(USERNOTICE, exptext, DISPLAYTEXT)
79
437k
} ASN1_SEQUENCE_END(USERNOTICE)
80
119k
81
119k
IMPLEMENT_ASN1_FUNCTIONS(USERNOTICE)
82
119k
83
119k
ASN1_SEQUENCE(NOTICEREF) = {
84
119k
    ASN1_SIMPLE(NOTICEREF, organization, DISPLAYTEXT),
85
119k
    ASN1_SEQUENCE_OF(NOTICEREF, noticenos, ASN1_INTEGER)
86
385k
} ASN1_SEQUENCE_END(NOTICEREF)
87
385k
88
385k
IMPLEMENT_ASN1_FUNCTIONS(NOTICEREF)
89
385k
90
385k
static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method,
91
385k
    X509V3_CTX *ctx, const char *value)
92
385k
{
93
527
    STACK_OF(POLICYINFO) *pols;
94
527
    char *pstr;
95
527
    POLICYINFO *pol;
96
527
    ASN1_OBJECT *pobj;
97
527
    STACK_OF(CONF_VALUE) *vals = X509V3_parse_list(value);
98
527
    CONF_VALUE *cnf;
99
527
    const int num = sk_CONF_VALUE_num(vals);
100
527
    int i, ia5org;
101
102
527
    if (vals == NULL) {
103
3
        ERR_raise(ERR_LIB_X509V3, ERR_R_X509V3_LIB);
104
3
        return NULL;
105
3
    }
106
107
524
    pols = sk_POLICYINFO_new_reserve(NULL, num);
108
524
    if (pols == NULL) {
109
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
110
0
        goto err;
111
0
    }
112
113
524
    ia5org = 0;
114
2.96k
    for (i = 0; i < num; i++) {
115
2.78k
        cnf = sk_CONF_VALUE_value(vals, i);
116
2.78k
        if (cnf->value != NULL || cnf->name == NULL) {
117
10
            ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_POLICY_IDENTIFIER);
118
10
            X509V3_conf_add_error_name_value(cnf);
119
10
            goto err;
120
10
        }
121
2.77k
        pstr = cnf->name;
122
2.77k
        if (strcmp(pstr, "ia5org") == 0) {
123
3
            ia5org = 1;
124
3
            continue;
125
2.76k
        } else if (*pstr == '@') {
126
383
            STACK_OF(CONF_VALUE) *polsect;
127
128
383
            polsect = X509V3_get_section(ctx, pstr + 1);
129
383
            if (polsect == NULL) {
130
5
                ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION,
131
5
                    "%s", cnf->name);
132
5
                goto err;
133
5
            }
134
378
            pol = policy_section(ctx, polsect, ia5org);
135
378
            X509V3_section_free(ctx, polsect);
136
378
            if (pol == NULL)
137
235
                goto err;
138
2.38k
        } else {
139
2.38k
            if ((pobj = OBJ_txt2obj(cnf->name, 0)) == NULL) {
140
93
                ERR_raise_data(ERR_LIB_X509V3,
141
93
                    X509V3_R_INVALID_OBJECT_IDENTIFIER,
142
93
                    "%s", cnf->name);
143
93
                goto err;
144
93
            }
145
2.29k
            pol = POLICYINFO_new();
146
2.29k
            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
2.29k
            pol->policyid = pobj;
152
2.29k
        }
153
2.43k
        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
2.43k
    }
159
181
    sk_CONF_VALUE_pop_free(vals, X509V3_conf_free);
160
181
    return pols;
161
343
err:
162
343
    sk_CONF_VALUE_pop_free(vals, X509V3_conf_free);
163
343
    sk_POLICYINFO_pop_free(pols, POLICYINFO_free);
164
343
    return NULL;
165
524
}
166
167
static POLICYINFO *policy_section(X509V3_CTX *ctx,
168
    STACK_OF(CONF_VALUE) *polstrs, int ia5org)
169
378
{
170
378
    int i;
171
378
    CONF_VALUE *cnf;
172
378
    POLICYINFO *pol;
173
378
    POLICYQUALINFO *qual;
174
175
378
    if ((pol = POLICYINFO_new()) == NULL) {
176
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
177
0
        goto err;
178
0
    }
179
1.03k
    for (i = 0; i < sk_CONF_VALUE_num(polstrs); i++) {
180
890
        cnf = sk_CONF_VALUE_value(polstrs, i);
181
890
        if (strcmp(cnf->name, "policyIdentifier") == 0) {
182
0
            ASN1_OBJECT *pobj;
183
184
0
            if ((pobj = OBJ_txt2obj(cnf->value, 0)) == NULL) {
185
0
                ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER);
186
0
                X509V3_conf_err(cnf);
187
0
                goto err;
188
0
            }
189
0
            pol->policyid = pobj;
190
191
890
        } else if (!ossl_v3_name_cmp(cnf->name, "CPS")) {
192
52
            if (pol->qualifiers == NULL)
193
14
                pol->qualifiers = sk_POLICYQUALINFO_new_null();
194
52
            if ((qual = POLICYQUALINFO_new()) == NULL) {
195
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
196
0
                goto err;
197
0
            }
198
52
            if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) {
199
0
                POLICYQUALINFO_free(qual);
200
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
201
0
                goto err;
202
0
            }
203
52
            if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_cps)) == NULL) {
204
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_INTERNAL_ERROR);
205
0
                goto err;
206
0
            }
207
52
            if ((qual->d.cpsuri = ASN1_IA5STRING_new()) == NULL) {
208
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
209
0
                goto err;
210
0
            }
211
52
            if (!ASN1_STRING_set1_string(qual->d.cpsuri, cnf->value)) {
212
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
213
0
                goto err;
214
0
            }
215
838
        } else if (!ossl_v3_name_cmp(cnf->name, "userNotice")) {
216
781
            STACK_OF(CONF_VALUE) *unot;
217
781
            if (*cnf->value != '@') {
218
16
                ERR_raise(ERR_LIB_X509V3, X509V3_R_EXPECTED_A_SECTION_NAME);
219
16
                X509V3_conf_err(cnf);
220
16
                goto err;
221
16
            }
222
765
            unot = X509V3_get_section(ctx, cnf->value + 1);
223
765
            if (!unot) {
224
14
                ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION);
225
226
14
                X509V3_conf_err(cnf);
227
14
                goto err;
228
14
            }
229
751
            qual = notice_section(ctx, unot, ia5org);
230
751
            X509V3_section_free(ctx, unot);
231
751
            if (!qual)
232
148
                goto err;
233
603
            if (pol->qualifiers == NULL)
234
164
                pol->qualifiers = sk_POLICYQUALINFO_new_null();
235
603
            if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) {
236
0
                POLICYQUALINFO_free(qual);
237
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
238
0
                goto err;
239
0
            }
240
603
        } else {
241
57
            ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_OPTION);
242
57
            X509V3_conf_err(cnf);
243
57
            goto err;
244
57
        }
245
890
    }
246
143
    if (pol->policyid == NULL) {
247
0
        ERR_raise(ERR_LIB_X509V3, X509V3_R_NO_POLICY_IDENTIFIER);
248
0
        goto err;
249
0
    }
250
251
143
    return pol;
252
253
235
err:
254
235
    POLICYINFO_free(pol);
255
235
    return NULL;
256
143
}
257
258
static int displaytext_get_tag_len(const char *tagstr)
259
384
{
260
384
    const char *colon = strchr(tagstr, ':');
261
262
384
    return (colon == NULL) ? -1 : (int)(colon - tagstr);
263
384
}
264
265
static int displaytext_str2tag(const char *tagstr, unsigned int *tag_len)
266
384
{
267
384
    int len;
268
269
384
    *tag_len = 0;
270
384
    len = displaytext_get_tag_len(tagstr);
271
272
384
    if (len == -1)
273
40
        return V_ASN1_VISIBLESTRING;
274
344
    *tag_len = len;
275
344
    if (len == sizeof("UTF8") - 1 && HAS_PREFIX(tagstr, "UTF8"))
276
35
        return V_ASN1_UTF8STRING;
277
309
    if (len == sizeof("UTF8String") - 1 && HAS_PREFIX(tagstr, "UTF8String"))
278
0
        return V_ASN1_UTF8STRING;
279
309
    if (len == sizeof("BMP") - 1 && HAS_PREFIX(tagstr, "BMP"))
280
18
        return V_ASN1_BMPSTRING;
281
291
    if (len == sizeof("BMPSTRING") - 1 && HAS_PREFIX(tagstr, "BMPSTRING"))
282
15
        return V_ASN1_BMPSTRING;
283
276
    if (len == sizeof("VISIBLE") - 1 && HAS_PREFIX(tagstr, "VISIBLE"))
284
40
        return V_ASN1_VISIBLESTRING;
285
236
    if (len == sizeof("VISIBLESTRING") - 1 && HAS_PREFIX(tagstr, "VISIBLESTRING"))
286
16
        return V_ASN1_VISIBLESTRING;
287
220
    *tag_len = 0;
288
220
    return V_ASN1_VISIBLESTRING;
289
236
}
290
291
static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
292
    STACK_OF(CONF_VALUE) *unot, int ia5org)
293
751
{
294
751
    int i, ret, len, tag;
295
751
    unsigned int tag_len;
296
751
    CONF_VALUE *cnf;
297
751
    USERNOTICE *not;
298
751
    POLICYQUALINFO *qual;
299
751
    char *value = NULL;
300
301
751
    if ((qual = POLICYQUALINFO_new()) == NULL) {
302
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
303
0
        goto err;
304
0
    }
305
751
    if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice)) == NULL) {
306
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_INTERNAL_ERROR);
307
0
        goto err;
308
0
    }
309
751
    if ((not = USERNOTICE_new()) == NULL) {
310
0
        ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
311
0
        goto err;
312
0
    }
313
751
    qual->d.usernotice = not;
314
1.61k
    for (i = 0; i < sk_CONF_VALUE_num(unot); i++) {
315
1.01k
        cnf = sk_CONF_VALUE_value(unot, i);
316
317
1.01k
        value = cnf->value;
318
1.01k
        if (strcmp(cnf->name, "explicitText") == 0) {
319
384
            tag = displaytext_str2tag(value, &tag_len);
320
384
            if ((not->exptext = ASN1_STRING_type_new(tag)) == NULL) {
321
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
322
0
                goto err;
323
0
            }
324
384
            if (tag_len != 0)
325
124
                value += tag_len + 1;
326
384
            len = (int)strlen(value);
327
384
            if (!ASN1_STRING_set1_data(not->exptext, (uint8_t *)value, len)) {
328
0
                ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
329
0
                goto err;
330
0
            }
331
628
        } else if (strcmp(cnf->name, "organization") == 0) {
332
147
            NOTICEREF *nref;
333
334
147
            if (!not->noticeref) {
335
67
                if ((nref = NOTICEREF_new()) == NULL) {
336
0
                    ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
337
0
                    goto err;
338
0
                }
339
67
                not->noticeref = nref;
340
67
            } else
341
80
                nref = not->noticeref;
342
147
            if (ia5org)
343
0
                nref->organization->type = V_ASN1_IA5STRING;
344
147
            else
345
147
                nref->organization->type = V_ASN1_VISIBLESTRING;
346
147
            if (!ASN1_STRING_set1_string(nref->organization, 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
4.21k
{
437
4.21k
    POLICYQUALINFO *qualinfo;
438
4.21k
    int i;
439
10.0k
    for (i = 0; i < sk_POLICYQUALINFO_num(quals); i++) {
440
5.81k
        if (i > 0)
441
2.97k
            BIO_puts(out, "\n");
442
5.81k
        qualinfo = sk_POLICYQUALINFO_value(quals, i);
443
5.81k
        switch (OBJ_obj2nid(qualinfo->pqualid)) {
444
997
        case NID_id_qt_cps:
445
997
            BIO_printf(out, "%*sCPS: %.*s", indent, "",
446
997
                qualinfo->d.cpsuri->length,
447
997
                qualinfo->d.cpsuri->length
448
997
                    ? qualinfo->d.cpsuri->data
449
997
                    : (const unsigned char *)"");
450
997
            break;
451
452
1.80k
        case NID_id_qt_unotice:
453
1.80k
            BIO_printf(out, "%*sUser Notice:\n", indent, "");
454
1.80k
            print_notice(out, qualinfo->d.usernotice, indent + 2);
455
1.80k
            break;
456
457
3.01k
        default:
458
3.01k
            BIO_printf(out, "%*sUnknown Qualifier: ", indent + 2, "");
459
460
3.01k
            i2a_ASN1_OBJECT(out, qualinfo->pqualid);
461
3.01k
            break;
462
5.81k
        }
463
5.81k
    }
464
4.21k
}
465
466
static void print_notice(BIO *out, USERNOTICE *notice, int indent)
467
1.80k
{
468
1.80k
    int i;
469
1.80k
    if (notice->noticeref) {
470
605
        NOTICEREF *ref;
471
605
        ref = notice->noticeref;
472
605
        BIO_printf(out, "%*sOrganization: %.*s\n", indent, "",
473
605
            ref->organization->length,
474
605
            ref->organization->length
475
605
                ? ref->organization->data
476
605
                : (const unsigned char *)"");
477
605
        BIO_printf(out, "%*sNumber%s: ", indent, "",
478
605
            sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : "");
479
1.46k
        for (i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) {
480
864
            ASN1_INTEGER *num;
481
864
            char *tmp;
482
864
            num = sk_ASN1_INTEGER_value(ref->noticenos, i);
483
864
            if (i)
484
424
                BIO_puts(out, ", ");
485
864
            if (num == NULL)
486
0
                BIO_puts(out, "(null)");
487
864
            else {
488
864
                tmp = i2s_ASN1_INTEGER(NULL, num);
489
864
                if (tmp == NULL)
490
0
                    return;
491
864
                BIO_puts(out, tmp);
492
864
                OPENSSL_free(tmp);
493
864
            }
494
864
        }
495
605
        if (notice->exptext)
496
103
            BIO_puts(out, "\n");
497
605
    }
498
1.80k
    if (notice->exptext)
499
1.29k
        BIO_printf(out, "%*sExplicit Text: %.*s", indent, "",
500
1.29k
            notice->exptext->length,
501
1.29k
            notice->exptext->length
502
1.29k
                ? notice->exptext->data
503
1.29k
                : (const unsigned char *)"");
504
1.80k
}
505
506
void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent)
507
0
{
508
0
    const X509_POLICY_DATA *dat = node->data;
509
510
0
    BIO_printf(out, "%*sPolicy: ", indent, "");
511
512
0
    i2a_ASN1_OBJECT(out, dat->valid_policy);
513
0
    BIO_puts(out, "\n");
514
0
    BIO_printf(out, "%*s%s\n", indent + 2, "",
515
0
        node_data_critical(dat) ? "Critical" : "Non Critical");
516
0
    if (dat->qualifier_set) {
517
0
        print_qualifiers(out, dat->qualifier_set, indent + 2);
518
0
        BIO_puts(out, "\n");
519
0
    } else
520
0
        BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, "");
521
0
}