Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::GeneralSubtree Class Referencefinal

A single Name Constraint. More...

#include <pkix_types.h>

Inheritance diagram for Botan::GeneralSubtree:
Botan::ASN1_Object

Public Member Functions

const GeneralNamebase () const
 
std::vector< uint8_t > BER_encode () const
 
void decode_from (BER_Decoder &) override
 
void encode_into (DER_Encoder &) const override
 
 GeneralSubtree ()
 
 GeneralSubtree (const GeneralName &base, size_t min, size_t max)
 
 GeneralSubtree (const std::string &str)
 
size_t maximum () const
 
size_t minimum () const
 

Detailed Description

A single Name Constraint.

The Name Constraint extension adds a minimum and maximum path length to a GeneralName to form a constraint. The length limits are currently unused.

Definition at line 241 of file pkix_types.h.

Constructor & Destructor Documentation

◆ GeneralSubtree() [1/3]

Botan::GeneralSubtree::GeneralSubtree ( )
inline

Creates an empty name constraint.

Definition at line 246 of file pkix_types.h.

246: m_base(), m_minimum(0), m_maximum(std::numeric_limits<std::size_t>::max()) {}

◆ GeneralSubtree() [2/3]

Botan::GeneralSubtree::GeneralSubtree ( const GeneralName & base,
size_t min,
size_t max )
inline

Definition at line 254 of file pkix_types.h.

254: m_base(base), m_minimum(min), m_maximum(max) {}
const GeneralName & base() const
Definition pkix_types.h:269

◆ GeneralSubtree() [3/3]

Botan::GeneralSubtree::GeneralSubtree ( const std::string & str)

Creates a new name constraint for its string format.

Parameters
strname constraint

Definition at line 185 of file name_constraint.cpp.

185 : GeneralSubtree() {
186 size_t p0, p1;
187 const auto min = std::stoull(str, &p0, 10);
188 const auto max = std::stoull(str.substr(p0 + 1), &p1, 10);
189 GeneralName gn(str.substr(p0 + p1 + 2));
190
191 if(p0 > 0 && p1 > 0) {
192 m_minimum = static_cast<size_t>(min);
193 m_maximum = static_cast<size_t>(max);
194 m_base = gn;
195 } else {
196 throw Invalid_Argument("Failed to decode Name Constraint");
197 }
198}

Member Function Documentation

◆ base()

const GeneralName & Botan::GeneralSubtree::base ( ) const
inline
Returns
name

Definition at line 269 of file pkix_types.h.

269{ return m_base; }

Referenced by Botan::operator<<().

◆ 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::GeneralSubtree::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 204 of file name_constraint.cpp.

204 {
205 ber.start_sequence()
206 .decode(m_base)
207 .decode_optional(m_minimum, ASN1_Type(0), ASN1_Class::ContextSpecific, size_t(0))
208 .end_cons();
209
210 if(m_minimum != 0) {
211 throw Decoding_Error("GeneralSubtree minimum must be 0");
212 }
213
214 m_maximum = std::numeric_limits<std::size_t>::max();
215}
ASN1_Type
Definition asn1_obj.h:43

References Botan::ContextSpecific, Botan::BER_Decoder::decode(), Botan::BER_Decoder::decode_optional(), Botan::BER_Decoder::end_cons(), and Botan::BER_Decoder::start_sequence().

◆ encode_into()

void Botan::GeneralSubtree::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 200 of file name_constraint.cpp.

200 {
201 throw Not_Implemented("General Subtree encoding");
202}

◆ maximum()

size_t Botan::GeneralSubtree::maximum ( ) const
inline
Returns
maximum path length

Definition at line 279 of file pkix_types.h.

279{ return m_maximum; }

Referenced by Botan::operator<<().

◆ minimum()

size_t Botan::GeneralSubtree::minimum ( ) const
inline
Returns
minimum path length

Definition at line 274 of file pkix_types.h.

274{ return m_minimum; }

Referenced by Botan::operator<<().


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