Botan 3.13.0
Crypto and TLS for C&
asn1_obj.h
Go to the documentation of this file.
1/*
2* (C) 1999-2007,2018,2020 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_ASN1_OBJECT_TYPES_H_
8#define BOTAN_ASN1_OBJECT_TYPES_H_
9
10#include <botan/exceptn.h>
11#include <iosfwd>
12#include <optional>
13#include <span>
14#include <string>
15#include <string_view>
16#include <vector>
17
18namespace Botan {
19
20class BER_Decoder;
21class DER_Encoder;
22class ASN1_Time; // in asn1_time.h
23
24/**
25* Alias for ASN1_Time, reflecting the name used by the X.509 ASN.1 modules
26*/
28
29/**
30* ASN.1 Class Tags
31*/
32enum class ASN1_Class : uint32_t /* NOLINT(performance-enum-size) */ {
33 Universal = 0b0000'0000,
34 Application = 0b0100'0000,
35 ContextSpecific = 0b1000'0000,
36 Private = 0b1100'0000,
37
38 Constructed = 0b0010'0000,
40
41 NoObject = 0xFF00
42};
43
44/**
45* ASN.1 Type Tags
46*/
47enum class ASN1_Type : uint32_t /* NOLINT(performance-enum-size) */ {
48 Eoc = 0x00,
49 Boolean = 0x01,
50 Integer = 0x02,
51 BitString = 0x03,
53 Null = 0x05,
54 ObjectId = 0x06,
55 Enumerated = 0x0A,
56 Sequence = 0x10,
57 Set = 0x11,
58
59 Utf8String = 0x0C,
63 Ia5String = 0x16,
66 BmpString = 0x1E,
67
68 UtcTime = 0x17,
70
71 NoObject = 0xFF00,
72};
73
74/**
75* Return true if the two class tags have any bits in common
76*/
77inline bool intersects(ASN1_Class x, ASN1_Class y) {
78 return (static_cast<uint32_t>(x) & static_cast<uint32_t>(y)) != 0;
79}
80
81/**
82* Return the bitwise combination of two type tags
83*/
85 return static_cast<ASN1_Type>(static_cast<uint32_t>(x) | static_cast<uint32_t>(y));
86}
87
88/**
89* Return the bitwise combination of two class tags
90*/
92 return static_cast<ASN1_Class>(static_cast<uint32_t>(x) | static_cast<uint32_t>(y));
93}
94
95/**
96* Combine a type tag and a class tag into a single tagging value
97*/
98inline uint32_t operator|(ASN1_Type x, ASN1_Class y) {
99 return static_cast<uint32_t>(x) | static_cast<uint32_t>(y);
100}
101
102/**
103* Combine a class tag and a type tag into a single tagging value
104*/
105inline uint32_t operator|(ASN1_Class x, ASN1_Type y) {
106 return static_cast<uint32_t>(x) | static_cast<uint32_t>(y);
107}
108
109/**
110* Return a descriptive string for an ASN.1 type tag
111*/
113
114/**
115* Return a descriptive string for an ASN.1 class tag
116*/
118
119/**
120* Basic ASN.1 Object Interface
121*/
123 public:
124 /**
125 * Encode whatever this object is into to
126 * @param to the DER_Encoder that will be written to
127 */
128 virtual void encode_into(DER_Encoder& to) const = 0;
129
130 /**
131 * Decode whatever this object is from from
132 * @param from the BER_Decoder that will be read from
133 */
134 virtual void decode_from(BER_Decoder& from) = 0;
135
136 /**
137 * Return the encoding of this object. This is a convenience
138 * method when just one object needs to be serialized. Use
139 * DER_Encoder for complicated encodings.
140 */
141 std::vector<uint8_t> BER_encode() const;
142
143 /**
144 * Default constructor
145 */
146 ASN1_Object() = default;
147
148 /**
149 * Copy constructor
150 */
151 ASN1_Object(const ASN1_Object&) = default;
152
153 /**
154 * Copy assignment
155 */
157
158 /**
159 * Move constructor
160 */
162
163 /**
164 * Move assignment
165 */
167
168 virtual ~ASN1_Object() = default;
169};
170
171/**
172* ASN.1 BIT STRING with explicit unused-bit count.
173*/
175 public:
176 /**
177 * Create an empty BIT STRING
178 */
179 ASN1_BitString() = default;
180
181 /**
182 * Create a BIT STRING from the given bits
183 *
184 * @param bytes the bits, without the leading unused-bit count octet
185 * @param unused_bits the number of unused bits in the final byte
186 *
187 * Throws Invalid_Argument if unused_bits is 8 or larger, if unused_bits is
188 * non-zero for an empty BIT STRING, or if any of the unused bits are set.
189 */
190 ASN1_BitString(std::vector<uint8_t> bytes, size_t unused_bits);
191
192 /**
193 * Create a BIT STRING from the given bits
194 *
195 * @param bytes the bits, without the leading unused-bit count octet
196 * @param unused_bits the number of unused bits in the final byte
197 *
198 * Throws Invalid_Argument if unused_bits is 8 or larger, if unused_bits is
199 * non-zero for an empty BIT STRING, or if any of the unused bits are set.
200 */
201 ASN1_BitString(std::span<const uint8_t> bytes, size_t unused_bits);
202
203 /**
204 * Return the bits, without the leading unused-bit count octet
205 */
206 std::span<const uint8_t> bytes() const { return std::span{m_bytes}; }
207
208 /**
209 * Return the number of unused bits in the final byte
210 */
211 size_t unused_bits() const { return m_unused_bits; }
212
213 /**
214 * Return the number of significant bits in this BIT STRING
215 */
216 size_t bit_length() const;
217
218 /**
219 * Return the value of a single bit, counting from the most significant bit
220 * of the first byte
221 *
222 * Throws Invalid_Argument if bit is not less than bit_length()
223 */
224 bool bit_at(size_t bit) const;
225
226 private:
227 std::vector<uint8_t> m_bytes;
228 size_t m_unused_bits = 0;
229};
230
231/**
232* BER Encoded Object
233*/
234class BOTAN_PUBLIC_API(2, 0) BER_Object final {
235 public:
236 /**
237 * Create an unset BER_Object
238 */
239 BER_Object() = default;
240
241 /**
242 * Copy constructor
243 */
244 BER_Object(const BER_Object& other) = default;
245
246 /**
247 * Move constructor
248 */
249 BER_Object(BER_Object&& other) = default;
250
251 /**
252 * Copy assignment
253 */
254 BER_Object& operator=(const BER_Object& other) = default;
255
256 /**
257 * Move assignment
258 */
259 BER_Object& operator=(BER_Object&& other) = default;
260
261 ~BER_Object();
262
263 /**
264 * Return true if this object holds a value, ie if it was not read past the
265 * end of the input
266 */
267 bool is_set() const { return m_type_tag != ASN1_Type::NoObject; }
268
269 /**
270 * Return the type and class tags combined into a single value
271 */
272 uint32_t tagging() const { return type_tag() | class_tag(); }
273
274 /**
275 * Return the type tag of this object
276 */
277 ASN1_Type type_tag() const { return m_type_tag; }
278
279 /**
280 * Return the class tag of this object
281 */
282 ASN1_Class class_tag() const { return m_class_tag; }
283
284 /**
285 * Return the type tag of this object, an alias for type_tag()
286 */
287 ASN1_Type type() const { return m_type_tag; }
288
289 /**
290 * Return the class tag of this object, an alias for class_tag()
291 */
292 ASN1_Class get_class() const { return m_class_tag; }
293
294 /**
295 * Return a pointer to the contents of this object, excluding the tag and
296 * length header
297 */
298 const uint8_t* bits() const { return m_value.data(); }
299
300 /**
301 * Return the length in bytes of the contents of this object
302 */
303 size_t length() const { return m_value.size(); }
304
305 /**
306 * Return the contents of this object, excluding the tag and length header
307 */
308 std::span<const uint8_t> data() const { return std::span{m_value}; }
309
310 /**
311 * Throw BER_Decoding_Error unless this object has the expected tagging
312 *
313 * @param type_tag the expected type tag
314 * @param class_tag the expected class tag
315 * @param descr a description of the object, used in the exception message
316 */
317 void assert_is_a(ASN1_Type type_tag, ASN1_Class class_tag, std::string_view descr = "object") const;
318
319 /**
320 * Return true if this object has the given tagging
321 *
322 * @param type_tag the expected type tag
323 * @param class_tag the expected class tag
324 */
325 bool is_a(ASN1_Type type_tag, ASN1_Class class_tag) const;
326
327 /**
328 * Return true if this object has the given tagging
329 *
330 * @param type_tag the expected type tag, typically a context specific tag number
331 * @param class_tag the expected class tag
332 */
333 bool is_a(int type_tag, ASN1_Class class_tag) const;
334
335 private:
336 ASN1_Type m_type_tag = ASN1_Type::NoObject;
337 ASN1_Class m_class_tag = ASN1_Class::Universal;
338 std::vector<uint8_t> m_value;
339
340 friend class BER_Decoder;
341
342 void set_tagging(ASN1_Type type_tag, ASN1_Class class_tag);
343
344 uint8_t* mutable_bits(size_t length) {
345 m_value.resize(length);
346 return m_value.data();
347 }
348};
349
350/*
351* ASN.1 Utility Functions
352*/
353class DataSource;
354
355namespace ASN1 {
356
357/**
358* Return the DER tag and length header of a SEQUENCE with the given contents length
359* @param contents_len the length in bytes of the SEQUENCE contents
360*/
361std::vector<uint8_t> der_sequence_header(size_t contents_len);
362
363/**
364* Return the contents wrapped in a DER SEQUENCE
365* @param val the contents of the SEQUENCE
366*/
367std::vector<uint8_t> put_in_sequence(const std::vector<uint8_t>& val);
368
369/**
370* Return the contents wrapped in a DER SEQUENCE
371* @param bits the contents of the SEQUENCE
372* @param len the length of bits in bytes
373*/
374std::vector<uint8_t> put_in_sequence(const uint8_t bits[], size_t len);
375
376/**
377* Return the contents of a BER object interpreted as a string
378* @param obj the object whose contents are converted
379*/
380std::string to_string(const BER_Object& obj);
381
382/**
383* Heuristics tests; is this object possibly BER?
384* @param src a data source that will be peeked at but not modified
385*/
386bool maybe_BER(DataSource& src);
387
388} // namespace ASN1
389
390/**
391* General BER Decoding Error Exception
392*/
394 public:
395 /**
396 * Create a BER decoding error
397 * @param err a description of the problem encountered
398 */
399 explicit BER_Decoding_Error(std::string_view err);
400};
401
402/**
403* Exception For Incorrect BER Taggings
404*/
406 public:
407 /**
408 * Create a bad tag error
409 * @param msg a description of the problem encountered
410 * @param tagging the offending tagging value
411 */
412 BER_Bad_Tag(std::string_view msg, uint32_t tagging);
413};
414
415/**
416* This class represents ASN.1 object identifiers.
417*/
418class BOTAN_PUBLIC_API(2, 0) OID final : public ASN1_Object {
419 public:
420 /**
421 * Create an uninitialised OID object
422 */
423 explicit OID() = default;
424
425 /**
426 * Construct an OID from a string.
427 * @param str a string in the form "a.b.c" etc., where a,b,c are integers
428 *
429 * Note: it is currently required that each integer fit into 32 bits
430 */
431 explicit OID(std::string_view str);
432
433 /**
434 * Initialize an OID from a sequence of integer values
435 */
436 OID(std::initializer_list<uint32_t> init);
437
438 /**
439 * Initialize an OID from a vector of integer values
440 */
441 explicit OID(std::vector<uint32_t>&& init);
442
443 /**
444 * Construct an OID from a string.
445 * @param str a string in the form "a.b.c" etc., where a,b,c are numbers
446 * or any known OID name (for example "RSA" or "X509v3.SubjectKeyIdentifier")
447 */
448 static OID from_string(std::string_view str);
449
450 /**
451 * Construct an OID from a name
452 * @param name any known OID name (for example "RSA" or "X509v3.SubjectKeyIdentifier")
453 */
454 static std::optional<OID> from_name(std::string_view name);
455
456 /**
457 * Register a new OID in the internal table
458 */
459 static void register_oid(const OID& oid, std::string_view name);
460
461 void encode_into(DER_Encoder& to) const override;
462 void decode_from(BER_Decoder& from) override;
463
464 /**
465 * Find out whether this OID is empty
466 * @return true is no OID value is set
467 */
468 bool empty() const { return m_id.empty(); }
469
470 /**
471 * Find out whether this OID has a value
472 * @return true is this OID has a value
473 */
474 bool has_value() const { return !empty(); }
475
476 /**
477 * Get this OID as a dotted-decimal string
478 * @return string representing this OID
479 */
480 std::string to_string() const;
481
482 /**
483 * If there is a known name associated with this OID, return that.
484 * Otherwise return the result of to_string
485 */
486 std::string to_formatted_string() const;
487
488 /**
489 * If there is a known name associated with this OID, return that.
490 * Otherwise return the empty string.
491 */
492 std::string human_name_or_empty() const;
493
494 /**
495 * If there is a known name associated with this OID, return that.
496 * Otherwise return nullopt.
497 */
498 std::optional<std::string> registered_name() const;
499
500 /**
501 * Return true if the OID in *this is registered in the internal
502 * set of constants as a known OID.
503 */
504 bool registered_oid() const;
505
506 /**
507 * Compare two OIDs.
508 * @return true if they are equal, false otherwise
509 */
510 bool operator==(const OID& other) const { return m_id == other.m_id; }
511
512 /**
513 * Return a hash code for this OID
514 *
515 * This value is only meant as a std::unordered_map hash and
516 * can change value from release to release.
517 */
518 uint64_t hash_code() const;
519
520 /**
521 * Check if this OID matches the provided value
522 */
523 bool matches(std::initializer_list<uint32_t> other) const;
524
525 /**
526 * Get this OID as list (vector) of its components.
527 * @return vector representing this OID
528 */
529 BOTAN_DEPRECATED("Do not access the integer values, use eg to_string")
530 const std::vector<uint32_t>& get_components() const {
531 return m_id;
532 }
533
534 /**
535 * Get this OID as list (vector) of its components.
536 * @return vector representing this OID
537 */
538 BOTAN_DEPRECATED("Do not access the integer values, use eg to_string")
539 const std::vector<uint32_t>& get_id() const {
540 return m_id;
541 }
542
543 private:
544 std::vector<uint32_t> m_id;
545};
546
547/**
548* Write an OID to a stream, in the format produced by OID::to_string
549* @param out the stream to write to
550* @param oid the OID to write
551* @return the stream
552*/
553BOTAN_PUBLIC_API(3, 0) std::ostream& operator<<(std::ostream& out, const OID& oid);
554
555/**
556* Compare two OIDs.
557* @param a the first OID
558* @param b the second OID
559* @return true if a is not equal to b
560*/
561inline bool operator!=(const OID& a, const OID& b) {
562 return !(a == b);
563}
564
565/**
566* Compare two OIDs.
567* @param a the first OID
568* @param b the second OID
569* @return true if a is lexicographically smaller than b
570*/
571BOTAN_PUBLIC_API(2, 0) bool operator<(const OID& a, const OID& b);
572
573/**
574* ASN.1 string type
575* This class normalizes all inputs to a UTF-8 std::string
576*/
577class BOTAN_PUBLIC_API(2, 0) ASN1_String final : public ASN1_Object {
578 public:
579 void encode_into(DER_Encoder& to) const override;
580 void decode_from(BER_Decoder& from) override;
581
582 /**
583 * Return the string type tag this value was encoded with
584 */
585 ASN1_Type tagging() const { return m_tag; }
586
587 /**
588 * Return the value of this string, converted to UTF-8
589 */
590 const std::string& value() const { return m_utf8_str; }
591
592 /**
593 * Return the length in bytes of the UTF-8 representation of this string
594 */
595 size_t size() const { return value().size(); }
596
597 /**
598 * Return true if this string is empty
599 */
600 bool empty() const { return m_utf8_str.empty(); }
601
602 /**
603 * Return true iff this is a tag for a known string type we can handle.
604 */
605 static bool is_string_type(ASN1_Type tag);
606
607 /**
608 * Compare two strings, ignoring the type tag they were encoded with
609 */
610 bool operator==(const ASN1_String& other) const { return value() == other.value(); }
611
612 friend bool operator<(const ASN1_String& a, const ASN1_String& b) { return a.value() < b.value(); }
613
614 /**
615 * Create a string, tagged as PrintableString if possible and otherwise as
616 * Utf8String
617 *
618 * @param utf8 the value of the string, encoded as UTF-8
619 */
620 explicit ASN1_String(std::string_view utf8 = "");
621
622 /**
623 * Create a string with a specific type tag
624 *
625 * @param utf8 the value of the string, encoded as UTF-8
626 * @param tag the string type tag to encode this value with
627 *
628 * Throws Invalid_Argument if tag is not a string type that is a subset of
629 * UTF-8, or if utf8 is not a valid value for that type.
630 */
631 ASN1_String(std::string_view utf8, ASN1_Type tag);
632
633 private:
634 std::vector<uint8_t> m_data;
635 std::string m_utf8_str;
636 ASN1_Type m_tag;
637};
638
639/**
640* Algorithm Identifier
641*/
643 public:
644 /**
645 * Selects how an absent parameters field is encoded
646 */
647 enum Encoding_Option : uint8_t { USE_NULL_PARAM, USE_EMPTY_PARAM }; /* NOLINT(*-use-enum-class) */
648
649 void encode_into(DER_Encoder& to) const override;
650 void decode_from(BER_Decoder& from) override;
651
652 /**
653 * Create an empty AlgorithmIdentifier
654 */
656
657 /**
658 * Create an AlgorithmIdentifier with no parameters
659 * @param oid the algorithm OID
660 * @param enc whether the empty parameters are encoded as NULL or omitted
661 */
663
664 /**
665 * Create an AlgorithmIdentifier with no parameters
666 * @param oid_name a name or dotted decimal string identifying the algorithm
667 * @param enc whether the empty parameters are encoded as NULL or omitted
668 */
669 AlgorithmIdentifier(std::string_view oid_name, Encoding_Option enc);
670
671 /**
672 * Create an AlgorithmIdentifier
673 * @param oid the algorithm OID
674 * @param params the DER encoded parameters
675 */
676 AlgorithmIdentifier(const OID& oid, const std::vector<uint8_t>& params);
677
678 /**
679 * Create an AlgorithmIdentifier
680 * @param oid_name a name or dotted decimal string identifying the algorithm
681 * @param params the DER encoded parameters
682 */
683 AlgorithmIdentifier(std::string_view oid_name, const std::vector<uint8_t>& params);
684
685 /**
686 * Return the algorithm OID
687 */
688 const OID& oid() const { return m_oid; }
689
690 /**
691 * Return the DER encoded parameters, which may be empty
692 */
693 const std::vector<uint8_t>& parameters() const { return m_parameters; }
694
695 /**
696 * Return the algorithm OID
697 */
698 BOTAN_DEPRECATED("Use AlgorithmIdentifier::oid") const OID& get_oid() const { return m_oid; }
699
700 /**
701 * Return the DER encoded parameters, which may be empty
702 */
703 BOTAN_DEPRECATED("Use AlgorithmIdentifier::parameters") const std::vector<uint8_t>& get_parameters() const {
704 return m_parameters;
705 }
706
707 /**
708 * Return true if the parameters consist of a single DER encoded NULL
709 */
710 bool parameters_are_null() const;
711
712 /**
713 * Return true if the parameters field is absent
714 */
715 bool parameters_are_empty() const { return m_parameters.empty(); }
716
717 /**
718 * Return true if the parameters field is absent or a single DER encoded NULL
719 */
721
722 /**
723 * Return true if neither the OID nor the parameters have been set
724 */
725 bool empty() const { return m_oid.empty() && m_parameters.empty(); }
726
727 private:
728 OID m_oid;
729 std::vector<uint8_t> m_parameters;
730};
731
732/**
733* Compare two AlgorithmIdentifiers
734*
735* @param x the first AlgorithmIdentifier
736* @param y the second AlgorithmIdentifier
737* @return true if x is equal to y
738*/
739BOTAN_PUBLIC_API(2, 0) bool operator==(const AlgorithmIdentifier& x, const AlgorithmIdentifier& y);
740
741/**
742* Compare two AlgorithmIdentifiers
743*
744* @param x the first AlgorithmIdentifier
745* @param y the second AlgorithmIdentifier
746* @return true if x is not equal to y
747*/
748BOTAN_PUBLIC_API(2, 0) bool operator!=(const AlgorithmIdentifier& x, const AlgorithmIdentifier& y);
749
750} // namespace Botan
751
752/**
753* Specialization of std::hash allowing OIDs to be used as keys in unordered containers
754*/
755template <>
756class std::hash<Botan::OID> {
757 public:
758 /**
759 * Return a hash of the OID; see OID::hash_code
760 */
761 size_t operator()(const Botan::OID& oid) const noexcept { return static_cast<size_t>(oid.hash_code()); }
762};
763
764/*
765In 3.11 ASN1_Time was split out to its own header as <chrono> is huge in C++20
766However we continue to include this header (when not building the library),
767to avoid breaking applications which would expect it to still be available.
768
769TODO(Botan4) remove this
770*/
771#if defined(BOTAN_AMALGAMATION_H_) || (!defined(BOTAN_IS_BEING_BUILT) && !defined(__clang_analyzer__))
772 #include <botan/asn1_time.h>
773#endif
774
775#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
size_t unused_bits() const
Definition asn1_obj.h:211
std::span< const uint8_t > bytes() const
Definition asn1_obj.h:206
ASN1_Object & operator=(ASN1_Object &&)=default
ASN1_Object & operator=(const ASN1_Object &)=default
ASN1_Object(const ASN1_Object &)=default
virtual ~ASN1_Object()=default
ASN1_Object(ASN1_Object &&)=default
virtual void decode_from(BER_Decoder &from)=0
ASN1_Object()=default
virtual void encode_into(DER_Encoder &to) const =0
std::vector< uint8_t > BER_encode() const
Definition asn1_obj.cpp:21
const std::string & value() const
Definition asn1_obj.h:590
ASN1_String(std::string_view utf8="")
Definition asn1_str.cpp:145
bool empty() const
Definition asn1_obj.h:600
size_t size() const
Definition asn1_obj.h:595
bool operator==(const ASN1_String &other) const
Definition asn1_obj.h:610
friend bool operator<(const ASN1_String &a, const ASN1_String &b)
Definition asn1_obj.h:612
void encode_into(DER_Encoder &to) const override
Definition asn1_str.cpp:150
ASN1_Type tagging() const
Definition asn1_obj.h:585
void decode_from(BER_Decoder &from) override
Definition asn1_str.cpp:162
bool parameters_are_empty() const
Definition asn1_obj.h:715
bool parameters_are_null_or_empty() const
Definition asn1_obj.h:720
const std::vector< uint8_t > & parameters() const
Definition asn1_obj.h:693
bool parameters_are_null() const
Definition alg_id.cpp:50
const OID & oid() const
Definition asn1_obj.h:688
const std::vector< uint8_t > & get_parameters() const
Definition asn1_obj.h:703
const OID & get_oid() const
Definition asn1_obj.h:698
BER_Bad_Tag(std::string_view msg, uint32_t tagging)
Definition asn1_obj.cpp:201
BER_Decoding_Error(std::string_view err)
Definition asn1_obj.cpp:199
size_t length() const
Definition asn1_obj.h:303
BER_Object(BER_Object &&other)=default
friend class BER_Decoder
Definition asn1_obj.h:340
const uint8_t * bits() const
Definition asn1_obj.h:298
BER_Object & operator=(const BER_Object &other)=default
ASN1_Type type_tag() const
Definition asn1_obj.h:277
uint32_t tagging() const
Definition asn1_obj.h:272
BER_Object(const BER_Object &other)=default
bool is_set() const
Definition asn1_obj.h:267
std::span< const uint8_t > data() const
Definition asn1_obj.h:308
BER_Object & operator=(BER_Object &&other)=default
BER_Object()=default
ASN1_Type type() const
Definition asn1_obj.h:287
ASN1_Class get_class() const
Definition asn1_obj.h:292
ASN1_Class class_tag() const
Definition asn1_obj.h:282
Decoding_Error(std::string_view name)
Definition exceptn.cpp:125
const std::vector< uint32_t > & get_id() const
Definition asn1_obj.h:539
const std::vector< uint32_t > & get_components() const
Definition asn1_obj.h:530
bool operator==(const OID &other) const
Definition asn1_obj.h:510
static std::optional< OID > from_name(std::string_view name)
Definition asn1_oid.cpp:66
static void register_oid(const OID &oid, std::string_view name)
Definition asn1_oid.cpp:61
void decode_from(BER_Decoder &from) override
Definition asn1_oid.cpp:225
OID()=default
bool has_value() const
Definition asn1_obj.h:474
bool empty() const
Definition asn1_obj.h:468
void encode_into(DER_Encoder &to) const override
Definition asn1_oid.cpp:185
static OID from_string(std::string_view str)
Definition asn1_oid.cpp:80
size_t operator()(const Botan::OID &oid) const noexcept
Definition asn1_obj.h:761
std::vector< uint8_t > put_in_sequence(const std::vector< uint8_t > &contents)
Definition asn1_obj.cpp:208
std::vector< uint8_t > der_sequence_header(size_t contents_len)
Definition der_enc.cpp:71
bool maybe_BER(DataSource &source)
Definition asn1_obj.cpp:231
std::string to_string(const BER_Object &obj)
Definition asn1_obj.cpp:224
ASN1_Type operator|(ASN1_Type x, ASN1_Type y)
Definition asn1_obj.h:84
ASN1_Time X509_Time
Definition asn1_obj.h:27
std::string asn1_tag_to_string(ASN1_Type type)
Definition asn1_obj.cpp:129
ASN1_Class
Definition asn1_obj.h:32
ASN1_Type
Definition asn1_obj.h:47
std::string asn1_class_to_string(ASN1_Class type)
Definition asn1_obj.cpp:110
bool intersects(ASN1_Class x, ASN1_Class y)
Definition asn1_obj.h:77
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition exceptn.cpp:13