Botan::Extensions Class Reference

#include <x509_ext.h>

Inheritance diagram for Botan::Extensions:

Botan::ASN1_Object

List of all members.

Public Member Functions

void add (Certificate_Extension *extn, bool critical=false)
void contents_to (Data_Store &, Data_Store &) const
void decode_from (class BER_Decoder &)
void encode_into (class DER_Encoder &) const
 Extensions (bool st=true)
 Extensions (const Extensions &)
Extensionsoperator= (const Extensions &)
 ~Extensions ()


Detailed Description

X.509 Certificate Extension List

Definition at line 66 of file x509_ext.h.


Constructor & Destructor Documentation

Botan::Extensions::Extensions ( const Extensions extensions  ) 

Definition at line 44 of file x509_ext.cpp.

00044                                                    : ASN1_Object()
00045    {
00046    *this = extensions;
00047    }

Botan::Extensions::Extensions ( bool  st = true  )  [inline]

Definition at line 79 of file x509_ext.h.

00079 : should_throw(st) {}

Botan::Extensions::~Extensions (  ) 

Definition at line 156 of file x509_ext.cpp.

00157    {
00158    for(u32bit i = 0; i != extensions.size(); ++i)
00159       delete extensions[i].first;
00160    }


Member Function Documentation

void Botan::Extensions::add ( Certificate_Extension extn,
bool  critical = false 
)

Definition at line 74 of file x509_ext.cpp.

Referenced by Botan::X509::create_cert_req(), Botan::X509::create_self_signed_cert(), Botan::CRL_Entry::encode_into(), and Botan::X509_CA::sign_request().

00075    {
00076    extensions.push_back(std::make_pair(extn, critical));
00077    }

void Botan::Extensions::contents_to ( Data_Store subject_info,
Data_Store issuer_info 
) const

Definition at line 146 of file x509_ext.cpp.

Referenced by Botan::CRL_Entry::decode_from().

00148    {
00149    for(u32bit i = 0; i != extensions.size(); ++i)
00150       extensions[i].first->contents_to(subject_info, issuer_info);
00151    }

void Botan::Extensions::decode_from ( class BER_Decoder from  )  [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 105 of file x509_ext.cpp.

References Botan::OID::as_string(), Botan::BOOLEAN, Botan::BER_Decoder::decode(), Botan::Certificate_Extension::decode_inner(), Botan::BER_Decoder::decode_optional(), Botan::BER_Decoder::end_cons(), Botan::BER_Decoder::more_items(), Botan::OCTET_STRING, oid, Botan::SEQUENCE, Botan::BER_Decoder::start_cons(), Botan::UNIVERSAL, and Botan::BER_Decoder::verify_end().

00106    {
00107    for(u32bit i = 0; i != extensions.size(); ++i)
00108       delete extensions[i].first;
00109    extensions.clear();
00110 
00111    BER_Decoder sequence = from_source.start_cons(SEQUENCE);
00112    while(sequence.more_items())
00113       {
00114       OID oid;
00115       MemoryVector<byte> value;
00116       bool critical;
00117 
00118       sequence.start_cons(SEQUENCE)
00119             .decode(oid)
00120             .decode_optional(critical, BOOLEAN, UNIVERSAL, false)
00121             .decode(value, OCTET_STRING)
00122             .verify_end()
00123          .end_cons();
00124 
00125       Certificate_Extension* ext = get_extension(oid);
00126 
00127       if(!ext)
00128          {
00129          if(!critical || !should_throw)
00130             continue;
00131 
00132          throw Decoding_Error("Encountered unknown X.509 extension marked "
00133                               "as critical; OID = " + oid.as_string());
00134          }
00135 
00136       ext->decode_inner(value);
00137 
00138       extensions.push_back(std::make_pair(ext, critical));
00139       }
00140    sequence.verify_end();
00141    }

void Botan::Extensions::encode_into ( class DER_Encoder to  )  const [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 82 of file x509_ext.cpp.

References Botan::DER_Encoder::encode(), Botan::Certificate_Extension::encode_inner(), Botan::OCTET_STRING, Botan::Certificate_Extension::oid_of(), Botan::SEQUENCE, Botan::Certificate_Extension::should_encode(), and Botan::DER_Encoder::start_cons().

00083    {
00084    for(u32bit i = 0; i != extensions.size(); ++i)
00085       {
00086       const Certificate_Extension* ext = extensions[i].first;
00087       const bool is_critical = extensions[i].second;
00088 
00089       const bool should_encode = ext->should_encode();
00090 
00091       if(should_encode)
00092          {
00093          to_object.start_cons(SEQUENCE)
00094                .encode(ext->oid_of())
00095                .encode_optional(is_critical, false)
00096                .encode(ext->encode_inner(), OCTET_STRING)
00097             .end_cons();
00098          }
00099       }
00100    }

Extensions & Botan::Extensions::operator= ( const Extensions other  ) 

Definition at line 52 of file x509_ext.cpp.

References extensions.

00053    {
00054    for(u32bit i = 0; i != extensions.size(); ++i)
00055       delete extensions[i].first;
00056    extensions.clear();
00057 
00058    for(u32bit i = 0; i != other.extensions.size(); ++i)
00059       extensions.push_back(
00060          std::make_pair(other.extensions[i].first->copy(),
00061                         other.extensions[i].second));
00062 
00063    return (*this);
00064    }


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

Generated on Fri Aug 13 16:20:57 2010 for Botan by  doxygen 1.5.8