Botan 3.3.0
Crypto and TLS for C&
Public Member Functions | Friends | List of all members
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
 
 CRL_Entry (const X509_Certificate &cert, CRL_Code reason=CRL_Code::Unspecified)
 
void decode_from (BER_Decoder &) override
 
void encode_into (DER_Encoder &) const override
 
const X509_Timeexpire_time () const
 
const Extensionsextensions () const
 
CRL_Code reason_code () const
 
const std::vector< uint8_t > & serial_number () const
 

Friends

class X509_CRL
 

Detailed Description

This class represents CRL entries

Definition at line 28 of file x509_crl.h.

Constructor & Destructor Documentation

◆ CRL_Entry() [1/2]

Botan::CRL_Entry::CRL_Entry ( )
default

Create uninitialized CRL_Entry object

◆ 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 28 of file crl_ent.cpp.

28 {
29 m_data = std::make_shared<CRL_Entry_Data>();
30 m_data->m_serial = cert.serial_number();
31 m_data->m_time = X509_Time(std::chrono::system_clock::now());
32 m_data->m_reason = why;
33
34 if(why != CRL_Code::Unspecified) {
35 m_data->m_extensions.add(std::make_unique<Cert_Extension::CRL_ReasonCode>(why));
36 }
37}
ASN1_Time X509_Time
Definition asn1_obj.h:402

References Botan::X509_Certificate::serial_number(), and Botan::Unspecified.

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 19 of file asn1_obj.cpp.

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

References Botan::ASN1_Object::encode_into().

Referenced by Botan::PSS_Params::decode_from(), 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::Certificate_Store_In_SQL::revoke_cert().

◆ 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 78 of file crl_ent.cpp.

78 {
79 BigInt serial_number_bn;
80
81 auto data = std::make_unique<CRL_Entry_Data>();
82
83 BER_Decoder entry = source.start_sequence();
84
85 entry.decode(serial_number_bn).decode(data->m_time);
86 data->m_serial = BigInt::encode(serial_number_bn);
87
88 if(entry.more_items()) {
89 entry.decode(data->m_extensions);
90 if(auto ext = data->m_extensions.get_extension_object_as<Cert_Extension::CRL_ReasonCode>()) {
91 data->m_reason = ext->get_reason();
92 } else {
93 data->m_reason = CRL_Code::Unspecified;
94 }
95 }
96
97 entry.end_cons();
98
99 m_data = std::move(data);
100}
static std::vector< uint8_t > encode(const BigInt &n)
Definition bigint.h:749
const T * get_extension_object_as(const OID &oid=T::static_oid()) const
Definition pkix_types.h:397

References Botan::BER_Decoder::decode(), Botan::BigInt::encode(), Botan::BER_Decoder::end_cons(), Botan::Extensions::get_extension_object_as(), Botan::BER_Decoder::more_items(), 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 65 of file crl_ent.cpp.

65 {
66 der.start_sequence()
68 .encode(expire_time())
69 .start_sequence()
70 .encode(extensions())
71 .end_cons()
72 .end_cons();
73}
static BigInt decode(const uint8_t buf[], size_t length)
Definition bigint.h:772
const X509_Time & expire_time() const
Definition crl_ent.cpp:114
const std::vector< uint8_t > & serial_number() const
Definition crl_ent.cpp:110
const Extensions & extensions() const
Definition crl_ent.cpp:122

References Botan::BigInt::decode(), Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), expire_time(), extensions(), serial_number(), 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 114 of file crl_ent.cpp.

114 {
115 return data().m_time;
116}

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

◆ extensions()

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

Get the extensions on this CRL entry

Definition at line 122 of file crl_ent.cpp.

122 {
123 return data().m_extensions;
124}

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 118 of file crl_ent.cpp.

118 {
119 return data().m_reason;
120}

Referenced by 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.

Returns
certificate's serial number

Definition at line 110 of file crl_ent.cpp.

110 {
111 return data().m_serial;
112}

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

Friends And Related Symbol Documentation

◆ X509_CRL

friend class X509_CRL
friend

Definition at line 69 of file x509_crl.h.


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