Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

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

Classes | Public Types | Public Member Functions | List of all members
Botan::DER_Encoder Class Referencefinal

`#include <der_enc.h>`

## Public Types
typedef std::function< void(const uint8_t[], size_t)> | append_fn

## Public Member Functions
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const std::vector< uint8_t > &rep)
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const secure_vector< uint8_t > &rep)
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, const std::string &str)
DER_Encoder & | add_object (ASN1_Tag type_tag, ASN1_Tag class_tag, uint8_t val)
| DER_Encoder ()=default
| DER_Encoder (secure_vector< uint8_t > &vec)
| DER_Encoder (std::vector< uint8_t > &vec)
| DER_Encoder (append_fn append)
DER_Encoder & | encode (bool b)
DER_Encoder & | encode (size_t s)
DER_Encoder & | encode (const BigInt &n)
DER_Encoder & | encode (const uint8_t val[], size_t len, ASN1_Tag real_type)
template<typename Alloc >
DER_Encoder & | encode (const std::vector< uint8_t, Alloc > &vec, ASN1_Tag real_type)
DER_Encoder & | encode (bool b, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC)
DER_Encoder & | encode (size_t s, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC)
DER_Encoder & | encode (const BigInt &n, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC)
DER_Encoder & | encode (const uint8_t v[], size_t len, ASN1_Tag real_type, ASN1_Tag type_tag, ASN1_Tag class_tag=CONTEXT_SPECIFIC)
template<typename Alloc >
DER_Encoder & | encode (const std::vector< uint8_t, Alloc > &bytes, ASN1_Tag real_type, ASN1_Tag type_tag, ASN1_Tag class_tag)
DER_Encoder & | encode (const ASN1_Object &obj)
DER_Encoder & | encode_if (bool pred, DER_Encoder &enc)
DER_Encoder & | encode_if (bool pred, const ASN1_Object &obj)
template<typename T >
DER_Encoder & | encode_list (const std::vector< T > &values)
DER_Encoder & | encode_null ()
template<typename T >
DER_Encoder & | encode_optional (const T &value, const T &default_value)
DER_Encoder & | end_cons ()
DER_Encoder & | end_explicit ()
secure_vector< uint8_t > | get_contents ()
std::vector< uint8_t > | get_contents_unlocked ()
DER_Encoder & | raw_bytes (const uint8_t val[], size_t len)
template<typename Alloc >
DER_Encoder & | raw_bytes (const std::vector< uint8_t, Alloc > &val)
DER_Encoder & | start_cons (ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
DER_Encoder & | start_explicit (uint16_t type_tag)

## Detailed Description

General DER Encoding Object

Definition at line 23 of file der_enc.h.

## Member Typedef Documentation

typedef std::function<void (const uint8_t[], size_t)> Botan::DER_Encoder::append_fn

Definition at line 26 of file der_enc.h.

## Constructor & Destructor Documentation

Botan::DER_Encoder::DER_Encoder | ( |  | ) |
| default

DER encode, writing to an internal buffer Use get_contents or get_contents_unlocked to read the results after all encoding is completed.

Botan::DER_Encoder::DER_Encoder | ( | secure_vector< uint8_t > & | vec | ) |

DER encode, writing to

Parameters

  vec | If this constructor is used, get_contents* may not be called.

Definition at line 69 of file der_enc.cpp.

70 {
71 m_append_output = [&vec](const uint8_t b[], size_t l)
72 {
73 vec.insert(vec.end(), b, b + l);
74 };
75 }

Botan::DER_Encoder::DER_Encoder | ( | std::vector< uint8_t > & | vec | ) |

DER encode, writing to

Parameters

  vec | If this constructor is used, get_contents* may not be called.

Definition at line 77 of file der_enc.cpp.

78 {
79 m_append_output = [&vec](const uint8_t b[], size_t l)
80 {
81 vec.insert(vec.end(), b, b + l);
82 };
83 }

Botan::DER_Encoder::DER_Encoder | ( | append_fn | append | ) |
| inline

DER encode, calling append to write output If this constructor is used, get_contents* may not be called.

Definition at line 51 of file der_enc.h.

51 : m_append_output(append) {}

## Member Function Documentation

DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag,
|  | const uint8_t | rep[],
|  | size_t | length
| ) |  |

Definition at line 249 of file der_enc.cpp.

Referenced by add_object(), encode(), Botan::ASN1_String::encode_into(), Botan::X509_Time::encode_into(), Botan::OID::encode_into(), and encode_null().

251 {
252 std::vector<uint8_t> hdr;
253 encode_tag(hdr, type_tag, class_tag);
254 encode_length(hdr, length);
255
256 if(m_subsequences.size())
257 {
258 m_subsequences[m_subsequences.size()-1].add_bytes(hdr.data(), hdr.size(), rep, length);
259 }
260 else if(m_append_output)
261 {
262 m_append_output(hdr.data(), hdr.size());
263 m_append_output(rep, length);
264 }
265 else
266 {
267 m_default_outbuf += hdr;
268 m_default_outbuf += std::make_pair(rep, length);
269 }
270
271 return (*this);
272 }

DER_Encoder& Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag,
|  | const std::vector< uint8_t > & | rep
| ) |  |
| inline

Definition at line 161 of file der_enc.h.

163 {
164 return add_object(type_tag, class_tag, rep.data(), rep.size());
165 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249

DER_Encoder& Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag,
|  | const secure_vector< uint8_t > & | rep
| ) |  |
| inline

Definition at line 167 of file der_enc.h.

169 {
170 return add_object(type_tag, class_tag, rep.data(), rep.size());
171 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249

DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag,
|  | const std::string & | str
| ) |  |

Definition at line 388 of file der_enc.cpp.

References add_object(), and Botan::cast_char_ptr_to_uint8().

390 {
391 const uint8_t* rep = cast_char_ptr_to_uint8(rep_str.data());
392 const size_t rep_len = rep_str.size();
393 return add_object(type_tag, class_tag, rep, rep_len);
394 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249
Botan::cast_char_ptr_to_uint8
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition: mem_ops.h:189

DER_Encoder & Botan::DER_Encoder::add_object | ( | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag,
|  | uint8_t | val
| ) |  |

Definition at line 399 of file der_enc.cpp.

References add_object().

401 {
402 return add_object(type_tag, class_tag, &rep, 1);
403 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249

DER_Encoder & Botan::DER_Encoder::encode | ( | bool | b | ) |

Definition at line 285 of file der_enc.cpp.

References Botan::BOOLEAN, and Botan::UNIVERSAL.

Referenced by Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::OCSP::Request::BER_encode(), Botan::PKCS8::BER_encode(), Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), Botan::PKCS8::BER_encode_encrypted_pbkdf_msec(), Botan::PSSR::config_for_x509(), Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), Botan::EC_Group::DER_encode(), Botan::DL_Group::DER_encode(), encode(), Botan::Attribute::encode_into(), Botan::AlternativeName::encode_into(), Botan::AlgorithmIdentifier::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::X509_DN::encode_into(), Botan::CRL_Entry::encode_into(), Botan::X509_Object::encode_into(), Botan::Extensions::encode_into(), Botan::X509_Object::make_signed(), Botan::Ed25519_PrivateKey::private_key_bits(), Botan::Curve25519_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::DL_Scheme_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::EC_PrivateKey::private_key_bits(), Botan::XMSS_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), Botan::DL_Scheme_PublicKey::public_key_bits(), Botan::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::GOST_3410_PublicKey::public_key_bits(), Botan::TPM_PrivateKey::public_key_bits(), Botan::XMSS_PublicKey::public_key_bits(), and Botan::Public_Key::subject_public_key().

286 {
287 return encode(is_true, BOOLEAN, UNIVERSAL);
288 }
Botan::BOOLEAN
Definition: asn1_obj.h:33
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285
Botan::UNIVERSAL
Definition: asn1_obj.h:24

DER_Encoder & Botan::DER_Encoder::encode | ( | size_t | s | ) |

Definition at line 293 of file der_enc.cpp.

References encode(), Botan::INTEGER, and Botan::UNIVERSAL.

294 {
295 return encode(BigInt(n), INTEGER, UNIVERSAL);
296 }
Botan::INTEGER
Definition: asn1_obj.h:34
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285
Botan::UNIVERSAL
Definition: asn1_obj.h:24

DER_Encoder & Botan::DER_Encoder::encode | ( | const BigInt & | n | ) |

Definition at line 301 of file der_enc.cpp.

References encode(), Botan::INTEGER, and Botan::UNIVERSAL.

302 {
303 return encode(n, INTEGER, UNIVERSAL);
304 }
Botan::INTEGER
Definition: asn1_obj.h:34
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285
Botan::UNIVERSAL
Definition: asn1_obj.h:24

DER_Encoder & Botan::DER_Encoder::encode | ( | const uint8_t | val[],
|  | size_t | len,
|  | ASN1_Tag | real_type
| ) |  |

