Botan  2.6.0
Crypto and TLS for C++11
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/x509_obj.h>
12 #include <botan/x509_dn.h>
13 #include <botan/crl_ent.h>
14 #include <vector>
15 
16 namespace Botan {
17 
18 class Extensions;
19 class X509_Certificate;
20 
21 struct CRL_Data;
22 
23 /**
24 * This class represents X.509 Certificate Revocation Lists (CRLs).
25 */
26 class BOTAN_PUBLIC_API(2,0) X509_CRL final : public X509_Object
27  {
28  public:
29  /**
30  * This class represents CRL related errors.
31  */
32  class BOTAN_PUBLIC_API(2,0) X509_CRL_Error final : public Exception
33  {
34  public:
35  explicit X509_CRL_Error(const std::string& error) :
36  Exception("X509_CRL: " + error) {}
37  };
38 
39  /**
40  * Check if this particular certificate is listed in the CRL
41  */
42  bool is_revoked(const X509_Certificate& cert) const;
43 
44  /**
45  * Get the entries of this CRL in the form of a vector.
46  * @return vector containing the entries of this CRL.
47  */
48  const std::vector<CRL_Entry>& get_revoked() const;
49 
50  /**
51  * Get the issuer DN of this CRL.
52  * @return CRLs issuer DN
53  */
54  const X509_DN& issuer_dn() const;
55 
56  /**
57  * @return extension data for this CRL
58  */
59  const Extensions& extensions() const;
60 
61  /**
62  * Get the AuthorityKeyIdentifier of this CRL.
63  * @return this CRLs AuthorityKeyIdentifier
64  */
65  const std::vector<uint8_t>& authority_key_id() const;
66 
67  /**
68  * Get the serial number of this CRL.
69  * @return CRLs serial number
70  */
71  uint32_t crl_number() const;
72 
73  /**
74  * Get the CRL's thisUpdate value.
75  * @return CRLs thisUpdate
76  */
77  const X509_Time& this_update() const;
78 
79  /**
80  * Get the CRL's nextUpdate value.
81  * @return CRLs nextdUpdate
82  */
83  const X509_Time& next_update() const;
84 
85  /**
86  * Get the CRL's distribution point
87  * @return CRL.IssuingDistributionPoint from the CRL's Data_Store
88  */
89  std::string crl_issuing_distribution_point() const;
90 
91  /**
92  * Create an uninitialized CRL object. Any attempts to access
93  * this object will throw an exception.
94  */
95  X509_CRL() = default;
96 
97  /**
98  * Construct a CRL from a data source.
99  * @param source the data source providing the DER or PEM encoded CRL.
100  */
101  X509_CRL(DataSource& source);
102 
103 #if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
104  /**
105  * Construct a CRL from a file containing the DER or PEM encoded CRL.
106  * @param filename the name of the CRL file
107  */
108  X509_CRL(const std::string& filename);
109 #endif
110 
111  /**
112  * Construct a CRL from a binary vector
113  * @param vec the binary (DER) representation of the CRL
114  */
115  X509_CRL(const std::vector<uint8_t>& vec);
116 
117  /**
118  * Construct a CRL
119  * @param issuer issuer of this CRL
120  * @param thisUpdate valid from
121  * @param nextUpdate valid until
122  * @param revoked entries to be included in the CRL
123  */
124  X509_CRL(const X509_DN& issuer, const X509_Time& thisUpdate,
125  const X509_Time& nextUpdate, const std::vector<CRL_Entry>& revoked);
126 
127  private:
128  std::string PEM_label() const override;
129 
130  std::vector<std::string> alternate_PEM_labels() const override;
131 
132  void force_decode() override;
133 
134  const CRL_Data& data() const;
135 
136  std::shared_ptr<CRL_Data> m_data;
137  };
138 
139 }
140 
141 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
X509_CRL_Error(const std::string &error)
Definition: x509_crl.h:35
Definition: alg_id.cpp:13