Botan  2.15.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::GeneralSubtree Class Referencefinal

A single Name Constraint. More...

#include <name_constraint.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 90 of file name_constraint.h.

Constructor & Destructor Documentation

◆ GeneralSubtree() [1/3]

Botan::GeneralSubtree::GeneralSubtree ( )
inline

Creates an empty name constraint.

Definition at line 96 of file name_constraint.h.

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

◆ GeneralSubtree() [2/3]

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

Definition at line 105 of file name_constraint.h.

106  : m_base(base), m_minimum(min), m_maximum(max)
107  {}
const GeneralName & base() const

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

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

Member Function Documentation

◆ base()

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

Definition at line 122 of file name_constraint.h.

Referenced by Botan::operator<<().

122 { return m_base; }

◆ 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.

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().

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

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

References Botan::CONTEXT_SPECIFIC, Botan::BER_Decoder::decode(), Botan::BER_Decoder::decode_optional(), Botan::BER_Decoder::end_cons(), Botan::SEQUENCE, and Botan::BER_Decoder::start_cons().

256  {
257  ber.start_cons(SEQUENCE)
258  .decode(m_base)
259  .decode_optional(m_minimum,ASN1_Tag(0), CONTEXT_SPECIFIC,size_t(0))
260  .end_cons();
261 
262  if(m_minimum != 0)
263  throw Decoding_Error("GeneralSubtree minimum must be 0");
264 
265  m_maximum = std::numeric_limits<std::size_t>::max();
266  }
ASN1_Tag
Definition: asn1_obj.h:23

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

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

◆ maximum()

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

Definition at line 132 of file name_constraint.h.

Referenced by Botan::operator<<().

132 { return m_maximum; }

◆ minimum()

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

Definition at line 127 of file name_constraint.h.

Referenced by Botan::operator<<().

127 { return m_minimum; }

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