Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::GeneralSubtree Class Reference

A single Name Constraint. More...

`#include <name_constraint.h>`

Inheritance diagram for Botan::GeneralSubtree:

## Public Member Functions
GeneralName | base () const
void | decode_from (class BER_Decoder &) override
void | encode_into (class 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 87 of file name_constraint.h.

## Constructor & Destructor Documentation

Botan::GeneralSubtree::GeneralSubtree | ( |  | ) |
| inline

Creates an empty name constraint.

Definition at line 93 of file name_constraint.h.

93 : m_base(), m_minimum(0), m_maximum(std::numeric_limits<std::size_t>::max())
94 {}
Botan::CT::max
T max(T a, T b)
Definition: ct_utils.h:173

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

Definition at line 102 of file name_constraint.h.

103 : m_base(base), m_minimum(min), m_maximum(max)
104 {}
Botan::CT::max
T max(T a, T b)
Definition: ct_utils.h:173
Botan::GeneralSubtree::base
GeneralName base() const
Definition: name_constraint.h:119
Botan::CT::min
T min(T a, T b)
Definition: ct_utils.h:180

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

Creates a new name constraint for its string format.

Parameters

  str | name constraint

Definition at line 231 of file name_constraint.cpp.

References Botan::CT::max(), and Botan::CT::min().

231 : GeneralSubtree()
232 {
233 size_t p0, p1;
234 size_t min = std::stoull(str, &p0, 10);
235 size_t 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 = min;
241 m_maximum = max;
242 m_base = gn;
243 }
244 else
245 {
246 throw Invalid_Argument("Failed to decode Name Constraint");
247 }
248 }
Botan::CT::max
T max(T a, T b)
Definition: ct_utils.h:173
Botan::GeneralSubtree::GeneralSubtree
GeneralSubtree()
Definition: name_constraint.h:93
Botan::CT::min
T min(T a, T b)
Definition: ct_utils.h:180

## Member Function Documentation

GeneralName Botan::GeneralSubtree::base | ( |  | ) | const
| inline

Returns
  name

Definition at line 119 of file name_constraint.h.

Referenced by Botan::operator<<().

119 { return m_base; }

void Botan::GeneralSubtree::decode_from | ( | class BER_Decoder & | from | ) |
| override virtual

Decode whatever this object is from from

Parameters

  from | the 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::CT::max(), 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 }
Botan::CONTEXT_SPECIFIC
Definition: asn1_obj.h:25
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_obj.h:22
Botan::SEQUENCE
Definition: asn1_obj.h:39
Botan::CT::max
T max(T a, T b)
Definition: ct_utils.h:173

void Botan::GeneralSubtree::encode_into | ( | class DER_Encoder & | to | ) | const
| override virtual

Encode whatever this object is into to

Parameters

  to | the 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 }

size_t Botan::GeneralSubtree::maximum | ( |  | ) | const
| inline

Returns
  maximum path length

Definition at line 129 of file name_constraint.h.

Referenced by Botan::operator<<().

129 { return m_maximum; }

size_t Botan::GeneralSubtree::minimum | ( |  | ) | const
| inline

Returns
  minimum path length

Definition at line 124 of file name_constraint.h.

Referenced by Botan::operator<<().

124 { return m_minimum; }

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

- src/lib/x509/name_constraint.h
- src/lib/x509/name_constraint.cpp