Botan 3.11.0
Crypto and TLS for C&
pkix_types.h
Go to the documentation of this file.
1/*
2* (C) 1999-2010,2012,2018,2020 Jack Lloyd
3* (C) 2007 Yves Jerschow
4* (C) 2015 Kai Michaelis
5* (C) 2016 René Korthaus, Rohde & Schwarz Cybersecurity
6* (C) 2017 Fabian Weissberg, Rohde & Schwarz Cybersecurity
7*
8* Botan is released under the Simplified BSD License (see license.txt)
9*/
10
11#ifndef BOTAN_PKIX_TYPES_H_
12#define BOTAN_PKIX_TYPES_H_
13
14#include <botan/asn1_obj.h>
15
16#include <botan/pkix_enums.h>
17#include <initializer_list>
18#include <iosfwd>
19#include <map>
20#include <memory>
21#include <set>
22#include <string>
23#include <string_view>
24#include <variant>
25#include <vector>
26
27namespace Botan {
28
30class Public_Key;
31
32BOTAN_DEPRECATED("Use Key_Constraints::to_string")
33
35 return c.to_string();
36}
37
38/**
39* Distinguished Name
40*/
41class BOTAN_PUBLIC_API(2, 0) X509_DN final : public ASN1_Object {
42 public:
43 X509_DN() = default;
44
45 X509_DN(std::initializer_list<std::pair<std::string_view, std::string_view>> args) {
46 for(const auto& i : args) {
47 add_attribute(i.first, i.second);
48 }
49 }
50
51 /**
52 * Since DN matching for Name Constraints requires preserving order and
53 * multimaps have sorted keys, this constructor is deprecated.
54 */
55 BOTAN_DEPRECATED("Deprecated use initializer list constructor")
56 explicit X509_DN(const std::multimap<OID, std::string>& args) {
57 for(const auto& i : args) {
58 add_attribute(i.first, i.second);
59 }
60 }
61
62 /**
63 * Since DN matching for Name Constraints requires preserving order and
64 * multimaps have sorted keys, this constructor is deprecated.
65 */
66 BOTAN_DEPRECATED("Deprecated use initializer list constructor")
67 explicit X509_DN(const std::multimap<std::string, std::string>& args) {
68 for(const auto& i : args) {
69 add_attribute(i.first, i.second);
70 }
71 }
72
73 void encode_into(DER_Encoder& to) const override;
74 void decode_from(BER_Decoder& from) override;
75
76 bool has_field(const OID& oid) const;
77 ASN1_String get_first_attribute(const OID& oid) const;
78
79 /*
80 * Return the BER encoded data, if any
81 */
82 const std::vector<uint8_t>& get_bits() const { return m_dn_bits; }
83
84 std::vector<uint8_t> DER_encode() const;
85
86 bool empty() const { return m_rdn.empty(); }
87
88 size_t count() const { return m_rdn.size(); }
89
90 std::string to_string() const;
91
92 /**
93 * Return the DN components as a vector. Note that the order of the components is
94 * preserved only when using the initializer list constructor.
95 */
96 const std::vector<std::pair<OID, ASN1_String>>& dn_info() const { return m_rdn; }
97
98 std::multimap<OID, std::string> get_attributes() const;
99 std::multimap<std::string, std::string> contents() const;
100
101 bool has_field(std::string_view attr) const;
102 std::vector<std::string> get_attribute(std::string_view attr) const;
103 std::string get_first_attribute(std::string_view attr) const;
104
105 void add_attribute(std::string_view key, std::string_view val);
106
107 void add_attribute(const OID& oid, std::string_view val) { add_attribute(oid, ASN1_String(val)); }
108
109 void add_attribute(const OID& oid, const ASN1_String& val);
110
111 static std::string deref_info_field(std::string_view key);
112
113 /**
114 * Lookup upper bounds in characters for the length of distinguished name fields
115 * as given in RFC 5280, Appendix A.
116 *
117 * @param oid the oid of the DN to lookup
118 * @return the upper bound, or zero if no ub is known to Botan
119 */
120 static size_t lookup_ub(const OID& oid);
121
122 private:
123 std::vector<std::pair<OID, ASN1_String>> m_rdn;
124 std::vector<uint8_t> m_dn_bits;
125};
126
127BOTAN_PUBLIC_API(2, 0) bool operator==(const X509_DN& dn1, const X509_DN& dn2);
128BOTAN_PUBLIC_API(2, 0) bool operator!=(const X509_DN& dn1, const X509_DN& dn2);
129
130/*
131The ordering here is arbitrary and may change from release to release.
132It is intended for allowing DNs as keys in std::map and similar containers
133*/
134BOTAN_PUBLIC_API(2, 0) bool operator<(const X509_DN& dn1, const X509_DN& dn2);
135
136BOTAN_PUBLIC_API(2, 0) std::ostream& operator<<(std::ostream& out, const X509_DN& dn);
137BOTAN_PUBLIC_API(2, 0) std::istream& operator>>(std::istream& in, X509_DN& dn);
138
139/**
140* Alternative Name
141*/
142class BOTAN_PUBLIC_API(2, 0) AlternativeName final : public ASN1_Object {
143 public:
144 void encode_into(DER_Encoder& to) const override;
145 void decode_from(BER_Decoder& from) override;
146
147 /// Create an empty name
148 AlternativeName() = default;
149
150 /// Add a URI to this AlternativeName
151 void add_uri(std::string_view uri);
152
153 /// Add a URI to this AlternativeName
154 void add_email(std::string_view addr);
155
156 /// Add a DNS name to this AlternativeName
157 void add_dns(std::string_view dns);
158
159 /// Add an "OtherName" identified by object identifier to this AlternativeName
160 void add_other_name(const OID& oid, const ASN1_String& value);
161
162 /// Add a directory name to this AlternativeName
163 void add_dn(const X509_DN& dn);
164
165 /// Add an IP address to this alternative name
166 void add_ipv4_address(uint32_t ipv4);
167
168 /// Return the set of URIs included in this alternative name
169 const std::set<std::string>& uris() const { return m_uri; }
170
171 /// Return the set of email addresses included in this alternative name
172 const std::set<std::string>& email() const { return m_email; }
173
174 /// Return the set of DNS names included in this alternative name
175 const std::set<std::string>& dns() const { return m_dns; }
176
177 /// Return the set of IPv4 addresses included in this alternative name
178 const std::set<uint32_t>& ipv4_address() const { return m_ipv4_addr; }
179
180 /// Return the set of "other names" included in this alternative name
181 BOTAN_DEPRECATED("Support for other names is deprecated")
182 const std::set<std::pair<OID, ASN1_String>>& other_names() const {
183 return m_othernames;
184 }
185
186 /// Return the set of directory names included in this alternative name
187 const std::set<X509_DN>& directory_names() const { return m_dn_names; }
188
189 /// Return the total number of names in this AlternativeName
190 ///
191 /// This only counts names which were parsed, ignoring names which
192 /// were of some unknown type
193 size_t count() const;
194
195 /// Return true if this has any names set
196 bool has_items() const;
197
198 // Old, now deprecated interface follows:
199 BOTAN_DEPRECATED("Use AlternativeName::{uris, email, dns, othernames, directory_names}")
200 std::multimap<std::string, std::string> contents() const;
201
202 BOTAN_DEPRECATED("Use AlternativeName::{uris, email, dns, othernames, directory_names}.empty()")
203 bool has_field(std::string_view attr) const;
204
205 BOTAN_DEPRECATED("Use AlternativeName::{uris, email, dns, othernames, directory_names}")
206 std::vector<std::string> get_attribute(std::string_view attr) const;
207
208 BOTAN_DEPRECATED("Use AlternativeName::{uris, email, dns, othernames, directory_names}")
209 std::multimap<std::string, std::string, std::less<>> get_attributes() const;
210
211 BOTAN_DEPRECATED("Use AlternativeName::{uris, email, dns, othernames, directory_names}")
212 std::string get_first_attribute(std::string_view attr) const;
213
214 BOTAN_DEPRECATED("Use AlternativeName::add_{uri, dns, email, ...}")
215 void add_attribute(std::string_view type, std::string_view value);
216
217 BOTAN_DEPRECATED("Use AlternativeName::add_other_name")
218 void add_othername(const OID& oid, std::string_view value, ASN1_Type type);
219
220 BOTAN_DEPRECATED("Use AlternativeName::othernames") std::multimap<OID, ASN1_String> get_othernames() const;
221
222 BOTAN_DEPRECATED("Use AlternativeName::directory_names") X509_DN dn() const;
223
224 BOTAN_DEPRECATED("Use plain constructor plus add_{uri,dns,email,ipv4_address}")
225 BOTAN_FUTURE_EXPLICIT AlternativeName(std::string_view email_addr,
226 std::string_view uri = "",
227 std::string_view dns = "",
228 std::string_view ip_address = "");
229
230 private:
231 std::set<std::string> m_dns;
232 std::set<std::string> m_uri;
233 std::set<std::string> m_email;
234 std::set<uint32_t> m_ipv4_addr;
235 std::set<X509_DN> m_dn_names;
236 std::set<std::pair<OID, ASN1_String>> m_othernames;
237};
238
239/**
240* Attribute
241*/
242class BOTAN_PUBLIC_API(2, 0) Attribute final : public ASN1_Object {
243 public:
244 void encode_into(DER_Encoder& to) const override;
245 void decode_from(BER_Decoder& from) override;
246
247 Attribute() = default;
248 Attribute(const OID& oid, const std::vector<uint8_t>& params);
249 Attribute(std::string_view oid_str, const std::vector<uint8_t>& params);
250
251 const OID& oid() const { return m_oid; }
252
253 const std::vector<uint8_t>& parameters() const { return m_parameters; }
254
255 const OID& object_identifier() const { return m_oid; }
256
257 const std::vector<uint8_t>& get_parameters() const { return m_parameters; }
258
259 private:
260 OID m_oid;
261 std::vector<uint8_t> m_parameters;
262};
263
264/**
265* @brief X.509 GeneralName Type
266*
267* Handles parsing GeneralName types in their BER and canonical string
268* encoding. Allows matching GeneralNames against each other using
269* the rules laid out in the RFC 5280, sec. 4.2.1.10 (Name Constraints).
270*
271* This entire class is deprecated and will be removed in a future
272* major release
273*/
274class BOTAN_PUBLIC_API(2, 0) GeneralName final : public ASN1_Object {
275 public:
276 enum MatchResult : uint8_t /* NOLINT(*-use-enum-class) */ {
282 };
283
284 enum class NameType : uint8_t {
286 RFC822 = 1,
287 DNS = 2,
288 URI = 3,
289 DN = 4,
290 IPv4 = 5,
291 Other = 6,
292 };
293
294 BOTAN_DEPRECATED("Deprecated use NameConstraints") GeneralName() = default;
295
296 static GeneralName email(std::string_view email);
297 static GeneralName dns(std::string_view dns);
298 static GeneralName uri(std::string_view uri);
300 static GeneralName ipv4_address(uint32_t ipv4);
301 static GeneralName ipv4_address(uint32_t ipv4, uint32_t mask);
302
303 // Encoding is not implemented
304 void encode_into(DER_Encoder& to) const override;
305
306 void decode_from(BER_Decoder& from) override;
307
308 /**
309 * @return Type of the name expressed in this restriction
310 */
311 NameType type_code() const { return m_type; }
312
313 /**
314 * @return Type of the name. Can be DN, DNS, IP, RFC822 or URI.
315 */
316 BOTAN_DEPRECATED("Deprecated use type_code") std::string type() const;
317
318 /**
319 * @return The name as string. Format depends on type.
320 */
321 BOTAN_DEPRECATED("Deprecated no replacement") std::string name() const;
322
323 /**
324 * @return The name as binary string. Format depends on type.
325 */
326 BOTAN_DEPRECATED("Deprecated no replacement") std::vector<uint8_t> binary_name() const;
327
328 /**
329 * Checks whether a given certificate (partially) matches this name.
330 * @param cert certificate to be matched
331 * @return the match result
332 */
333 BOTAN_DEPRECATED("Deprecated use NameConstraints type") MatchResult matches(const X509_Certificate& cert) const;
334
335 bool matches_dns(const std::string& dns_name) const;
336 bool matches_ipv4(uint32_t ip) const;
337 bool matches_dn(const X509_DN& dn) const;
338
339 private:
340 static constexpr size_t RFC822_IDX = 0;
341 static constexpr size_t DNS_IDX = 1;
342 static constexpr size_t URI_IDX = 2;
343 static constexpr size_t DN_IDX = 3;
344 static constexpr size_t IPV4_IDX = 4;
345
346 using NameVariant = std::variant<std::string, std::string, std::string, X509_DN, std::pair<uint32_t, uint32_t>>;
347
348 GeneralName(NameType type, NameVariant name) : m_type(type), m_name(std::move(name)) {}
349
350 template <size_t idx, typename T>
351 requires(idx < 5)
352 static GeneralName make(T&& value) {
353 return {NameType(idx + 1 /* implicit enum relationship! */),
354 NameVariant(std::in_place_index_t<idx>(), std::forward<T>(value))};
355 }
356
357 NameType m_type = NameType::Unknown;
358 NameVariant m_name;
359
360 static bool matches_dns(std::string_view name, std::string_view constraint);
361
362 /**
363 * Partial DN matching according to RFC 5280, Section 7.1, i.e.,
364 * whether the constraint is a prefix of the name.
365 */
366 static bool matches_dn(const X509_DN& name, const X509_DN& constraint);
367};
368
369BOTAN_DEPRECATED("Deprecated no replacement") std::ostream& operator<<(std::ostream& os, const GeneralName& gn);
370
371/**
372* @brief A single Name Constraint
373*
374* The Name Constraint extension adds a minimum and maximum path
375* length to a GeneralName to form a constraint. The length limits
376* are not used in PKIX.
377*
378* This entire class is deprecated and will be removed in a future
379* major release
380*/
381class BOTAN_PUBLIC_API(2, 0) GeneralSubtree final : public ASN1_Object {
382 public:
383 /**
384 * Creates an empty name constraint.
385 */
386 BOTAN_DEPRECATED("Deprecated use NameConstraints") GeneralSubtree();
387
388 void encode_into(DER_Encoder& to) const override;
389
390 void decode_from(BER_Decoder& from) override;
391
392 /**
393 * @return name
394 */
395 const GeneralName& base() const { return m_base; }
396
397 private:
398 GeneralName m_base;
399};
400
401BOTAN_DEPRECATED("Deprecated no replacement") std::ostream& operator<<(std::ostream& os, const GeneralSubtree& gs);
402
403/**
404* @brief Name Constraints
405*
406* Wraps the Name Constraints associated with a certificate.
407*/
409 public:
410 /**
411 * Creates an empty name NameConstraints.
412 */
413 NameConstraints() = default;
414
415 /**
416 * Creates NameConstraints from a list of permitted and excluded subtrees.
417 * @param permitted_subtrees names for which the certificate is permitted
418 * @param excluded_subtrees names for which the certificate is not permitted
419 */
420 NameConstraints(std::vector<GeneralSubtree>&& permitted_subtrees,
421 std::vector<GeneralSubtree>&& excluded_subtrees);
422
423 /**
424 * @return permitted names
425 */
426 BOTAN_DEPRECATED("Deprecated no replacement") const std::vector<GeneralSubtree>& permitted() const {
427 return m_permitted_subtrees;
428 }
429
430 /**
431 * @return excluded names
432 */
433 BOTAN_DEPRECATED("Deprecated no replacement") const std::vector<GeneralSubtree>& excluded() const {
434 return m_excluded_subtrees;
435 }
436
437 /**
438 * Return true if all of the names in the certificate are permitted
439 */
440 bool is_permitted(const X509_Certificate& cert, bool reject_unknown) const;
441
442 /**
443 * Return true if any of the names in the certificate are excluded
444 */
445 bool is_excluded(const X509_Certificate& cert, bool reject_unknown) const;
446
447 private:
448 std::vector<GeneralSubtree> m_permitted_subtrees;
449 std::vector<GeneralSubtree> m_excluded_subtrees;
450
451 std::set<GeneralName::NameType> m_permitted_name_types;
452 std::set<GeneralName::NameType> m_excluded_name_types;
453};
454
455/**
456* X.509 Certificate Extension
457*/
458class BOTAN_PUBLIC_API(2, 0) Certificate_Extension /* NOLINT(*-special-member-functions) */ {
459 public:
460 /**
461 * @return OID representing this extension
462 */
463 virtual OID oid_of() const = 0;
464
465 /*
466 * @return specific OID name
467 * If possible OIDS table should match oid_name to OIDS, ie
468 * OID::from_string(ext->oid_name()) == ext->oid_of()
469 * Should return empty string if OID is not known
470 */
471 virtual std::string oid_name() const = 0;
472
473 /**
474 * Make a copy of this extension
475 * @return copy of this
476 */
477
478 virtual std::unique_ptr<Certificate_Extension> copy() const = 0;
479
480 /*
481 * Callback visited during path validation.
482 *
483 * An extension can implement this callback to inspect
484 * the path during path validation.
485 *
486 * If an error occurs during validation of this extension,
487 * an appropriate status code shall be added to cert_status.
488 *
489 * @param subject Subject certificate that contains this extension
490 * @param issuer Issuer certificate. nullopt for certificates with no
491 * available issuer (e.g. non self-signed trust anchors).
492 * @param cert_path Certificate path which is currently validated
493 * @param cert_status Certificate validation status codes for subject certificate
494 * @param pos Position of subject certificate in cert_path
495 */
496 virtual void validate(const X509_Certificate& subject,
497 const std::optional<X509_Certificate>& issuer,
498 const std::vector<X509_Certificate>& cert_path,
499 std::vector<std::set<Certificate_Status_Code>>& cert_status,
500 size_t pos);
501
502 virtual ~Certificate_Extension() = default;
503
504 protected:
505 friend class Extensions;
506
507 virtual bool should_encode() const { return true; }
508
509 virtual std::vector<uint8_t> encode_inner() const = 0;
510 virtual void decode_inner(const std::vector<uint8_t>&) = 0;
511};
512
513/**
514* X.509 Certificate Extension List
515*/
516class BOTAN_PUBLIC_API(2, 0) Extensions final : public ASN1_Object {
517 public:
518 /**
519 * Look up an object in the extensions, based on OID Returns
520 * nullptr if not set, if the extension was either absent or not
521 * handled. The pointer returned is owned by the Extensions
522 * object.
523 * This would be better with an optional<T> return value
524 */
525 const Certificate_Extension* get_extension_object(const OID& oid) const;
526
527 template <typename T>
528 const T* get_extension_object_as(const OID& oid = T::static_oid()) const {
529 if(const Certificate_Extension* extn = get_extension_object(oid)) {
530 // Unknown_Extension oid_name is empty
531 if(extn->oid_name().empty()) {
532 return nullptr;
533 } else if(const T* extn_as_T = dynamic_cast<const T*>(extn)) {
534 return extn_as_T;
535 } else {
536 throw Decoding_Error("Exception::get_extension_object_as dynamic_cast failed");
537 }
538 }
539
540 return nullptr;
541 }
542
543 /**
544 * Return the set of extensions in the order they appeared in the certificate
545 * (or as they were added, if constructed)
546 */
547 const std::vector<OID>& get_extension_oids() const { return m_extension_oids; }
548
549 /**
550 * Return true if an extension was set
551 */
552 bool extension_set(const OID& oid) const;
553
554 /**
555 * Return true if an extension was set and marked critical
556 */
557 bool critical_extension_set(const OID& oid) const;
558
559 /**
560 * Return the raw bytes of the extension
561 * Will throw if OID was not set as an extension.
562 */
563 std::vector<uint8_t> get_extension_bits(const OID& oid) const;
564
565 void encode_into(DER_Encoder& to) const override;
566 void decode_from(BER_Decoder& from) override;
567
568 /**
569 * Adds a new extension to the list.
570 * @param extn pointer to the certificate extension (Extensions takes ownership)
571 * @param critical whether this extension should be marked as critical
572 * @throw Invalid_Argument if the extension is already present in the list
573 */
574 void add(std::unique_ptr<Certificate_Extension> extn, bool critical = false);
575
576 /**
577 * Adds a new extension to the list unless it already exists. If the extension
578 * already exists within the Extensions object, the extn pointer will be deleted.
579 *
580 * @param extn pointer to the certificate extension (Extensions takes ownership)
581 * @param critical whether this extension should be marked as critical
582 * @return true if the object was added false if the extension was already used
583 */
584 bool add_new(std::unique_ptr<Certificate_Extension> extn, bool critical = false);
585
586 /**
587 * Adds an extension to the list or replaces it.
588 * @param extn the certificate extension
589 * @param critical whether this extension should be marked as critical
590 */
591 void replace(std::unique_ptr<Certificate_Extension> extn, bool critical = false);
592
593 /**
594 * Remove an extension from the list. Returns true if the
595 * extension had been set, false otherwise.
596 */
597 bool remove(const OID& oid);
598
599 /**
600 * Searches for an extension by OID and returns the result.
601 * Only the known extensions types declared in this header
602 * are searched for by this function.
603 * @return Copy of extension with oid, nullptr if not found.
604 * Can avoid creating a copy by using get_extension_object function
605 */
606 std::unique_ptr<Certificate_Extension> get(const OID& oid) const;
607
608 /**
609 * Searches for an extension by OID and returns the result decoding
610 * it to some arbitrary extension type chosen by the application.
611 *
612 * Only the unknown extensions, that is, extensions types that
613 * are not declared in this header, are searched for by this
614 * function.
615 *
616 * @return Pointer to new extension with oid, nullptr if not found.
617 */
618 template <typename T>
619 std::unique_ptr<T> get_raw(const OID& oid) const {
620 auto extn_info = m_extension_info.find(oid);
621
622 if(extn_info != m_extension_info.end()) {
623 // Unknown_Extension oid_name is empty
624 if(extn_info->second.obj().oid_name().empty()) {
625 auto ext = std::make_unique<T>();
626 ext->decode_inner(extn_info->second.bits());
627 return ext;
628 }
629 }
630 return nullptr;
631 }
632
633 /**
634 * Returns a copy of the list of extensions together with the corresponding
635 * criticality flag. All extensions are encoded as some object, falling back
636 * to Unknown_Extension class which simply allows reading the bytes as well
637 * as the criticality flag.
638 */
639 std::vector<std::pair<std::unique_ptr<Certificate_Extension>, bool>> extensions() const;
640
641 /**
642 * Returns the list of extensions as raw, encoded bytes
643 * together with the corresponding criticality flag.
644 * Contains all extensions, including any extensions encoded as Unknown_Extension
645 */
646 std::map<OID, std::pair<std::vector<uint8_t>, bool>> extensions_raw() const;
647
648 Extensions() = default;
649
650 Extensions(const Extensions&) = default;
651 Extensions& operator=(const Extensions&) = default;
652
653 Extensions(Extensions&&) = default;
655
656 ~Extensions() override = default;
657
658 private:
659 static std::unique_ptr<Certificate_Extension> create_extn_obj(const OID& oid,
660 bool critical,
661 const std::vector<uint8_t>& body);
662
663 class BOTAN_UNSTABLE_API Extensions_Info {
664 public:
665 Extensions_Info(bool critical, std::unique_ptr<Certificate_Extension> ext) :
666 m_obj(std::move(ext)), m_bits(m_obj->encode_inner()), m_critical(critical) {}
667
668 Extensions_Info(bool critical,
669 const std::vector<uint8_t>& encoding,
670 std::unique_ptr<Certificate_Extension> ext) :
671 m_obj(std::move(ext)), m_bits(encoding), m_critical(critical) {}
672
673 bool is_critical() const { return m_critical; }
674
675 const std::vector<uint8_t>& bits() const { return m_bits; }
676
677 const Certificate_Extension& obj() const;
678
679 private:
680 std::shared_ptr<Certificate_Extension> m_obj;
681 std::vector<uint8_t> m_bits;
682 bool m_critical = false;
683 };
684
685 std::vector<OID> m_extension_oids;
686 std::map<OID, Extensions_Info> m_extension_info;
687};
688
689} // namespace Botan
690
691#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
#define BOTAN_UNSTABLE_API
Definition api.h:34
#define BOTAN_DEPRECATED(msg)
Definition api.h:73
#define BOTAN_FUTURE_EXPLICIT
Definition api.h:52
ASN1_Object()=default
const std::set< X509_DN > & directory_names() const
Return the set of directory names included in this alternative name.
Definition pkix_types.h:187
void add_dns(std::string_view dns)
Add a DNS name to this AlternativeName.
Definition alt_name.cpp:29
void add_ipv4_address(uint32_t ipv4)
Add an IP address to this alternative name.
Definition alt_name.cpp:43
void add_email(std::string_view addr)
Add a URI to this AlternativeName.
Definition alt_name.cpp:23
const std::set< uint32_t > & ipv4_address() const
Return the set of IPv4 addresses included in this alternative name.
Definition pkix_types.h:178
void encode_into(DER_Encoder &to) const override
Definition alt_name.cpp:59
const std::set< std::pair< OID, ASN1_String > > & other_names() const
Return the set of "other names" included in this alternative name.
Definition pkix_types.h:182
const std::set< std::string > & uris() const
Return the set of URIs included in this alternative name.
Definition pkix_types.h:169
void add_uri(std::string_view uri)
Add a URI to this AlternativeName.
Definition alt_name.cpp:17
const std::set< std::string > & dns() const
Return the set of DNS names included in this alternative name.
Definition pkix_types.h:175
void add_other_name(const OID &oid, const ASN1_String &value)
Add an "OtherName" identified by object identifier to this AlternativeName.
Definition alt_name.cpp:35
const std::set< std::string > & email() const
Return the set of email addresses included in this alternative name.
Definition pkix_types.h:172
void add_dn(const X509_DN &dn)
Add a directory name to this AlternativeName.
Definition alt_name.cpp:39
AlternativeName()=default
Create an empty name.
void decode_from(BER_Decoder &from) override
Definition alt_name.cpp:112
std::multimap< OID, ASN1_String > get_othernames() const
const std::vector< uint8_t > & parameters() const
Definition pkix_types.h:253
void decode_from(BER_Decoder &from) override
const OID & object_identifier() const
Definition pkix_types.h:255
const OID & oid() const
Definition pkix_types.h:251
void encode_into(DER_Encoder &to) const override
Attribute()=default
const std::vector< uint8_t > & get_parameters() const
Definition pkix_types.h:257
virtual bool should_encode() const
Definition pkix_types.h:507
virtual std::string oid_name() const =0
virtual OID oid_of() const =0
virtual std::unique_ptr< Certificate_Extension > copy() const =0
virtual std::vector< uint8_t > encode_inner() const =0
virtual void validate(const X509_Certificate &subject, const std::optional< X509_Certificate > &issuer, const std::vector< X509_Certificate > &cert_path, std::vector< std::set< Certificate_Status_Code > > &cert_status, size_t pos)
Definition x509_ext.cpp:134
virtual ~Certificate_Extension()=default
virtual void decode_inner(const std::vector< uint8_t > &)=0
const Certificate_Extension * get_extension_object(const OID &oid) const
Definition x509_ext.cpp:209
std::unique_ptr< T > get_raw(const OID &oid) const
Definition pkix_types.h:619
Extensions & operator=(const Extensions &)=default
Extensions(const Extensions &)=default
~Extensions() override=default
Extensions(Extensions &&)=default
const std::vector< OID > & get_extension_oids() const
Definition pkix_types.h:547
const T * get_extension_object_as(const OID &oid=T::static_oid()) const
Definition pkix_types.h:528
Extensions()=default
Extensions & operator=(Extensions &&)=default
X.509 GeneralName Type.
Definition pkix_types.h:274
static GeneralName email(std::string_view email)
void decode_from(BER_Decoder &from) override
GeneralName()=default
static GeneralName ipv4_address(uint32_t ipv4)
void encode_into(DER_Encoder &to) const override
static GeneralName uri(std::string_view uri)
NameType type_code() const
Definition pkix_types.h:311
static GeneralName dns(std::string_view dns)
static GeneralName directory_name(Botan::X509_DN dn)
A single Name Constraint.
Definition pkix_types.h:381
void encode_into(DER_Encoder &to) const override
const GeneralName & base() const
Definition pkix_types.h:395
void decode_from(BER_Decoder &from) override
const std::vector< GeneralSubtree > & permitted() const
Definition pkix_types.h:426
const std::vector< GeneralSubtree > & excluded() const
Definition pkix_types.h:433
void add_attribute(const OID &oid, std::string_view val)
Definition pkix_types.h:107
void add_attribute(std::string_view key, std::string_view val)
Definition x509_dn.cpp:94
X509_DN()=default
const std::vector< std::pair< OID, ASN1_String > > & dn_info() const
Definition pkix_types.h:96
X509_DN(std::initializer_list< std::pair< std::string_view, std::string_view > > args)
Definition pkix_types.h:45
bool empty() const
Definition pkix_types.h:86
const std::vector< uint8_t > & get_bits() const
Definition pkix_types.h:82
size_t count() const
Definition pkix_types.h:88
ASN1_Type
Definition asn1_obj.h:43
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition exceptn.cpp:13
std::string key_constraints_to_string(Key_Constraints c)
Definition pkix_types.h:34