9 #include <botan/asn1_alt_name.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>
16 #include <botan/x509_dn.h>
26 const std::string& uri,
27 const std::string& dns,
28 const std::string& ip)
40 const std::string& value)
42 if(type.empty() || value.empty())
45 auto range = m_alt_info.equal_range(type);
46 for(
auto j = range.first; j != range.second; ++j)
47 if(j->second == value)
69 std::multimap<std::string, std::string> names;
71 for(
auto i = m_alt_info.begin(); i != m_alt_info.end(); ++i)
76 for(
auto i = m_othernames.begin(); i != m_othernames.end(); ++i)
78 multimap_insert(names, i->first.to_formatted_string(), i->second.value());
86 auto range = m_alt_info.equal_range(attr);
87 return (range.first != range.second);
92 auto i = m_alt_info.lower_bound(attr);
93 if(i != m_alt_info.end() && i->first == attr)
101 std::vector<std::string> results;
102 auto range = m_alt_info.equal_range(attr);
103 for(
auto i = range.first; i != range.second; ++i)
104 results.push_back(i->second);
113 return (m_alt_info.size() > 0 || m_othernames.size() > 0);
122 const std::multimap<std::string, std::string>& attr,
125 auto range = attr.equal_range(type);
127 for(
auto i = range.first; i != range.second; ++i)
129 if(type ==
"RFC822" || type ==
"DNS" || type ==
"URI")
134 else if(type ==
"IP")
137 uint8_t ip_buf[4] = { 0 };
141 else if (type ==
"DN")
143 std::stringstream ss(i->second);
160 encode_entries(der, m_alt_info,
"RFC822",
ASN1_Tag(1));
161 encode_entries(der, m_alt_info,
"DNS",
ASN1_Tag(2));
162 encode_entries(der, m_alt_info,
"DN",
ASN1_Tag(4));
163 encode_entries(der, m_alt_info,
"URI",
ASN1_Tag(6));
164 encode_entries(der, m_alt_info,
"IP",
ASN1_Tag(7));
166 for(
auto i = m_othernames.begin(); i != m_othernames.end(); ++i)
206 BER_Decoder othername_value_inner(othername_value_outer);
233 std::stringstream ss;
void encode_into(class DER_Encoder &) const override
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const uint8_t rep[], size_t length)
static bool is_string_type(ASN1_Tag tag)
void add_othername(const OID &oid, const std::string &value, ASN1_Tag type)
void store_be(uint16_t in, uint8_t out[2])
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 decode_from(class BER_Decoder &) override
DER_Encoder & start_explicit(uint16_t type_tag)