Coverage Report

Created: 2025-12-10 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/x509/pcy_lib.c
Line
Count
Source
1
/*
2
 * Copyright 2004-2020 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 "internal/cryptlib.h"
11
#include <openssl/x509.h>
12
#include <openssl/x509v3.h>
13
14
#include "pcy_local.h"
15
16
/* accessor functions */
17
18
/* X509_POLICY_TREE stuff */
19
20
int X509_policy_tree_level_count(const X509_POLICY_TREE *tree)
21
0
{
22
0
    if (!tree)
23
0
        return 0;
24
0
    return tree->nlevel;
25
0
}
26
27
X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,
28
    int i)
29
0
{
30
0
    if (!tree || (i < 0) || (i >= tree->nlevel))
31
0
        return NULL;
32
0
    return tree->levels + i;
33
0
}
34
35
STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const X509_POLICY_TREE
36
        *tree)
37
0
{
38
0
    if (!tree)
39
0
        return NULL;
40
0
    return tree->auth_policies;
41
0
}
42
43
STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const X509_POLICY_TREE
44
        *tree)
45
0
{
46
0
    if (!tree)
47
0
        return NULL;
48
0
    if (tree->flags & POLICY_FLAG_ANY_POLICY)
49
0
        return tree->auth_policies;
50
0
    else
51
0
        return tree->user_policies;
52
0
}
53
54
/* X509_POLICY_LEVEL stuff */
55
56
int X509_policy_level_node_count(X509_POLICY_LEVEL *level)
57
0
{
58
0
    int n;
59
0
    if (!level)
60
0
        return 0;
61
0
    if (level->anyPolicy)
62
0
        n = 1;
63
0
    else
64
0
        n = 0;
65
0
    if (level->nodes)
66
0
        n += sk_X509_POLICY_NODE_num(level->nodes);
67
0
    return n;
68
0
}
69
70
X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level, int i)
71
0
{
72
0
    if (!level)
73
0
        return NULL;
74
0
    if (level->anyPolicy) {
75
0
        if (i == 0)
76
0
            return level->anyPolicy;
77
0
        i--;
78
0
    }
79
0
    return sk_X509_POLICY_NODE_value(level->nodes, i);
80
0
}
81
82
/* X509_POLICY_NODE stuff */
83
84
const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node)
85
0
{
86
0
    if (!node)
87
0
        return NULL;
88
0
    return node->data->valid_policy;
89
0
}
90
91
STACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const X509_POLICY_NODE
92
        *node)
93
0
{
94
0
    if (!node)
95
0
        return NULL;
96
0
    return node->data->qualifier_set;
97
0
}
98
99
const X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE
100
        *node)
101
0
{
102
0
    if (!node)
103
0
        return NULL;
104
0
    return node->parent;
105
0
}