Botan: Botan::Extensions Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

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

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

`#include <x509_ext.h>`

Inheritance diagram for Botan::Extensions:

## 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 (const Extensions &)
| Extensions (bool st=true)
Extensions & | operator= (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 45 of file x509_ext.cpp.

45 : ASN1_Object()
46 {
47 *this = extensions;
48 }

Botan::Extensions::Extensions | ( | bool | st = `true` | ) |
| inline

Definition at line 79 of file x509_ext.h.

79 : should_throw(st) {}

Botan::Extensions::~Extensions | ( |  | ) |

Definition at line 160 of file x509_ext.cpp.

161 {
162 for(size_t i = 0; i != extensions.size(); ++i)
163 delete extensions[i].first;
164 }

## Member Function Documentation

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

Definition at line 77 of file x509_ext.cpp.

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

78 {
79 extensions.push_back(std::make_pair(extn, critical));
80 }

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

Definition at line 150 of file x509_ext.cpp.

Referenced by Botan::CRL_Entry::decode_from(), Botan::PKCS10_Request::PKCS10_Request(), Botan::X509_Certificate::X509_Certificate(), and Botan::X509_CRL::X509_CRL().

152 {
153 for(size_t i = 0; i != extensions.size(); ++i)
154 extensions[i].first->contents_to(subject_info, issuer_info);
155 }

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

109 {
110 for(size_t i = 0; i != extensions.size(); ++i)
111 delete extensions[i].first;
112 extensions.clear();
113
114 BER_Decoder sequence = from_source.start_cons(SEQUENCE);
115
116 while(sequence.more_items())
117 {
118 OID oid;
119 MemoryVector<byte> value;
120 bool critical;
121
122 sequence.start_cons(SEQUENCE)
123 .decode(oid)
124 .decode_optional(critical, BOOLEAN, UNIVERSAL, false)
125 .decode(value, OCTET_STRING)
126 .verify_end()
127 .end_cons();
128
129 Certificate_Extension* ext = get_extension(oid);
130
131 if(!ext)
132 {
133 if(!critical || !should_throw)
134 continue;
135
136 throw Decoding_Error("Encountered unknown X.509 extension marked "
137 "as critical; OID = " + oid.as_string());
138 }
139
140 ext->decode_inner(value);
141
142 extensions.push_back(std::make_pair(ext, critical));
143 }
144 sequence.verify_end();
145 }
Botan::UNIVERSAL
Definition: asn1_int.h:20
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::SEQUENCE
Definition: asn1_int.h:35
Botan::BOOLEAN
Definition: asn1_int.h:28
oid
OID oid
Definition: x509_ext.cpp:446

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

86 {
87 for(size_t i = 0; i != extensions.size(); ++i)
88 {
89 const Certificate_Extension* ext = extensions[i].first;
90 const bool is_critical = extensions[i].second;
91
92 const bool should_encode = ext->should_encode();
93
94 if(should_encode)
95 {
96 to_object.start_cons(SEQUENCE)
97 .encode(ext->oid_of())
98 .encode_optional(is_critical, false)
99 .encode(ext->encode_inner(), OCTET_STRING)
100 .end_cons();
101 }
102 }
103 }
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::SEQUENCE
Definition: asn1_int.h:35

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

Definition at line 53 of file x509_ext.cpp.

54 {
55 for(size_t i = 0; i != extensions.size(); ++i)
56 delete extensions[i].first;
57 extensions.clear();
58
59 for(size_t i = 0; i != other.extensions.size(); ++i)
60 extensions.push_back(
61 std::make_pair(other.extensions[i].first->copy(),
62 other.extensions[i].second));
63
64 should_throw = other.should_throw;
65
66 return (*this);
67 }

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

- src/cert/x509cert/x509_ext.h
- src/cert/x509cert/x509_ext.cpp