7#ifndef BOTAN_ASN1_OBJECT_TYPES_H_
8#define BOTAN_ASN1_OBJECT_TYPES_H_
10#include <botan/secmem.h>
11#include <botan/exceptn.h>
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);
161std::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;
311inline
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;
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:
ASN1_Object & operator=(const ASN1_Object &)=default
ASN1_Object(const ASN1_Object &)=default
virtual ~ASN1_Object()=default
virtual void decode_from(BER_Decoder &from)=0
virtual void encode_into(DER_Encoder &to) const =0
const std::string & value() const
ASN1_Time()=default
Create an invalid ASN1_Time.
bool parameters_are_empty() const
bool parameters_are_null_or_empty() const
AlgorithmIdentifier()=default
const std::vector< uint8_t > & get_parameters() const
const OID & get_oid() const
std::vector< uint8_t > parameters
BER_Object(BER_Object &&other)=default
const uint8_t * bits() const
BER_Object & operator=(const BER_Object &other)=default
secure_vector< uint8_t > value
BER_Object(const BER_Object &other)=default
BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES class_tag
BER_Object & operator=(BER_Object &&other)=default
ASN1_Tag get_class() const
const std::vector< uint32_t > & get_id() const
const std::vector< uint32_t > & get_components() const
OID(std::initializer_list< uint32_t > init)
bool operator==(const OID &other) const
OID(std::vector< uint32_t > &&init)
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_UNSTABLE_API
std::vector< uint8_t > put_in_sequence(const std::vector< uint8_t > &contents)
bool maybe_BER(DataSource &source)
std::string to_string(const BER_Object &obj)
secure_vector< uint8_t > BER_encode(const Private_Key &key)
@ UTC_OR_GENERALIZED_TIME
std::string to_string(ErrorType type)
Convert an ErrorType to string.
std::string asn1_class_to_string(ASN1_Tag type)
std::vector< T, secure_allocator< T > > secure_vector
std::string asn1_tag_to_string(ASN1_Tag type)