Botan 3.6.1
Crypto and TLS for C&
Botan::Cert_Extension::Name_Constraints Class Referencefinal

#include <x509_ext.h>

Inheritance diagram for Botan::Cert_Extension::Name_Constraints:
Botan::Certificate_Extension

Public Member Functions

std::unique_ptr< Certificate_Extensioncopy () const override
 
const NameConstraintsget_name_constraints () const
 
 Name_Constraints ()=default
 
 Name_Constraints (const NameConstraints &nc)
 
OID oid_of () const override
 
void validate (const X509_Certificate &subject, const X509_Certificate &issuer, const std::vector< X509_Certificate > &cert_path, std::vector< std::set< Certificate_Status_Code > > &cert_status, size_t pos) override
 

Static Public Member Functions

static OID static_oid ()
 

Detailed Description

Name Constraints

Definition at line 232 of file x509_ext.h.

Constructor & Destructor Documentation

◆ Name_Constraints() [1/2]

Botan::Cert_Extension::Name_Constraints::Name_Constraints ( )
default

◆ Name_Constraints() [2/2]

Botan::Cert_Extension::Name_Constraints::Name_Constraints ( const NameConstraints & nc)
inline

Definition at line 240 of file x509_ext.h.

240: m_name_constraints(nc) {}

Member Function Documentation

◆ copy()

std::unique_ptr< Certificate_Extension > Botan::Cert_Extension::Name_Constraints::copy ( ) const
inlineoverridevirtual

Make a copy of this extension

Returns
copy of this

Implements Botan::Certificate_Extension.

Definition at line 234 of file x509_ext.h.

234 {
235 return std::make_unique<Name_Constraints>(m_name_constraints);
236 }

◆ get_name_constraints()

const NameConstraints & Botan::Cert_Extension::Name_Constraints::get_name_constraints ( ) const
inline

Definition at line 248 of file x509_ext.h.

248{ return m_name_constraints; }

◆ oid_of()

OID Botan::Cert_Extension::Name_Constraints::oid_of ( ) const
inlineoverridevirtual
Returns
OID representing this extension

Implements Botan::Certificate_Extension.

Definition at line 252 of file x509_ext.h.

252{ return static_oid(); }

◆ static_oid()

static OID Botan::Cert_Extension::Name_Constraints::static_oid ( )
inlinestatic

Definition at line 250 of file x509_ext.h.

250{ return OID("2.5.29.30"); }

◆ validate()

void Botan::Cert_Extension::Name_Constraints::validate ( const X509_Certificate & subject,
const X509_Certificate & issuer,
const std::vector< X509_Certificate > & cert_path,
std::vector< std::set< Certificate_Status_Code > > & cert_status,
size_t pos )
overridevirtual

Reimplemented from Botan::Certificate_Extension.

Definition at line 524 of file x509_ext.cpp.

528 {
529 if(!m_name_constraints.permitted().empty() || !m_name_constraints.excluded().empty()) {
530 if(!subject.is_CA_cert()) {
531 cert_status.at(pos).insert(Certificate_Status_Code::NAME_CONSTRAINT_ERROR);
532 }
533
534 const bool issuer_name_constraint_critical = subject.is_critical("X509v3.NameConstraints");
535
536 // Check that all subordinate certs pass the name constraint
537 for(size_t j = 0; j < pos; ++j) {
538 const auto& cert = cert_path.at(j);
539
540 if(!m_name_constraints.is_permitted(cert, issuer_name_constraint_critical)) {
541 cert_status.at(j).insert(Certificate_Status_Code::NAME_CONSTRAINT_ERROR);
542 continue;
543 }
544
545 if(m_name_constraints.is_excluded(cert, issuer_name_constraint_critical)) {
546 cert_status.at(j).insert(Certificate_Status_Code::NAME_CONSTRAINT_ERROR);
547 continue;
548 }
549 }
550 }
551}
bool is_permitted(const X509_Certificate &cert, bool reject_unknown) const
bool is_excluded(const X509_Certificate &cert, bool reject_unknown) const
const std::vector< GeneralSubtree > & permitted() const
Definition pkix_types.h:376
const std::vector< GeneralSubtree > & excluded() const
Definition pkix_types.h:383

References Botan::NameConstraints::excluded(), Botan::X509_Certificate::is_CA_cert(), Botan::X509_Certificate::is_critical(), Botan::NameConstraints::is_excluded(), Botan::NameConstraints::is_permitted(), Botan::NAME_CONSTRAINT_ERROR, and Botan::NameConstraints::permitted().


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