8 #include <botan/pkix_types.h> 9 #include <botan/der_enc.h> 10 #include <botan/ber_dec.h> 11 #include <botan/parsing.h> 12 #include <botan/internal/stl_util.h> 13 #include <botan/oids.h> 24 const std::string& str)
37 m_rdn.push_back(std::make_pair(oid, str));
46 std::multimap<OID, std::string> retval;
58 std::multimap<std::string, std::string> retval;
62 multimap_insert(retval, i.first.to_formatted_string(), i.second.value());
113 std::vector<std::string> values;
119 values.push_back(i.second.value());
131 if(info ==
"Name" || info ==
"CommonName" || info ==
"CN")
return "X520.CommonName";
132 if(info ==
"SerialNumber" || info ==
"SN")
return "X520.SerialNumber";
133 if(info ==
"Country" || info ==
"C")
return "X520.Country";
134 if(info ==
"Organization" || info ==
"O")
return "X520.Organization";
135 if(info ==
"Organizational Unit" || info ==
"OrgUnit" || info ==
"OU")
136 return "X520.OrganizationalUnit";
137 if(info ==
"Locality" || info ==
"L")
return "X520.Locality";
138 if(info ==
"State" || info ==
"Province" || info ==
"ST")
return "X520.State";
139 if(info ==
"Email")
return "RFC822";
151 if(attr1.size() != attr2.size())
return false;
153 auto p1 = attr1.begin();
154 auto p2 = attr2.begin();
158 if(p1 == attr1.end() && p2 == attr2.end())
160 if(p1 == attr1.end())
return false;
161 if(p2 == attr2.end())
return false;
162 if(p1->first != p2->first)
return false;
176 return !(dn1 == dn2);
188 if(attr1.size() < attr2.size())
190 if(attr1.size() > attr2.size())
194 auto p1 = attr1.begin();
195 auto p2 = attr2.begin();
197 while(p1 != attr1.end() && p2 != attr2.end())
199 if(p1->first != p2->first)
201 return (p1->first < p2->first);
217 while(p1 != attr1.end() && p2 != attr2.end())
226 return (p1->second < p2->second);
245 if(!m_dn_bits.empty())
255 for(
const auto& dn : m_rdn)
274 std::vector<uint8_t> bits;
305 std::string to_short_form(
const OID& oid)
309 if(long_id ==
"X520.CommonName")
312 if(long_id ==
"X520.Country")
315 if(long_id ==
"X520.Organization")
318 if(long_id ==
"X520.OrganizationalUnit")
328 std::ostringstream out;
337 for(
size_t i = 0; i != info.size(); ++i)
339 out << to_short_form(info[i].first) <<
"=\"";
340 for(
char c : info[i].second.value())
342 if(c ==
'\\' || c ==
'\"')
350 if(i + 1 < info.size())
371 if(std::isspace(c) && key.empty())
373 else if(!std::isspace(c))
386 if(!std::isspace(c) && c !=
'=')
394 bool in_quotes =
false;
401 if(!in_quotes && !val.empty())
407 in_quotes = !in_quotes;
414 else if(c ==
',' && !in_quotes)
420 if(!key.empty() && !val.empty())
bool operator!=(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
ASN1_String get_first_attribute(const OID &oid) const
int operator<<(int fd, Pipe &pipe)
const std::vector< std::pair< OID, ASN1_String > > & dn_info() const
static std::string deref_info_field(const std::string &key)
void add_attribute(const std::string &key, const std::string &val)
#define BOTAN_ASSERT_NOMSG(expr)
BER_Decoder & raw_bytes(std::vector< uint8_t, Alloc > &out)
BOTAN_UNSTABLE_API OID str2oid_or_empty(const std::string &name)
BER_Decoder & decode(bool &out)
DER_Encoder & raw_bytes(const uint8_t val[], size_t len)
DER_Encoder & encode(bool b)
void decode_from(BER_Decoder &) override
bool operator<(const OID &a, const OID &b)
std::vector< std::string > get_attribute(const std::string &attr) const
#define BOTAN_DEBUG_ASSERT(expr)
bool x500_name_cmp(const std::string &name1, const std::string &name2)
BER_Decoder start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
const std::string & value() const
std::string to_formatted_string() const
bool has_field(const OID &oid) const
BER_Decoder & verify_end()
void encode_into(DER_Encoder &) const override
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
int operator>>(int fd, Pipe &pipe)
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
void multimap_insert(std::multimap< K, V > &multimap, const K &key, const V &value)
std::multimap< OID, std::string > get_attributes() const
std::string to_string() const
std::multimap< std::string, std::string > contents() const
static OID from_string(const std::string &str)