Botan 3.3.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 distribution point
139 */
140 std::string crl_issuing_distribution_point() const;
141
142 /**
143 * Create an uninitialized CRL object. Any attempts to access
144 * this object will throw an exception.
145 */
146 X509_CRL() = default;
147
148 /**
149 * Construct a CRL from a data source.
150 * @param source the data source providing the DER or PEM encoded CRL.
151 */
152 X509_CRL(DataSource& source);
153
154#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
155 /**
156 * Construct a CRL from a file containing the DER or PEM encoded CRL.
157 * @param filename the name of the CRL file
158 */
159 X509_CRL(std::string_view filename);
160#endif
161
162 /**
163 * Construct a CRL from a binary vector
164 * @param vec the binary (DER) representation of the CRL
165 */
166 X509_CRL(const std::vector<uint8_t>& vec);
167
168 /**
169 * Construct a CRL
170 * @param issuer issuer of this CRL
171 * @param thisUpdate valid from
172 * @param nextUpdate valid until
173 * @param revoked entries to be included in the CRL
174 */
175 X509_CRL(const X509_DN& issuer,
176 const X509_Time& thisUpdate,
177 const X509_Time& nextUpdate,
178 const std::vector<CRL_Entry>& revoked);
179
180 private:
181 std::string PEM_label() const override;
182
183 std::vector<std::string> alternate_PEM_labels() const override;
184
185 void force_decode() override;
186
187 const CRL_Data& data() const;
188
189 std::shared_ptr<CRL_Data> m_data;
190};
191
192} // namespace Botan
193
194#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