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