Botan  2.6.0
Crypto and TLS for C++11
oids.h
Go to the documentation of this file.
1 /*
2 * OID Registry
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_OIDS_H_
9 #define BOTAN_OIDS_H_
10 
11 #include <botan/asn1_oid.h>
12 #include <unordered_map>
13 
14 namespace Botan {
15 
16 namespace OIDS {
17 
18 /**
19 * Register an OID to string mapping.
20 * @param oid the oid to register
21 * @param name the name to be associated with the oid
22 */
23 BOTAN_UNSTABLE_API void add_oid(const OID& oid, const std::string& name);
24 
25 BOTAN_UNSTABLE_API void add_oid2str(const OID& oid, const std::string& name);
26 BOTAN_UNSTABLE_API void add_str2oid(const OID& oid, const std::string& name);
27 
28 BOTAN_UNSTABLE_API void add_oidstr(const char* oidstr, const char* name);
29 
30 std::unordered_map<std::string, std::string> load_oid2str_map();
31 std::unordered_map<std::string, OID> load_str2oid_map();
32 
33 /**
34 * Resolve an OID
35 * @param oid the OID to look up
36 * @return name associated with this OID
37 */
38 BOTAN_PUBLIC_API(2,0) std::string lookup(const OID& oid);
39 
40 /**
41 * Find the OID to a name. The lookup will be performed in the
42 * general OID section of the configuration.
43 * @param name the name to resolve
44 * @return OID associated with the specified name
45 */
46 BOTAN_PUBLIC_API(2,0) OID lookup(const std::string& name);
47 
48 inline std::string oid2str(const OID& oid)
49  {
50  return lookup(oid);
51  }
52 
53 inline OID str2oid(const std::string& name)
54  {
55  return lookup(name);
56  }
57 
58 /**
59 * See if an OID exists in the internal table.
60 * @param oid the oid to check for
61 * @return true if the oid is registered
62 */
63 BOTAN_UNSTABLE_API bool have_oid(const std::string& oid);
64 
65 /**
66 * Tests whether the specified OID stands for the specified name.
67 * @param oid the OID to check
68 * @param name the name to check
69 * @return true if the specified OID stands for the specified name
70 */
71 BOTAN_UNSTABLE_API bool name_of(const OID& oid, const std::string& name);
72 }
73 
74 }
75 
76 #endif
#define BOTAN_UNSTABLE_API
Definition: compiler.h:34
std::unordered_map< std::string, std::string > load_oid2str_map()
Definition: oid_maps.cpp:17
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Definition: bigint.h:719
std::unordered_map< std::string, OID > load_str2oid_map()
Definition: oid_maps.cpp:221
void add_oid(const OID &oid, const std::string &name)
Definition: oids.cpp:93
void add_str2oid(const OID &oid, const std::string &name)
Definition: oids.cpp:108
bool have_oid(const std::string &name)
Definition: oids.cpp:123
OID str2oid(const std::string &name)
Definition: oids.h:53
void add_oidstr(const char *oidstr, const char *name)
Definition: oids.cpp:98
Definition: alg_id.cpp:13
bool name_of(const OID &oid, const std::string &name)
Definition: oids.cpp:128
void add_oid2str(const OID &oid, const std::string &name)
Definition: oids.cpp:103
std::string oid2str(const OID &oid)
Definition: oids.h:48
std::string lookup(const OID &oid)
Definition: oids.cpp:113