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/internal/parsing.h>
15#include <botan/internal/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(
const auto&
name : m_alt_info)
75 for(
const auto& othername : m_othernames)
78 othername.first.to_formatted_string(),
79 othername.second.value());
87 auto range = m_alt_info.equal_range(attr);
88 return (range.first != range.second);
93 auto i = m_alt_info.lower_bound(attr);
94 if(i != m_alt_info.end() && i->first == attr)
102 std::vector<std::string> results;
103 auto range = m_alt_info.equal_range(attr);
104 for(
auto i = range.first; i != range.second; ++i)
105 results.push_back(i->second);
112 auto range = m_alt_info.equal_range(
"DN");
114 for(
auto i = range.first; i != range.second; ++i)
116 std::istringstream strm(i->second);
128 return (!m_alt_info.empty() || !m_othernames.empty());
137 const std::multimap<std::string, std::string>& attr,
140 auto range = attr.equal_range(
type);
142 for(
auto i = range.first; i != range.second; ++i)
149 else if(
type ==
"IP")
152 uint8_t ip_buf[4] = { 0 };
156 else if (
type ==
"DN")
158 std::stringstream ss(i->second);
175 encode_entries(der, m_alt_info,
"RFC822",
ASN1_Type(1));
176 encode_entries(der, m_alt_info,
"DNS",
ASN1_Type(2));
177 encode_entries(der, m_alt_info,
"DN",
ASN1_Type(4));
178 encode_entries(der, m_alt_info,
"URI",
ASN1_Type(6));
179 encode_entries(der, m_alt_info,
"IP",
ASN1_Type(7));
181 for(
const auto& othername : m_othernames)
221 BER_Decoder othername_value_inner(othername_value_outer);
248 std::stringstream ss;
static bool is_string_type(ASN1_Type tag)
std::multimap< std::string, std::string > contents() const
void encode_into(DER_Encoder &) const override
bool has_field(const std::string &attr) const
void add_othername(const OID &oid, const std::string &value, ASN1_Type type)
std::string get_first_attribute(const std::string &attr) const
std::vector< std::string > get_attribute(const std::string &attr) const
void decode_from(BER_Decoder &) override
AlternativeName(const std::string &email_addr="", const std::string &uri="", const std::string &dns="", const std::string &ip_address="")
void add_attribute(const std::string &type, const std::string &value)
BER_Object get_next_object()
BER_Decoder & decode(bool &out)
BER_Decoder & verify_end()
BER_Decoder start_sequence()
const uint8_t * bits() const
bool is_a(ASN1_Type type_tag, ASN1_Class class_tag) const
ASN1_Class get_class() const
DER_Encoder & add_object(ASN1_Type type_tag, ASN1_Class class_tag, const uint8_t rep[], size_t length)
DER_Encoder & end_explicit()
DER_Encoder & start_explicit(uint16_t type_tag)
DER_Encoder & start_sequence()
DER_Encoder & encode(bool b)
std::string to_string(const BER_Object &obj)
@ ExplicitContextSpecific
uint32_t string_to_ipv4(const std::string &str)
constexpr uint32_t load_be< uint32_t >(const uint8_t in[], size_t off)
constexpr void store_be(uint16_t in, uint8_t out[2])
void multimap_insert(std::multimap< K, V > &multimap, const K &key, const V &value)
std::string ipv4_to_string(uint32_t ip)