Botan 3.0.0-alpha0
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 256 of file pkix_types.h.

Constructor & Destructor Documentation

◆ GeneralSubtree() [1/3]

Botan::GeneralSubtree::GeneralSubtree ( )
inline

Creates an empty name constraint.

Definition at line 262 of file pkix_types.h.

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

◆ GeneralSubtree() [2/3]

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

Definition at line 271 of file pkix_types.h.

272 : m_base(base), m_minimum(min), m_maximum(max)
273 {}
const GeneralName & base() const
Definition: pkix_types.h:288

◆ 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 232 of file name_constraint.cpp.

233 {
234 size_t p0, p1;
235 const auto min = std::stoull(str, &p0, 10);
236 const auto max = std::stoull(str.substr(p0 + 1), &p1, 10);
237 GeneralName gn(str.substr(p0 + p1 + 2));
238
239 if(p0 > 0 && p1 > 0)
240 {
241 m_minimum = static_cast<size_t>(min);
242 m_maximum = static_cast<size_t>(max);
243 m_base = gn;
244 }
245 else
246 {
247 throw Invalid_Argument("Failed to decode Name Constraint");
248 }
249 }

Member Function Documentation

◆ base()

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

Definition at line 288 of file pkix_types.h.

288{ 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 16 of file asn1_obj.cpp.

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

References Botan::ASN1_Object::encode_into().

Referenced by Botan::PSSR::config_for_x509(), 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 256 of file name_constraint.cpp.

257 {
258 ber.start_sequence()
259 .decode(m_base)
260 .decode_optional(m_minimum, ASN1_Type(0), ASN1_Class::ContextSpecific, size_t(0))
261 .end_cons();
262
263 if(m_minimum != 0)
264 throw Decoding_Error("GeneralSubtree minimum must be 0");
265
266 m_maximum = std::numeric_limits<std::size_t>::max();
267 }
ASN1_Type
Definition: asn1_obj.h:39

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 251 of file name_constraint.cpp.

252 {
253 throw Not_Implemented("General Subtree encoding");
254 }

◆ maximum()

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

Definition at line 298 of file pkix_types.h.

298{ return m_maximum; }

Referenced by Botan::operator<<().

◆ minimum()

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

Definition at line 293 of file pkix_types.h.

293{ return m_minimum; }

Referenced by Botan::operator<<().


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