8#include <botan/x509_crl.h>
10#include <botan/ber_dec.h>
11#include <botan/x509_ext.h>
12#include <botan/x509cert.h>
22 std::vector<CRL_Entry> m_entries;
23 Extensions m_extensions;
26 size_t m_crl_number = 0;
27 std::vector<uint8_t> m_auth_key_id;
28 std::vector<std::string> m_idp_urls;
31std::string X509_CRL::PEM_label()
const {
35std::vector<std::string> X509_CRL::alternate_PEM_labels()
const {
48#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
58 const std::vector<CRL_Entry>& revoked) :
60 m_data = std::make_shared<CRL_Data>();
61 m_data->m_issuer = issuer;
64 m_data->m_entries = revoked;
82 if(!crl_akid.empty() && !cert_akid.empty()) {
83 if(crl_akid != cert_akid) {
88 const std::vector<uint8_t>& cert_serial = cert.
serial_number();
94 if(cert_serial == entry.serial_number()) {
111std::unique_ptr<CRL_Data> decode_crl_body(
const std::vector<uint8_t>& body,
const AlgorithmIdentifier& sig_algo) {
112 auto data = std::make_unique<CRL_Data>();
119 if(version != 0 && version != 1) {
120 throw Decoding_Error(
"Unknown X.509 CRL version " + std::to_string(version + 1));
123 AlgorithmIdentifier sig_algo_inner;
124 tbs_crl.decode(sig_algo_inner);
126 if(sig_algo != sig_algo_inner) {
127 throw Decoding_Error(
"Algorithm identifier mismatch in CRL");
130 tbs_crl.decode(data->m_issuer).decode(data->m_this_update).decode(data->m_next_update);
132 BER_Object next = tbs_crl.get_next_object();
135 BER_Decoder cert_list(std::move(next));
137 while(cert_list.more_items()) {
139 cert_list.decode(entry);
140 data->m_entries.push_back(entry);
142 next = tbs_crl.get_next_object();
146 BER_Decoder crl_options(std::move(next));
147 crl_options.decode(data->m_extensions).verify_end();
148 next = tbs_crl.get_next_object();
152 throw Decoding_Error(
"Unknown tag following extensions in CRL");
155 tbs_crl.verify_end();
158 if(
auto ext = data->m_extensions.get_extension_object_as<Cert_Extension::CRL_Number>()) {
159 data->m_crl_number = ext->get_crl_number();
161 if(
auto ext = data->m_extensions.get_extension_object_as<Cert_Extension::Authority_Key_ID>()) {
162 data->m_auth_key_id = ext->get_key_id();
164 if(
auto ext = data->m_extensions.get_extension_object_as<Cert_Extension::CRL_Issuing_Distribution_Point>()) {
165 data->m_idp_urls = ext->get_point().get_attribute(
"URL");
173void X509_CRL::force_decode() {
177const CRL_Data& X509_CRL::data()
const {
179 throw Invalid_State(
"X509_CRL uninitialized");
185 return data().m_extensions;
192 return data().m_entries;
199 return data().m_issuer;
206 return data().m_auth_key_id;
213 return static_cast<uint32_t
>(data().m_crl_number);
220 return data().m_this_update;
227 return data().m_next_update;
234 if(!data().m_idp_urls.empty()) {
235 return data().m_idp_urls[0];
244 return data().m_idp_urls;
const std::vector< CRL_Entry > & get_revoked() const
const std::vector< uint8_t > & authority_key_id() const
const X509_Time & this_update() const
std::vector< std::string > issuing_distribution_points() const
const Extensions & extensions() const
uint32_t crl_number() const
const X509_Time & next_update() const
const X509_DN & issuer_dn() const
bool is_revoked(const X509_Certificate &cert) const
std::string crl_issuing_distribution_point() const
const std::vector< uint8_t > & serial_number() const
const std::vector< uint8_t > & authority_key_id() const
const X509_DN & issuer_dn() const
const std::vector< uint8_t > & signed_body() const
const AlgorithmIdentifier & signature_algorithm() const
void load_data(DataSource &src)