9#include <botan/pkix_types.h>
11#include <botan/ber_dec.h>
12#include <botan/der_enc.h>
13#include <botan/internal/loadstor.h>
14#include <botan/internal/parsing.h>
15#include <botan/internal/stl_util.h>
27 std::string_view ip) {
38 if(type.empty() || value.empty()) {
42 auto range = m_alt_info.equal_range(type);
43 for(
auto j = range.first; j != range.second; ++j) {
44 if(j->second == value) {
49 m_alt_info.emplace(type, value);
66 std::multimap<std::string, std::string> names;
68 for(
const auto&
name : m_alt_info) {
69 names.emplace(
name.first,
name.second);
72 for(
const auto& othername : m_othernames) {
73 multimap_insert(names, othername.first.to_formatted_string(), othername.second.value());
80 auto range = m_alt_info.equal_range(attr);
81 return (range.first != range.second);
85 auto i = m_alt_info.lower_bound(attr);
86 if(i != m_alt_info.end() && i->first == attr) {
94 std::vector<std::string> results;
95 auto range = m_alt_info.equal_range(attr);
96 for(
auto i = range.first; i != range.second; ++i) {
97 results.push_back(i->second);
104 auto range = m_alt_info.equal_range(
"DN");
106 for(
auto i = range.first; i != range.second; ++i) {
107 std::istringstream strm(i->second);
118 return (!m_alt_info.empty() || !m_othernames.empty());
127 const std::multimap<std::string, std::string, std::less<>>& attr,
128 std::string_view type,
130 auto range = attr.equal_range(type);
132 for(
auto i = range.first; i != range.second; ++i) {
133 if(type ==
"RFC822" || type ==
"DNS" || type ==
"URI") {
136 }
else if(type ==
"IP") {
138 uint8_t ip_buf[4] = {0};
141 }
else if(type ==
"DN") {
142 std::stringstream ss(i->second);
158 encode_entries(der, m_alt_info,
"RFC822",
ASN1_Type(1));
159 encode_entries(der, m_alt_info,
"DNS",
ASN1_Type(2));
160 encode_entries(der, m_alt_info,
"DN",
ASN1_Type(4));
161 encode_entries(der, m_alt_info,
"URI",
ASN1_Type(6));
162 encode_entries(der, m_alt_info,
"IP",
ASN1_Type(7));
164 for(
const auto& othername : m_othernames) {
200 BER_Decoder othername_value_inner(othername_value_outer);
219 std::stringstream ss;
static bool is_string_type(ASN1_Type tag)
std::string get_first_attribute(std::string_view attr) const
std::multimap< std::string, std::string > contents() const
std::vector< std::string > get_attribute(std::string_view attr) const
void add_attribute(std::string_view type, std::string_view value)
void encode_into(DER_Encoder &) const override
AlternativeName(std::string_view email_addr="", std::string_view uri="", std::string_view dns="", std::string_view ip_address="")
void add_othername(const OID &oid, std::string_view value, ASN1_Type type)
void decode_from(BER_Decoder &) override
bool has_field(std::string_view attr) const
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)
uint32_t string_to_ipv4(std::string_view str)
@ ExplicitContextSpecific
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)