Botan  2.4.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

GeneralName base () const
 
void decode_from (BER_Decoder &) override
 
void encode_into (DER_Encoder &) const override
 
 GeneralSubtree ()
 
 GeneralSubtree (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 ( 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  {}
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 236 of file name_constraint.cpp.

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

Member Function Documentation

◆ base()

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; }

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

261  {
262  ber.start_cons(SEQUENCE)
263  .decode(m_base)
264  .decode_optional(m_minimum,ASN1_Tag(0), CONTEXT_SPECIFIC,size_t(0))
265  .end_cons();
266 
267  if(m_minimum != 0)
268  throw Decoding_Error("GeneralSubtree minimum must be 0");
269 
270  m_maximum = std::numeric_limits<std::size_t>::max();
271  }
ASN1_Tag
Definition: asn1_obj.h:22

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

256  {
257  throw Not_Implemented("General Subtree encoding");
258  }

◆ maximum()

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

Definition at line 132 of file name_constraint.h.

References Botan::operator<<().

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: