Coverage Report

Created: 2026-10-19 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boringssl/crypto/x509/x509_ext.cc
Line
Count
Source
1
// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <openssl/asn1.h>
16
#include <openssl/evp.h>
17
#include <openssl/obj.h>
18
#include <openssl/stack.h>
19
#include <openssl/x509.h>
20
21
#include "../internal.h"
22
#include "internal.h"
23
24
25
using namespace bssl;
26
27
0
int X509_CRL_get_ext_count(const X509_CRL *x) {
28
0
  return X509v3_get_ext_count(x->crl->extensions);
29
0
}
30
31
0
int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos) {
32
0
  return X509v3_get_ext_by_NID(x->crl->extensions, nid, lastpos);
33
0
}
34
35
int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,
36
0
                            int lastpos) {
37
0
  return X509v3_get_ext_by_OBJ(x->crl->extensions, obj, lastpos);
38
0
}
39
40
0
int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos) {
41
0
  return X509v3_get_ext_by_critical(x->crl->extensions, crit, lastpos);
42
0
}
43
44
0
X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc) {
45
0
  return X509v3_get_ext(x->crl->extensions, loc);
46
0
}
47
48
0
static X509_EXTENSION *delete_ext(STACK_OF(X509_EXTENSION) **exts, int loc) {
49
0
  X509_EXTENSION *ext = X509v3_delete_ext(*exts, loc);
50
  // Empty extension lists are omitted.
51
0
  if (*exts != nullptr && sk_X509_EXTENSION_num(*exts) == 0) {
52
0
    sk_X509_EXTENSION_pop_free(*exts, X509_EXTENSION_free);
53
0
    *exts = nullptr;
54
0
  }
55
0
  return ext;
56
0
}
57
58
0
X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc) {
59
0
  return delete_ext(&x->crl->extensions, loc);
60
0
}
61
62
void *X509_CRL_get_ext_d2i(const X509_CRL *crl, int nid, int *out_critical,
63
0
                           int *out_idx) {
64
0
  return X509V3_get_d2i(crl->crl->extensions, nid, out_critical, out_idx);
65
0
}
66
67
int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
68
0
                          unsigned long flags) {
69
0
  return X509V3_add1_i2d(&x->crl->extensions, nid, value, crit, flags);
70
0
}
71
72
0
int X509_CRL_add_ext(X509_CRL *x, const X509_EXTENSION *ex, int loc) {
73
0
  return X509v3_add_ext(&x->crl->extensions, ex, loc) != nullptr;
74
0
}
75
76
53.3k
int X509_get_ext_count(const X509 *x) {
77
53.3k
  const auto *impl = FromOpaque(x);
78
53.3k
  return X509v3_get_ext_count(impl->extensions);
79
53.3k
}
80
81
2.43k
int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos) {
82
2.43k
  const auto *impl = FromOpaque(x);
83
2.43k
  return X509v3_get_ext_by_NID(impl->extensions, nid, lastpos);
84
2.43k
}
85
86
0
int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos) {
87
0
  const auto *impl = FromOpaque(x);
88
0
  return X509v3_get_ext_by_OBJ(impl->extensions, obj, lastpos);
89
0
}
90
91
0
int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos) {
92
0
  const auto *impl = FromOpaque(x);
93
0
  return X509v3_get_ext_by_critical(impl->extensions, crit, lastpos);
94
0
}
95
96
49.8k
X509_EXTENSION *X509_get_ext(const X509 *x, int loc) {
97
49.8k
  const auto *impl = FromOpaque(x);
98
49.8k
  return X509v3_get_ext(impl->extensions, loc);
99
49.8k
}
100
101
0
X509_EXTENSION *X509_delete_ext(X509 *x, int loc) {
102
0
  auto *impl = FromOpaque(x);
103
0
  return delete_ext(&impl->extensions, loc);
104
0
}
105
106
0
int X509_add_ext(X509 *x, const X509_EXTENSION *ex, int loc) {
107
0
  auto *impl = FromOpaque(x);
108
0
  return X509v3_add_ext(&impl->extensions, ex, loc) != nullptr;
109
0
}
110
111
void *X509_get_ext_d2i(const X509 *x509, int nid, int *out_critical,
112
23.1k
                       int *out_idx) {
113
23.1k
  const auto *impl = FromOpaque(x509);
114
23.1k
  return X509V3_get_d2i(impl->extensions, nid, out_critical, out_idx);
115
23.1k
}
116
117
int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
118
0
                      unsigned long flags) {
119
0
  auto *impl = FromOpaque(x);
120
0
  return X509V3_add1_i2d(&impl->extensions, nid, value, crit, flags);
121
0
}
122
123
0
int X509_REVOKED_get_ext_count(const X509_REVOKED *x) {
124
0
  return X509v3_get_ext_count(x->extensions);
125
0
}
126
127
0
int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos) {
128
0
  return X509v3_get_ext_by_NID(x->extensions, nid, lastpos);
129
0
}
130
131
int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,
132
0
                                int lastpos) {
133
0
  return X509v3_get_ext_by_OBJ(x->extensions, obj, lastpos);
134
0
}
135
136
int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,
137
0
                                     int lastpos) {
138
0
  return X509v3_get_ext_by_critical(x->extensions, crit, lastpos);
139
0
}
140
141
0
X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc) {
142
0
  return X509v3_get_ext(x->extensions, loc);
143
0
}
144
145
0
X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc) {
146
0
  return delete_ext(&x->extensions, loc);
147
0
}
148
149
0
int X509_REVOKED_add_ext(X509_REVOKED *x, const X509_EXTENSION *ex, int loc) {
150
0
  return X509v3_add_ext(&x->extensions, ex, loc) != nullptr;
151
0
}
152
153
void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *revoked, int nid,
154
0
                               int *out_critical, int *out_idx) {
155
0
  return X509V3_get_d2i(revoked->extensions, nid, out_critical, out_idx);
156
0
}
157
158
int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
159
0
                              unsigned long flags) {
160
0
  return X509V3_add1_i2d(&x->extensions, nid, value, crit, flags);
161
0
}