Botan 1.10.17
asn1_oid.h
Go to the documentation of this file.
1/*
2* ASN.1 OID
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_ASN1_OID_H__
9#define BOTAN_ASN1_OID_H__
10
11#include <botan/asn1_int.h>
12#include <string>
13#include <vector>
14
15namespace Botan {
16
17/**
18* This class represents ASN.1 object identifiers.
19*/
20class BOTAN_DLL OID : public ASN1_Object
21 {
22 public:
23 void encode_into(class DER_Encoder&) const;
24 void decode_from(class BER_Decoder&);
25
26 /**
27 * Find out whether this OID is empty
28 * @return true is no OID value is set
29 */
30 bool is_empty() const { return id.size() == 0; }
31
32 /**
33 * Get this OID as list (vector) of its components.
34 * @return vector representing this OID
35 */
36 std::vector<u32bit> get_id() const { return id; }
37
38 /**
39 * Get this OID as a string
40 * @return string representing this OID
41 */
42 std::string as_string() const;
43
44 /**
45 * Compare two OIDs.
46 * @return true if they are equal, false otherwise
47 */
48 bool operator==(const OID&) const;
49
50 /**
51 * Reset this instance to an empty OID.
52 */
53 void clear();
54
55 /**
56 * Add a component to this OID.
57 * @param new_comp the new component to add to the end of this OID
58 * @return reference to *this
59 */
60 OID& operator+=(u32bit new_comp);
61
62 /**
63 * Construct an OID from a string.
64 * @param str a string in the form "a.b.c" etc., where a,b,c are numbers
65 */
66 OID(const std::string& str = "");
67 private:
68 std::vector<u32bit> id;
69 };
70
71/**
72* Append another component onto the OID.
73* @param oid the OID to add the new component to
74* @param new_comp the new component to add
75*/
76OID operator+(const OID& oid, u32bit new_comp);
77
78/**
79* Compare two OIDs.
80* @param a the first OID
81* @param b the second OID
82* @return true if a is not equal to b
83*/
84bool operator!=(const OID& a, const OID& b);
85
86/**
87* Compare two OIDs.
88* @param a the first OID
89* @param b the second OID
90* @return true if a is lexicographically smaller than b
91*/
92bool operator<(const OID& a, const OID& b);
93
94}
95
96#endif
std::vector< u32bit > get_id() const
Definition asn1_oid.h:36
void decode_from(class BER_Decoder &)
Definition asn1_oid.cpp:155
bool is_empty() const
Definition asn1_oid.h:30
OID(const std::string &str="")
Definition asn1_oid.cpp:19
void encode_into(class DER_Encoder &) const
Definition asn1_oid.cpp:127
bool BOTAN_DLL operator<(const X509_Time &, const X509_Time &)
Definition asn1_tm.cpp:286
OctetString operator+(const OctetString &k1, const OctetString &k2)
Definition symkey.cpp:114
bool operator!=(const OctetString &s1, const OctetString &s2)
Definition symkey.cpp:106
unsigned int u32bit
Definition types.h:32
bool operator==(const OctetString &s1, const OctetString &s2)
Definition symkey.cpp:98
MemoryRegion< T > & operator+=(MemoryRegion< T > &out, const MemoryRegion< T > &in)
Definition secmem.h:386