7 #ifndef BOTAN_ASN1_OBJECT_TYPES_H_
8 #define BOTAN_ASN1_OBJECT_TYPES_H_
10 #include <botan/secmem.h>
11 #include <botan/exceptn.h>
75 virtual void encode_into(
DER_Encoder& to)
const = 0;
119 const uint8_t*
bits()
const {
return value.data(); }
121 size_t length()
const {
return value.size(); }
124 const std::string& descr =
"object")
const;
128 bool is_a(
int type_tag,
ASN1_Tag class_tag)
const;
130 BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES:
145 uint8_t* mutable_bits(
size_t length)
147 value.resize(length);
160 std::vector<uint8_t>
put_in_sequence(
const uint8_t bits[],
size_t len);
161 std::string
to_string(
const BER_Object& obj);
206 explicit OID(
const std::string& str);
211 explicit OID(std::initializer_list<uint32_t>
init) : m_id(init) {}
223 static OID from_string(
const std::string& str);
225 void encode_into(
class DER_Encoder&)
const override;
232 bool empty()
const {
return m_id.empty(); }
238 bool has_value()
const {
return (m_id.empty() ==
false); }
246 const std::vector<uint32_t>&
get_id()
const {
return get_components(); }
252 std::string BOTAN_DEPRECATED(
"Use OID::to_string") as_string()
const
267 std::string to_formatted_string()
const;
275 return m_id == other.m_id;
281 void BOTAN_DEPRECATED(
"Avoid mutation of OIDs") clear() { m_id.clear(); }
288 BOTAN_DEPRECATED(
"Avoid mutation of OIDs")
OID& operator+=(uint32_t new_comp)
290 m_id.push_back(new_comp);
295 std::vector<uint32_t> m_id;
311 inline
bool operator!=(const
OID& a, const
OID& b)
340 std::string readable_string()
const;
343 bool time_is_set()
const;
346 int32_t cmp(
const ASN1_Time& other)
const;
352 explicit ASN1_Time(
const std::chrono::system_clock::time_point& time);
358 std::chrono::system_clock::time_point to_std_timepoint()
const;
361 uint64_t time_since_epoch()
const;
364 void set_to(
const std::string& t_spec,
ASN1_Tag);
365 bool passes_sanity_check()
const;
368 uint32_t m_month = 0;
371 uint32_t m_minute = 0;
372 uint32_t m_second = 0;
381 bool BOTAN_PUBLIC_API(2,0) operator<=(const ASN1_Time&, const ASN1_Time&);
382 bool BOTAN_PUBLIC_API(2,0) operator>=(const ASN1_Time&, const ASN1_Time&);
383 bool BOTAN_PUBLIC_API(2,0) operator<(const ASN1_Time&, const ASN1_Time&);
384 bool BOTAN_PUBLIC_API(2,0) operator>(const ASN1_Time&, const ASN1_Time&);
395 void encode_into(
class DER_Encoder&)
const override;
400 const std::string&
value()
const {
return m_utf8_str; }
402 size_t size()
const {
return value().size(); }
404 bool empty()
const {
return m_utf8_str.empty(); }
406 std::string BOTAN_DEPRECATED(
"Use value() to get UTF-8 string instead")
413 static
bool is_string_type(
ASN1_Tag tag);
416 {
return value() == other.value(); }
418 explicit ASN1_String(
const std::string& utf8 =
"");
421 std::vector<uint8_t> m_data;
422 std::string m_utf8_str;
434 void encode_into(
class DER_Encoder&)
const override;
448 bool parameters_are_null()
const;
453 return parameters_are_empty() || parameters_are_null();
456 BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES:
469 const AlgorithmIdentifier&);
471 const AlgorithmIdentifier&);
const std::vector< uint32_t > & get_components() const
std::string asn1_tag_to_string(ASN1_Tag type)
#define BOTAN_UNSTABLE_API
bool parameters_are_empty() const
std::string asn1_class_to_string(ASN1_Tag type)
OID(std::initializer_list< uint32_t > init)
std::vector< uint8_t > parameters
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
bool maybe_BER(DataSource &source)
std::string to_string(const BER_Object &obj)
bool operator==(const OID &other) const
std::string to_string(ErrorType type)
Convert an ErrorType to string.
const uint8_t * bits() const
std::vector< T, secure_allocator< T >> secure_vector
secure_vector< uint8_t > value
BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES class_tag
ASN1_Tag get_class() const
const OID & get_oid() const
secure_vector< uint8_t > BER_encode(const Private_Key &key)
std::vector< uint8_t > put_in_sequence(const std::vector< uint8_t > &contents)
const std::vector< uint32_t > & get_id() const
const std::string & value() const
OID(std::vector< uint32_t > &&init)
const std::vector< uint8_t > & get_parameters() const
bool parameters_are_null_or_empty() const