Botan 3.7.1
Crypto and TLS for C&
x509_crl.h
Go to the documentation of this file.
1/*
2* X.509 CRL
3* (C) 1999-2007 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_X509_CRL_H_
9#define BOTAN_X509_CRL_H_
10
11#include <botan/asn1_obj.h>
12#include <botan/pkix_enums.h>
13#include <botan/x509_obj.h>
14#include <vector>
15
16namespace Botan {
17
18class Extensions;
19class X509_Certificate;
20class X509_DN;
21
22struct CRL_Entry_Data;
23struct CRL_Data;
24
25/**
26* This class represents CRL entries
27*/
29 public:
30 void encode_into(DER_Encoder&) const override;
31 void decode_from(BER_Decoder&) override;
32
33 /**
34 * Get the serial number of the certificate associated with this entry.
35 * @return certificate's serial number
36 */
37 const std::vector<uint8_t>& serial_number() const;
38
39 /**
40 * Get the revocation date of the certificate associated with this entry
41 * @return certificate's revocation date
42 */
43 const X509_Time& expire_time() const;
44
45 /**
46 * Get the entries reason code
47 * @return reason code
48 */
49 CRL_Code reason_code() const;
50
51 /**
52 * Get the extensions on this CRL entry
53 */
54 const Extensions& extensions() const;
55
56 /**
57 * Create uninitialized CRL_Entry object
58 */
59 CRL_Entry() = default;
60
61 /**
62 * Construct an CRL entry.
63 * @param cert the certificate to revoke
64 * @param reason the reason code to set in the entry
65 */
66 CRL_Entry(const X509_Certificate& cert, CRL_Code reason = CRL_Code::Unspecified);
67
68 private:
69 friend class X509_CRL;
70
71 const CRL_Entry_Data& data() const;
72
73 std::shared_ptr<CRL_Entry_Data> m_data;
74};
75
76/**
77* Test two CRL entries for equality in all fields.
78*/
79BOTAN_PUBLIC_API(2, 0) bool operator==(const CRL_Entry&, const CRL_Entry&);
80
81/**
82* Test two CRL entries for inequality in at least one field.
83*/
84BOTAN_PUBLIC_API(2, 0) bool operator!=(const CRL_Entry&, const CRL_Entry&);
85
86/**
87* This class represents X.509 Certificate Revocation Lists (CRLs).
88*/
90 public:
91 /**
92 * Check if this particular certificate is listed in the CRL
93 */
94 bool is_revoked(const X509_Certificate& cert) const;
95
96 /**
97 * Get the entries of this CRL in the form of a vector.
98 * @return vector containing the entries of this CRL.
99 */
100 const std::vector<CRL_Entry>& get_revoked() const;
101
102 /**
103 * Get the X509 version of this CRL object
104 * @return X509 version
105 */
106 uint32_t x509_version() const;
107
108 /**
109 * Get the issuer DN of this CRL.
110 * @return CRLs issuer DN
111 */
112 const X509_DN& issuer_dn() const;
113
114 /**
115 * @return extension data for this CRL
116 */
117 const Extensions& extensions() const;
118
119 /**
120 * Get the AuthorityKeyIdentifier of this CRL.
121 * @return this CRLs AuthorityKeyIdentifier
122 */
123 const std::vector<uint8_t>& authority_key_id() const;
124
125 /**
126 * Get the serial number of this CRL.
127 * @return CRLs serial number
128 */
129 uint32_t crl_number() const;
130
131 /**
132 * Get the CRL's thisUpdate value.
133 * @return CRLs thisUpdate
134 */
135 const X509_Time& this_update() const;
136
137 /**
138 * Get the CRL's nextUpdate value.
139 * @return CRLs nextdUpdate
140 */
141 const X509_Time& next_update() const;
142
143 /**
144 * Get the CRL's issuing distribution point
145 */
146 BOTAN_DEPRECATED("Use issuing_distribution_points") std::string crl_issuing_distribution_point() const;
147
148 /**
149 * Get the CRL's issuing distribution points
150 *
151 * See https://www.rfc-editor.org/rfc/rfc5280#section-5.2.5
152 */
153 std::vector<std::string> issuing_distribution_points() const;
154
155 /**
156 * Create an uninitialized CRL object. Any attempts to access
157 * this object will throw an exception.
158 */
159 X509_CRL() = default;
160
161 /**
162 * Construct a CRL from a data source.
163 * @param source the data source providing the DER or PEM encoded CRL.
164 */
165 X509_CRL(DataSource& source);
166
167#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
168 /**
169 * Construct a CRL from a file containing the DER or PEM encoded CRL.
170 * @param filename the name of the CRL file
171 */
172 X509_CRL(std::string_view filename);
173#endif
174
175 /**
176 * Construct a CRL from a binary vector
177 * @param vec the binary (DER) representation of the CRL
178 */
179 X509_CRL(const std::vector<uint8_t>& vec);
180
181 /**
182 * Construct a CRL
183 * @param issuer issuer of this CRL
184 * @param thisUpdate valid from
185 * @param nextUpdate valid until
186 * @param revoked entries to be included in the CRL
187 */
188 X509_CRL(const X509_DN& issuer,
189 const X509_Time& thisUpdate,
190 const X509_Time& nextUpdate,
191 const std::vector<CRL_Entry>& revoked);
192
193 private:
194 std::string PEM_label() const override;
195
196 std::vector<std::string> alternate_PEM_labels() const override;
197
198 void force_decode() override;
199
200 const CRL_Data& data() const;
201
202 std::shared_ptr<CRL_Data> m_data;
203};
204
205} // namespace Botan
206
207#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:19
#define BOTAN_DEPRECATED(msg)
Definition api.h:59
Definition x509_crl.h:28
CRL_Entry()=default
X509_CRL()=default
int(* final)(unsigned char *, CTX *)