/usr/include/botan-2/botan/der_enc.h is in libbotan-2-dev 2.4.0-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | /*
* DER Encoder
* (C) 1999-2007 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_DER_ENCODER_H_
#define BOTAN_DER_ENCODER_H_
#include <botan/asn1_obj.h>
#include <vector>
namespace Botan {
class BigInt;
class ASN1_Object;
/**
* General DER Encoding Object
*/
class BOTAN_PUBLIC_API(2,0) DER_Encoder final
{
public:
secure_vector<uint8_t> get_contents();
std::vector<uint8_t> get_contents_unlocked()
{ return unlock(get_contents()); }
DER_Encoder& start_cons(ASN1_Tag type_tag,
ASN1_Tag class_tag = UNIVERSAL);
DER_Encoder& end_cons();
DER_Encoder& start_explicit(uint16_t type_tag);
DER_Encoder& end_explicit();
/**
* Insert raw bytes directly into the output stream
*/
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)
{
return raw_bytes(val.data(), val.size());
}
DER_Encoder& encode_null();
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)
{
return encode(vec.data(), vec.size(), 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 std::vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
DER_Encoder& encode(const secure_vector<uint8_t>& v,
ASN1_Tag real_type,
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 T>
DER_Encoder& encode_optional(const T& value, const T& default_value)
{
if(value != default_value)
encode(value);
return (*this);
}
template<typename T>
DER_Encoder& encode_list(const std::vector<T>& values)
{
for(size_t i = 0; i != values.size(); ++i)
encode(values[i]);
return (*this);
}
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);
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)
{
return add_object(type_tag, class_tag, rep.data(), rep.size());
}
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
const secure_vector<uint8_t>& rep)
{
return add_object(type_tag, class_tag, rep.data(), rep.size());
}
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);
private:
class DER_Sequence final
{
public:
ASN1_Tag tag_of() const;
secure_vector<uint8_t> get_contents();
void add_bytes(const uint8_t[], size_t);
DER_Sequence(ASN1_Tag, ASN1_Tag);
private:
ASN1_Tag m_type_tag, m_class_tag;
secure_vector<uint8_t> m_contents;
std::vector< secure_vector<uint8_t> > m_set_contents;
};
secure_vector<uint8_t> m_contents;
std::vector<DER_Sequence> m_subsequences;
};
}
#endif
|