Botan 3.13.0
Crypto and TLS for C&
Botan::CRL_Entry Class Referencefinal

#include <x509_crl.h>

Inheritance diagram for Botan::CRL_Entry:
Botan::ASN1_Object

Public Member Functions

std::vector< uint8_t > BER_encode () const
 CRL_Entry ()=default
BOTAN_FUTURE_EXPLICIT CRL_Entry (const X509_Certificate &cert, CRL_Code reason=CRL_Code::Unspecified)
void decode_from (BER_Decoder &from) override
void encode_into (DER_Encoder &to) const override
const X509_Timeexpire_time () const
const Extensionsextensions () const
CRL_Code reason_code () const
const X509_Serial_Numberserial () const
const std::vector< uint8_t > & serial_number () const

Friends

class X509_CRL

Detailed Description

This class represents CRL entries

Definition at line 32 of file x509_crl.h.

Constructor & Destructor Documentation

◆ CRL_Entry() [1/2]

Botan::CRL_Entry::CRL_Entry ( )
default

Create uninitialized CRL_Entry object

References BOTAN_FUTURE_EXPLICIT, CRL_Entry(), and Botan::Unspecified.

Referenced by CRL_Entry().

◆ CRL_Entry() [2/2]

Botan::CRL_Entry::CRL_Entry ( const X509_Certificate & cert,
CRL_Code reason = CRL_Code::Unspecified )

Construct an CRL entry.

Parameters
certthe certificate to revoke
reasonthe reason code to set in the entry

Definition at line 46 of file crl_ent.cpp.

46 {
47 m_data = std::make_shared<CRL_Entry_Data>(cert, why);
48}

Member Function Documentation

◆ BER_encode()

std::vector< uint8_t > Botan::ASN1_Object::BER_encode ( ) const
inherited

Return the encoding of this object. This is a convenience method when just one object needs to be serialized. Use DER_Encoder for complicated encodings.

Definition at line 21 of file asn1_obj.cpp.

21 {
22 std::vector<uint8_t> output;
23 DER_Encoder der(output);
24 this->encode_into(der);
25 return output;
26}
virtual void encode_into(DER_Encoder &to) const =0

References encode_into().

Referenced by decode_from(), Botan::PKCS12::export_to(), Botan::Certificate_Store_In_SQL::find_all_certs(), Botan::Certificate_Store_In_SQL::find_cert(), Botan::X509_Certificate::fingerprint(), Botan::Certificate_Store_In_SQL::insert_cert(), Botan::X509_Object::PEM_encode(), and Botan::PSS_Params::PSS_Params().

◆ decode_from()

void Botan::CRL_Entry::decode_from ( BER_Decoder & from)
overridevirtual

Decode whatever this object is from from

Parameters
fromthe BER_Decoder that will be read from

Implements Botan::ASN1_Object.

Definition at line 89 of file crl_ent.cpp.

89 {
90 auto data = std::make_unique<CRL_Entry_Data>();
91
92 BER_Decoder entry = source.start_sequence();
93
94 entry.decode(data->m_serial);
95 entry.decode(data->m_time);
96
97 data->m_serial_bits = data->m_serial.magnitude();
98
99 if(entry.more_items()) {
100 data->m_extensions.decode_from(entry, Extension_Context::CRL_Entry);
101
102 // TODO(Botan4) start checking that CRLEntry extensions is not empty
103 // Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
104
105 if(const auto* ext = data->m_extensions.get_extension_object_as<Cert_Extension::CRL_ReasonCode>()) {
106 const auto reason = ext->get_reason();
107
108 /*
109 * This reason code only makes sense in the context of delta CRL processing, which
110 * we do not currently support. Seeing it in a regular CRL suggests that something
111 * has gone very wrong (eg we are somehow processing a delta CRL, though that
112 * shouldn't happen since the delta CRL indicator extension should be a critical
113 * extension which we will reject.)
114 */
115 if(reason == CRL_Code::RemoveFromCrl) {
116 throw Decoding_Error("CRL entry ReasonCode extension included invalid RemoveFromCrl");
117 }
118 data->m_reason = reason;
119 } else {
120 data->m_reason = CRL_Code::Unspecified;
121 }
122 }
123
124 entry.end_cons();
125
126 m_data = std::move(data);
127}

References Botan::CRL_Entry, Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::BER_Decoder::more_items(), Botan::RemoveFromCrl, Botan::BER_Decoder::start_sequence(), and Botan::Unspecified.

◆ encode_into()

void Botan::CRL_Entry::encode_into ( DER_Encoder & to) const
overridevirtual

Encode whatever this object is into to

Parameters
tothe DER_Encoder that will be written to

Implements Botan::ASN1_Object.

Definition at line 76 of file crl_ent.cpp.

76 {
77 der.start_sequence().encode(serial()).encode(expire_time());
78
79 if(extensions().count() > 0) {
80 der.start_sequence().encode(extensions()).end_cons();
81 }
82
83 der.end_cons();
84}
const X509_Serial_Number & serial() const
Definition crl_ent.cpp:141
const X509_Time & expire_time() const
Definition crl_ent.cpp:145
const Extensions & extensions() const
Definition crl_ent.cpp:153

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), expire_time(), extensions(), serial(), and Botan::DER_Encoder::start_sequence().

◆ expire_time()

const X509_Time & Botan::CRL_Entry::expire_time ( ) const

Get the revocation date of the certificate associated with this entry

Returns
certificate's revocation date

Definition at line 145 of file crl_ent.cpp.

145 {
146 return data().m_time;
147}

Referenced by botan_x509_crl_entry_revocation_date(), encode_into(), and Botan::operator==().

◆ extensions()

const Extensions & Botan::CRL_Entry::extensions ( ) const

Get the extensions on this CRL entry

Definition at line 153 of file crl_ent.cpp.

153 {
154 return data().m_extensions;
155}

Referenced by encode_into().

◆ reason_code()

CRL_Code Botan::CRL_Entry::reason_code ( ) const

Get the entries reason code

Returns
reason code

Definition at line 149 of file crl_ent.cpp.

149 {
150 return data().m_reason;
151}

Referenced by botan_x509_crl_entry_reason(), and Botan::operator==().

◆ serial()

const X509_Serial_Number & Botan::CRL_Entry::serial ( ) const

Get the serial number of the certificate associated with this entry

Definition at line 141 of file crl_ent.cpp.

141 {
142 return data().m_serial;
143}

Referenced by botan_x509_crl_entry_serial_number(), encode_into(), and Botan::operator==().

◆ serial_number()

const std::vector< uint8_t > & Botan::CRL_Entry::serial_number ( ) const

Get the serial number of the certificate associated with this entry.

Note this is the absolute value; the (rare, non-conforming) negative serial numbers are indistinguishable from their positive counterpart. Prefer serial() which preserves the sign.

Returns
certificate's serial number

Definition at line 137 of file crl_ent.cpp.

137 {
138 return data().m_serial_bits;
139}

Referenced by botan_x509_crl_entry_view_serial_number().

◆ X509_CRL

friend class X509_CRL
friend

Definition at line 83 of file x509_crl.h.

References X509_CRL.

Referenced by X509_CRL.


The documentation for this class was generated from the following files: