24 typedef std::function<void(
const uint8_t[],
size_t)>
append_fn;
60 BOTAN_DEPRECATED(
"Use DER_Encoder(vector) instead") std::vector<uint8_t> get_contents_unlocked();
64 DER_Encoder& start_sequence() {
return start_cons(ASN1_Type::Sequence, ASN1_Class::Universal); }
69 return start_cons(
ASN1_Type(tag), ASN1_Class::ContextSpecific);
73 return start_cons(
ASN1_Type(tag), ASN1_Class::ExplicitContextSpecific);
84 DER_Encoder& raw_bytes(
const uint8_t val[],
size_t len);
86 template <
typename Alloc>
88 return raw_bytes(val.data(), val.size());
97 template <
typename Alloc>
99 return encode(vec.data(), vec.size(), real_type);
112 ASN1_Class class_tag = ASN1_Class::ContextSpecific);
114 template <
typename Alloc>
119 return encode(bytes.data(), bytes.size(), real_type, type_tag, class_tag);
122 template <
typename T>
124 if(value != default_value) {
130 template <
typename T>
132 for(
size_t i = 0; i != values.size(); ++i) {
170 return add_object(type_tag, class_tag, rep.data(), rep.size());
174 return add_object(type_tag, class_tag, rep.data(), rep.size());
182 class DER_Sequence
final {
184 uint32_t tag_of()
const;
188 void add_bytes(
const uint8_t val[],
size_t len);
190 void add_bytes(
const uint8_t hdr[],
size_t hdr_len,
const uint8_t val[],
size_t val_len);
194 DER_Sequence(DER_Sequence&& seq) noexcept :
195 m_type_tag(std::move(seq.m_type_tag)),
196 m_class_tag(std::move(seq.m_class_tag)),
197 m_contents(std::move(seq.m_contents)),
198 m_set_contents(std::move(seq.m_set_contents)) {}
200 DER_Sequence& operator=(DER_Sequence&& seq)
noexcept {
201 std::swap(m_type_tag, seq.m_type_tag);
202 std::swap(m_class_tag, seq.m_class_tag);
203 std::swap(m_contents, seq.m_contents);
204 std::swap(m_set_contents, seq.m_set_contents);
208 DER_Sequence(
const DER_Sequence& seq) =
default;
210 DER_Sequence& operator=(
const DER_Sequence& seq) =
default;
215 secure_vector<uint8_t> m_contents;
216 std::vector<secure_vector<uint8_t>> m_set_contents;
219 append_fn m_append_output;
220 secure_vector<uint8_t> m_default_outbuf;
221 std::vector<DER_Sequence> m_subsequences;