Botan 3.12.0
Crypto and TLS for C&
Botan::OCSP::SingleResponse Class Referencefinal

#include <ocsp.h>

Inheritance diagram for Botan::OCSP::SingleResponse:
Botan::ASN1_Object

Public Member Functions

std::vector< uint8_t > BER_encode () const
size_t cert_status () const
const CertIDcertid () const
void decode_from (BER_Decoder &from) override
void encode_into (DER_Encoder &to) const override
bool has_unknown_critical_extension () const
const X509_Timenext_update () const
const X509_Timethis_update () const

Detailed Description

Definition at line 48 of file ocsp.h.

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

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

References encode_into().

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

◆ cert_status()

size_t Botan::OCSP::SingleResponse::cert_status ( ) const
inline

Definition at line 52 of file ocsp.h.

52{ return m_cert_status; }

Referenced by decode_from().

◆ certid()

const CertID & Botan::OCSP::SingleResponse::certid ( ) const
inline

Definition at line 50 of file ocsp.h.

50{ return m_certid; }

◆ decode_from()

void Botan::OCSP::SingleResponse::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 102 of file ocsp.cpp.

102 {
103 /*
104 * RFC 6960 Section 4.2.1
105 *
106 * SingleResponse ::= SEQUENCE {
107 * certID CertID,
108 * certStatus CertStatus,
109 * thisUpdate GeneralizedTime,
110 * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
111 * singleExtensions [1] EXPLICIT Extensions OPTIONAL }
112 *
113 * CertStatus ::= CHOICE {
114 * good [0] IMPLICIT NULL,
115 * revoked [1] IMPLICIT RevokedInfo,
116 * unknown [2] IMPLICIT UnknownInfo }
117 *
118 * RevokedInfo ::= SEQUENCE {
119 * revocationTime GeneralizedTime,
120 * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
121 */
122 BER_Object cert_status;
123 Extensions extensions;
124
125 from.start_sequence()
126 .decode(m_certid)
127 .get_next(cert_status)
128 .decode(m_thisupdate)
129 .decode_optional(m_nextupdate, ASN1_Type(0), ASN1_Class::ContextSpecific | ASN1_Class::Constructed)
130 .decode_optional(extensions, ASN1_Type(1), ASN1_Class::ContextSpecific | ASN1_Class::Constructed)
131 .end_cons();
132
133 const auto cert_status_class = cert_status.get_class();
134 if(cert_status_class != ASN1_Class::ContextSpecific &&
135 cert_status_class != (ASN1_Class::ContextSpecific | ASN1_Class::Constructed)) {
136 throw Decoding_Error("OCSP::SingleResponse: certStatus has unexpected class tag");
137 }
138
139 // TODO: should verify the cert_status body and decode RevokedInfo
140 m_cert_status = static_cast<uint32_t>(cert_status.type());
141 if(m_cert_status > 2) {
142 throw Decoding_Error("Unknown OCSP CertStatus tag");
143 }
144
145 // We don't currently recognize any extensions here so if any are critical we should reject
146 m_has_unknown_critical_ext = !extensions.critical_extensions().empty();
147}
size_t cert_status() const
Definition ocsp.h:52
ASN1_Type
Definition asn1_obj.h:43

References cert_status(), Botan::Constructed, Botan::ContextSpecific, Botan::Extensions::critical_extensions(), Botan::BER_Decoder::decode(), Botan::BER_Decoder::decode_optional(), Botan::BER_Decoder::end_cons(), Botan::BER_Decoder::get_next(), and Botan::BER_Decoder::start_sequence().

◆ encode_into()

void Botan::OCSP::SingleResponse::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 98 of file ocsp.cpp.

98 {
99 throw Not_Implemented("SingleResponse::encode_into");
100}

◆ has_unknown_critical_extension()

bool Botan::OCSP::SingleResponse::has_unknown_critical_extension ( ) const
inline

Definition at line 62 of file ocsp.h.

62{ return m_has_unknown_critical_ext; }

◆ next_update()

const X509_Time & Botan::OCSP::SingleResponse::next_update ( ) const
inline

Definition at line 56 of file ocsp.h.

56{ return m_nextupdate; }

◆ this_update()

const X509_Time & Botan::OCSP::SingleResponse::this_update ( ) const
inline

Definition at line 54 of file ocsp.h.

54{ return m_thisupdate; }

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