Definition at line 309 of file der_enc.cpp.

References encode(), and Botan::UNIVERSAL.

311 {
312 return encode(bytes, length, real_type, real_type, UNIVERSAL);
313 }
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285
Botan::UNIVERSAL
Definition: asn1_obj.h:24
template<typename Alloc >

DER_Encoder& Botan::DER_Encoder::encode | ( | const std::vector< uint8_t, Alloc > & | vec,
|  | ASN1_Tag | real_type
| ) |  |
| inline

Definition at line 89 of file der_enc.h.

References Botan::PEM_Code::encode().

90 {
91 return encode(vec.data(), vec.size(), real_type);
92 }
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285

DER_Encoder & Botan::DER_Encoder::encode | ( | bool | b,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 318 of file der_enc.cpp.

References add_object().

320 {
321 uint8_t val = is_true ? 0xFF : 0x00;
322 return add_object(type_tag, class_tag, &val, 1);
323 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249

DER_Encoder & Botan::DER_Encoder::encode | ( | size_t | s,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 328 of file der_enc.cpp.

References encode().

330 {
331 return encode(BigInt(n), type_tag, class_tag);
332 }
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285

DER_Encoder & Botan::DER_Encoder::encode | ( | const BigInt & | n,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 337 of file der_enc.cpp.

References add_object(), Botan::BigInt::binary_encode(), Botan::BigInt::bits(), and Botan::BigInt::bytes().

339 {
340 if(n == 0)
341 return add_object(type_tag, class_tag, 0);
342
343 const size_t extra_zero = (n.bits() % 8 == 0) ? 1 : 0;
344 secure_vector<uint8_t> contents(extra_zero + n.bytes());
345 n.binary_encode(&contents[extra_zero]);
346 if(n < 0)
347 {
348 for(size_t i = 0; i != contents.size(); ++i)
349 contents[i] = ~contents[i];
350 for(size_t i = contents.size(); i > 0; --i)
351 if(++contents[i-1])
352 break;
353 }
354
355 return add_object(type_tag, class_tag, contents);
356 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249

DER_Encoder & Botan::DER_Encoder::encode | ( | const uint8_t | v[],
|  | size_t | len,
|  | ASN1_Tag | real_type,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `CONTEXT_SPECIFIC`
| ) |  |

Definition at line 361 of file der_enc.cpp.

References add_object(), Botan::BIT_STRING, and Botan::OCTET_STRING.

364 {
365 if(real_type != OCTET_STRING && real_type != BIT_STRING)
366 throw Invalid_Argument("DER_Encoder: Invalid tag for byte/bit string");
367
368 if(real_type == BIT_STRING)
369 {
370 secure_vector<uint8_t> encoded;
371 encoded.push_back(0);
372 encoded += std::make_pair(bytes, length);
373 return add_object(type_tag, class_tag, encoded);
374 }
375 else
376 return add_object(type_tag, class_tag, bytes, length);
377 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249
Botan::OCTET_STRING
Definition: asn1_obj.h:36
Botan::BIT_STRING
Definition: asn1_obj.h:35
template<typename Alloc >

DER_Encoder& Botan::DER_Encoder::encode | ( | const std::vector< uint8_t, Alloc > & | bytes,
|  | ASN1_Tag | real_type,
|  | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag
| ) |  |
| inline

Definition at line 112 of file der_enc.h.

References Botan::PEM_Code::encode().

115 {
116 return encode(bytes.data(), bytes.size(),
117 real_type, type_tag, class_tag);
118 }
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285

DER_Encoder & Botan::DER_Encoder::encode | ( | const ASN1_Object & | obj | ) |

Definition at line 379 of file der_enc.cpp.

References Botan::ASN1_Object::encode_into().

380 {
381 obj.encode_into(*this);
382 return (*this);
383 }

DER_Encoder& Botan::DER_Encoder::encode_if | ( | bool | pred,
|  | DER_Encoder & | enc
| ) |  |
| inline

Definition at line 144 of file der_enc.h.

References get_contents().

145 {
146 if(pred)
147 return raw_bytes(enc.get_contents());
148 return (*this);
149 }
Botan::DER_Encoder::raw_bytes
DER_Encoder & raw_bytes(const uint8_t val[], size_t len)
Definition: der_enc.cpp:228

DER_Encoder& Botan::DER_Encoder::encode_if | ( | bool | pred,
|  | const ASN1_Object & | obj
| ) |  |
| inline

Definition at line 151 of file der_enc.h.

References Botan::PEM_Code::encode().

152 {
153 if(pred)
154 encode(obj);
155 return (*this);
156 }
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285
template<typename T >

DER_Encoder& Botan::DER_Encoder::encode_list | ( | const std::vector< T > & | values | ) |
| inline

Definition at line 129 of file der_enc.h.

References Botan::PEM_Code::encode().

130 {
131 for(size_t i = 0; i != values.size(); ++i)
132 encode(values[i]);
133 return (*this);
134 }
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285

DER_Encoder & Botan::DER_Encoder::encode_null | ( |  | ) |

Definition at line 277 of file der_enc.cpp.

References add_object(), Botan::NULL_TAG, and Botan::UNIVERSAL.

Referenced by Botan::EC_Group::DER_encode().

278 {
279 return add_object(NULL_TAG, UNIVERSAL, nullptr, 0);
280 }
Botan::DER_Encoder::add_object
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
Definition: der_enc.cpp:249
Botan::UNIVERSAL
Definition: asn1_obj.h:24
Botan::NULL_TAG
Definition: asn1_obj.h:37
template<typename T >

DER_Encoder& Botan::DER_Encoder::encode_optional | ( | const T & | value,
|  | const T & | default_value
| ) |  |
| inline

Definition at line 121 of file der_enc.h.

References Botan::PEM_Code::encode().

Referenced by Botan::Extensions::encode_into().

122 {
123 if(value != default_value)
124 encode(value);
125 return (*this);
126 }
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:285

DER_Encoder & Botan::DER_Encoder::end_cons | ( |  | ) |

Definition at line 191 of file der_enc.cpp.

Referenced by Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::OCSP::Request::BER_encode(), Botan::PKCS8::BER_encode(), Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), Botan::PKCS8::BER_encode_encrypted_pbkdf_msec(), Botan::PSSR::config_for_x509(), Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), Botan::EC_Group::DER_encode(), Botan::DL_Group::DER_encode(), Botan::Attribute::encode_into(), Botan::AlternativeName::encode_into(), Botan::AlgorithmIdentifier::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::X509_DN::encode_into(), Botan::CRL_Entry::encode_into(), Botan::X509_Object::encode_into(), Botan::Extensions::encode_into(), end_explicit(), Botan::X509_Object::make_signed(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::EC_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), Botan::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::TPM_PrivateKey::public_key_bits(), Botan::ASN1::put_in_sequence(), and Botan::Public_Key::subject_public_key().

192 {
193 if(m_subsequences.empty())
194 throw Invalid_State("DER_Encoder::end_cons: No such sequence");
195
196 DER_Sequence last_seq = std::move(m_subsequences[m_subsequences.size()-1]);
197 m_subsequences.pop_back();
198 last_seq.push_contents(*this);
199
200 return (*this);
201 }

DER_Encoder & Botan::DER_Encoder::end_explicit | ( |  | ) |

Definition at line 220 of file der_enc.cpp.

References end_cons().

Referenced by Botan::OCSP::Request::BER_encode(), Botan::PKCS10_Request::create(), and Botan::AlternativeName::encode_into().

221 {
222 return end_cons();
223 }
Botan::DER_Encoder::end_cons
DER_Encoder & end_cons()
Definition: der_enc.cpp:191

secure_vector< uint8_t > Botan::DER_Encoder::get_contents | ( |  | ) |

Definition at line 152 of file der_enc.cpp.

Referenced by Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), encode_if(), Botan::Ed25519_PrivateKey::private_key_bits(), Botan::Curve25519_PrivateKey::private_key_bits(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::DL_Scheme_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::EC_PrivateKey::private_key_bits(), Botan::XMSS_PrivateKey::private_key_bits(), and Botan::Private_Key::private_key_info().

153 {
154 if(m_subsequences.size() != 0)
155 throw Invalid_State("DER_Encoder: Sequence hasn't been marked done");
156
157 if(m_append_output)
158 throw Invalid_State("DER_Encoder Cannot get contents when using output vector");
159
160 secure_vector<uint8_t> output;
161 std::swap(output, m_default_outbuf);
162 return output;
163 }

std::vector< uint8_t > Botan::DER_Encoder::get_contents_unlocked | ( |  | ) |

Return the encoded contents as a std::vector

If using this function, instead pass a std::vector to the contructor of DER_Encoder where the output will be placed. This avoids several unecessary copies.

Definition at line 165 of file der_enc.cpp.

166 {
167 if(m_subsequences.size() != 0)
168 throw Invalid_State("DER_Encoder: Sequence hasn't been marked done");
169
170 if(m_append_output)
171 throw Invalid_State("DER_Encoder Cannot get contents when using output vector");
172
173 std::vector<uint8_t> output(m_default_outbuf.begin(), m_default_outbuf.end());
174 m_default_outbuf.clear();
175 return output;
176 }

DER_Encoder & Botan::DER_Encoder::raw_bytes | ( | const uint8_t | val[],
|  | size_t | len
| ) |  |

Insert raw bytes directly into the output stream

Definition at line 228 of file der_enc.cpp.

Referenced by Botan::PKCS10_Request::create(), Botan::Attribute::encode_into(), Botan::AlgorithmIdentifier::encode_into(), Botan::X509_DN::encode_into(), Botan::X509_Object::encode_into(), Botan::X509_Object::make_signed(), and Botan::ASN1::put_in_sequence().

229 {
230 if(m_subsequences.size())
231 {
232 m_subsequences[m_subsequences.size()-1].add_bytes(bytes, length);
233 }
234 else if(m_append_output)
235 {
236 m_append_output(bytes, length);
237 }
238 else
239 {
240 m_default_outbuf += std::make_pair(bytes, length);
241 }
242
243 return (*this);
244 }
template<typename Alloc >

DER_Encoder& Botan::DER_Encoder::raw_bytes | ( | const std::vector< uint8_t, Alloc > & | val | ) |
| inline

Definition at line 77 of file der_enc.h.

78 {
79 return raw_bytes(val.data(), val.size());
80 }
Botan::DER_Encoder::raw_bytes
DER_Encoder & raw_bytes(const uint8_t val[], size_t len)
Definition: der_enc.cpp:228

DER_Encoder & Botan::DER_Encoder::start_cons | ( | ASN1_Tag | type_tag,
|  | ASN1_Tag | class_tag = `UNIVERSAL`
| ) |  |

Definition at line 181 of file der_enc.cpp.

Referenced by Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::OCSP::Request::BER_encode(), Botan::PKCS8::BER_encode(), Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), Botan::PKCS8::BER_encode_encrypted_pbkdf_msec(), Botan::PSSR::config_for_x509(), Botan::PKCS10_Request::create(), Botan::TLS::Session::DER_encode(), Botan::EC_Group::DER_encode(), Botan::DL_Group::DER_encode(), Botan::Attribute::encode_into(), Botan::AlternativeName::encode_into(), Botan::AlgorithmIdentifier::encode_into(), Botan::OCSP::CertID::encode_into(), Botan::X509_DN::encode_into(), Botan::CRL_Entry::encode_into(), Botan::X509_Object::encode_into(), Botan::Extensions::encode_into(), Botan::X509_Object::make_signed(), Botan::McEliece_PrivateKey::private_key_bits(), Botan::RSA_PrivateKey::private_key_bits(), Botan::EC_PrivateKey::private_key_bits(), Botan::Private_Key::private_key_info(), Botan::McEliece_PublicKey::public_key_bits(), Botan::RSA_PublicKey::public_key_bits(), Botan::TPM_PrivateKey::public_key_bits(), Botan::ASN1::put_in_sequence(), start_explicit(), and Botan::Public_Key::subject_public_key().

183 {
184 m_subsequences.push_back(DER_Sequence(type_tag, class_tag));
185 return (*this);
186 }

DER_Encoder & Botan::DER_Encoder::start_explicit | ( | uint16_t | type_tag | ) |

Definition at line 206 of file der_enc.cpp.

References Botan::CONTEXT_SPECIFIC, Botan::SET, and start_cons().

Referenced by Botan::OCSP::Request::BER_encode(), and Botan::AlternativeName::encode_into().

207 {
208 ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
209
210 // This would confuse DER_Sequence
211 if(type_tag == SET)
212 throw Internal_Error("DER_Encoder.start_explicit(SET) not supported");
213
214 return start_cons(type_tag, CONTEXT_SPECIFIC);
215 }
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_obj.h:23
Botan::SET
Definition: asn1_obj.h:41
Botan::DER_Encoder::start_cons
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
Definition: der_enc.cpp:181
Botan::CONTEXT_SPECIFIC
Definition: asn1_obj.h:26
Botan::OCSP::Response_Status_Code::Internal_Error

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

- src/lib/asn1/der_enc.h
- src/lib/asn1/der_enc.cpp