Botan 3.5.0
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 issuer DN of this CRL.
104 * @return CRLs issuer DN
105 */
106 const X509_DN& issuer_dn() const;
107
108 /**
109 * @return extension data for this CRL
110 */
111 const Extensions& extensions() const;
112
113 /**
114 * Get the AuthorityKeyIdentifier of this CRL.
115 * @return this CRLs AuthorityKeyIdentifier
116 */
117 const std::vector<uint8_t>& authority_key_id() const;
118
119 /**
120 * Get the serial number of this CRL.
121 * @return CRLs serial number
122 */
123 uint32_t crl_number() const;
124
125 /**
126 * Get the CRL's thisUpdate value.
127 * @return CRLs thisUpdate
128 */
129 const X509_Time& this_update() const;
130
131 /**
132 * Get the CRL's nextUpdate value.
133 * @return CRLs nextdUpdate
134 */
135 const X509_Time& next_update() const;
136
137 /**
138 * Get the CRL's issuing distribution point
139 */
140 BOTAN_DEPRECATED("Use issuing_distribution_points") std::string crl_issuing_distribution_point() const;
141
142 /**
143 * Get the CRL's issuing distribution points
144 *
145 * See https://www.rfc-editor.org/rfc/rfc5280#section-5.2.5
146 */
147 std::vector<std::string> issuing_distribution_points() const;
148
149 /**
150 * Create an uninitialized CRL object. Any attempts to access
151 * this object will throw an exception.
152 */
153 X509_CRL() = default;
154
155 /**
156 * Construct a CRL from a data source.
157 * @param source the data source providing the DER or PEM encoded CRL.
158 */
159 X509_CRL(DataSource& source);
160
161#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
162 /**
163 * Construct a CRL from a file containing the DER or PEM encoded CRL.
164 * @param filename the name of the CRL file
165 */
166 X509_CRL(std::string_view filename);
167#endif
168
169 /**
170 * Construct a CRL from a binary vector
171 * @param vec the binary (DER) representation of the CRL
172 */
173 X509_CRL(const std::vector<uint8_t>& vec);
174
175 /**
176 * Construct a CRL
177 * @param issuer issuer of this CRL
178 * @param thisUpdate valid from
179 * @param nextUpdate valid until
180 * @param revoked entries to be included in the CRL
181 */
182 X509_CRL(const X509_DN& issuer,
183 const X509_Time& thisUpdate,
184 const X509_Time& nextUpdate,
185 const std::vector<CRL_Entry>& revoked);
186
187 private:
188 std::string PEM_label() const override;
189
190 std::vector<std::string> alternate_PEM_labels() const override;
191
192 void force_decode() override;
193
194 const CRL_Data& data() const;
195
196 std::shared_ptr<CRL_Data> m_data;
197};
198
199} // namespace Botan
200
201#endif
Definition x509_crl.h:28
CRL_Entry()=default
X509_CRL()=default
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
#define BOTAN_DEPRECATED(msg)
Definition compiler.h:125