Coverage Report

Created: 2020-05-23 13:54

/src/botan/build/include/botan/x509_crl.h
Line
Count
Source
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
      * In a future major release this exception type will be removed and
33
      * replaced with Decoding_Error
34
      */
35
      class BOTAN_PUBLIC_API(2,0) X509_CRL_Error final : public Decoding_Error
36
         {
37
         public:
38
            explicit X509_CRL_Error(const std::string& error) :
39
203
               Decoding_Error("X509_CRL: " + error) {}
40
         };
41
42
      /**
43
      * Check if this particular certificate is listed in the CRL
44
      */
45
      bool is_revoked(const X509_Certificate& cert) const;
46
47
      /**
48
      * Get the entries of this CRL in the form of a vector.
49
      * @return vector containing the entries of this CRL.
50
      */
51
      const std::vector<CRL_Entry>& get_revoked() const;
52
53
      /**
54
      * Get the issuer DN of this CRL.
55
      * @return CRLs issuer DN
56
      */
57
      const X509_DN& issuer_dn() const;
58
59
      /**
60
      * @return extension data for this CRL
61
      */
62
      const Extensions& extensions() const;
63
64
      /**
65
      * Get the AuthorityKeyIdentifier of this CRL.
66
      * @return this CRLs AuthorityKeyIdentifier
67
      */
68
      const std::vector<uint8_t>& authority_key_id() const;
69
70
      /**
71
      * Get the serial number of this CRL.
72
      * @return CRLs serial number
73
      */
74
      uint32_t crl_number() const;
75
76
      /**
77
      * Get the CRL's thisUpdate value.
78
      * @return CRLs thisUpdate
79
      */
80
      const X509_Time& this_update() const;
81
82
      /**
83
      * Get the CRL's nextUpdate value.
84
      * @return CRLs nextdUpdate
85
      */
86
      const X509_Time& next_update() const;
87
88
      /**
89
      * Get the CRL's distribution point
90
      * @return CRL.IssuingDistributionPoint from the CRL's Data_Store
91
      */
92
      std::string crl_issuing_distribution_point() const;
93
94
      /**
95
      * Create an uninitialized CRL object. Any attempts to access
96
      * this object will throw an exception.
97
      */
98
      X509_CRL() = default;
99
100
      /**
101
      * Construct a CRL from a data source.
102
      * @param source the data source providing the DER or PEM encoded CRL.
103
      */
104
      X509_CRL(DataSource& source);
105
106
#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
107
      /**
108
      * Construct a CRL from a file containing the DER or PEM encoded CRL.
109
      * @param filename the name of the CRL file
110
      */
111
      X509_CRL(const std::string& filename);
112
#endif
113
114
      /**
115
      * Construct a CRL from a binary vector
116
      * @param vec the binary (DER) representation of the CRL
117
      */
118
      X509_CRL(const std::vector<uint8_t>& vec);
119
120
      /**
121
      * Construct a CRL
122
      * @param issuer issuer of this CRL
123
      * @param thisUpdate valid from
124
      * @param nextUpdate valid until
125
      * @param revoked entries to be included in the CRL
126
      */
127
      X509_CRL(const X509_DN& issuer, const X509_Time& thisUpdate,
128
               const X509_Time& nextUpdate, const std::vector<CRL_Entry>& revoked);
129
130
   private:
131
      std::string PEM_label() const override;
132
133
      std::vector<std::string> alternate_PEM_labels() const override;
134
135
      void force_decode() override;
136
137
      const CRL_Data& data() const;
138
139
      std::shared_ptr<CRL_Data> m_data;
140
   };
141
142
}
143
144
#endif