9 #include <botan/pkix_types.h>
10 #include <botan/der_enc.h>
11 #include <botan/ber_dec.h>
12 #include <botan/oids.h>
13 #include <botan/internal/stl_util.h>
14 #include <botan/parsing.h>
15 #include <botan/loadstor.h>
25 const std::string& uri,
26 const std::string& dns,
27 const std::string& ip)
39 const std::string& value)
41 if(type.empty() || value.empty())
44 auto range = m_alt_info.equal_range(type);
45 for(
auto j = range.first; j != range.second; ++j)
46 if(j->second == value)
68 std::multimap<std::string, std::string> names;
70 for(
auto i = m_alt_info.begin(); i != m_alt_info.end(); ++i)
75 for(
auto i = m_othernames.begin(); i != m_othernames.end(); ++i)
77 multimap_insert(names, i->first.to_formatted_string(), i->second.value());
85 auto range = m_alt_info.equal_range(attr);
86 return (range.first != range.second);
91 auto i = m_alt_info.lower_bound(attr);
92 if(i != m_alt_info.end() && i->first == attr)
100 std::vector<std::string> results;
101 auto range = m_alt_info.equal_range(attr);
102 for(
auto i = range.first; i != range.second; ++i)
103 results.push_back(i->second);
110 auto range = m_alt_info.equal_range(
"DN");
112 for(
auto i = range.first; i != range.second; ++i)
114 std::istringstream strm(i->second);
126 return (m_alt_info.size() > 0 || m_othernames.size() > 0);
135 const std::multimap<std::string, std::string>& attr,
138 auto range = attr.equal_range(type);
140 for(
auto i = range.first; i != range.second; ++i)
142 if(type ==
"RFC822" || type ==
"DNS" || type ==
"URI")
147 else if(type ==
"IP")
150 uint8_t ip_buf[4] = { 0 };
154 else if (type ==
"DN")
156 std::stringstream ss(i->second);
173 encode_entries(der, m_alt_info,
"RFC822",
ASN1_Tag(1));
174 encode_entries(der, m_alt_info,
"DNS",
ASN1_Tag(2));
175 encode_entries(der, m_alt_info,
"DN",
ASN1_Tag(4));
176 encode_entries(der, m_alt_info,
"URI",
ASN1_Tag(6));
177 encode_entries(der, m_alt_info,
"IP",
ASN1_Tag(7));
179 for(
auto i = m_othernames.begin(); i != m_othernames.end(); ++i)
219 BER_Decoder othername_value_inner(othername_value_outer);
246 std::stringstream ss;
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
void decode_from(BER_Decoder &) override
static bool is_string_type(ASN1_Tag tag)
void add_othername(const OID &oid, const std::string &value, ASN1_Tag type)
void add_attribute(const std::string &type, const std::string &value)
uint32_t load_be< uint32_t >(const uint8_t in[], size_t off)
DER_Encoder & end_explicit()
std::string to_string(const BER_Object &obj)
std::multimap< std::string, std::string > contents() const
bool is_a(ASN1_Tag type_tag, ASN1_Tag class_tag) const
BER_Decoder & decode(bool &out)
std::string get_first_attribute(const std::string &attr) const
const uint8_t * bits() const
DER_Encoder & encode(bool b)
std::string ipv4_to_string(uint32_t ip)
ASN1_Tag get_class() const
AlternativeName(const std::string &email_addr="", const std::string &uri="", const std::string &dns="", const std::string &ip_address="")
bool has_field(const std::string &attr) const
BER_Decoder start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
uint32_t string_to_ipv4(const std::string &str)
BER_Object get_next_object()
BER_Decoder & verify_end()
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
void multimap_insert(std::multimap< K, V > &multimap, const K &key, const V &value)
std::vector< std::string > get_attribute(const std::string &attr) const
void encode_into(DER_Encoder &) const override
DER_Encoder & start_explicit(uint16_t type_tag)