Botan 2.19.2
Crypto and TLS for C&
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_obj.h>
12#include <unordered_map>
13
14namespace Botan {
15
16namespace 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*/
23BOTAN_UNSTABLE_API void add_oid(const OID& oid, const std::string& name);
24
25BOTAN_UNSTABLE_API void add_oid2str(const OID& oid, const std::string& name);
26BOTAN_UNSTABLE_API void add_str2oid(const OID& oid, const std::string& name);
27
28BOTAN_UNSTABLE_API void add_oidstr(const char* oidstr, const char* name);
29
30std::unordered_map<std::string, std::string> load_oid2str_map();
31std::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, or an empty string
37*/
38BOTAN_UNSTABLE_API std::string oid2str_or_empty(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*/
47
48BOTAN_UNSTABLE_API std::string oid2str_or_throw(const OID& oid);
49
50/**
51* See if an OID exists in the internal table.
52* @param oid the oid to check for
53* @return true if the oid is registered
54*/
55BOTAN_UNSTABLE_API bool BOTAN_DEPRECATED("Just lookup the value instead") have_oid(const std::string& oid);
56
57/**
58* Tests whether the specified OID stands for the specified name.
59* @param oid the OID to check
60* @param name the name to check
61* @return true if the specified OID stands for the specified name
62*/
63inline bool BOTAN_DEPRECATED("Use oid == OID::from_string(name)") name_of(const OID& oid, const std::string& name)
64 {
65 return (oid == str2oid_or_empty(name));
66 }
67
68/**
69* Prefer oid2str_or_empty
70*/
71inline std::string lookup(const OID& oid)
72 {
73 return oid2str_or_empty(oid);
74 }
75
76/**
77* Prefer str2oid_or_empty
78*/
79inline OID lookup(const std::string& name)
80 {
81 return str2oid_or_empty(name);
82 }
83
84inline std::string BOTAN_DEPRECATED("Use oid2str_or_empty") oid2str(const OID& oid)
85 {
86 return oid2str_or_empty(oid);
87 }
88
89inline OID BOTAN_DEPRECATED("Use str2oid_or_empty") str2oid(const std::string& name)
90 {
91 return str2oid_or_empty(name);
92 }
93
94}
95
96}
97
98#endif
std::string name
#define BOTAN_UNSTABLE_API
Definition: compiler.h:44
bool name_of(const OID &oid, const std::string &name)
Definition: oids.h:63
std::string oid2str(const OID &oid)
Definition: oids.h:84
BOTAN_UNSTABLE_API std::string oid2str_or_throw(const OID &oid)
Definition: oids.cpp:121
BOTAN_UNSTABLE_API void add_str2oid(const OID &oid, const std::string &name)
Definition: oids.cpp:106
BOTAN_UNSTABLE_API void add_oidstr(const char *oidstr, const char *name)
Definition: oids.cpp:96
BOTAN_UNSTABLE_API void add_oid2str(const OID &oid, const std::string &name)
Definition: oids.cpp:101
std::unordered_map< std::string, OID > load_str2oid_map()
Definition: oid_maps.cpp:264
BOTAN_UNSTABLE_API std::string oid2str_or_empty(const OID &oid)
Definition: oids.cpp:111
std::string lookup(const OID &oid)
Definition: oids.h:71
OID str2oid(const std::string &name)
Definition: oids.h:89
BOTAN_UNSTABLE_API bool have_oid(const std::string &oid)
Definition: oids.cpp:129
BOTAN_UNSTABLE_API void add_oid(const OID &oid, const std::string &name)
Definition: oids.cpp:91
BOTAN_UNSTABLE_API OID str2oid_or_empty(const std::string &name)
Definition: oids.cpp:116
std::unordered_map< std::string, std::string > load_oid2str_map()
Definition: oid_maps.cpp:17
Definition: alg_id.cpp:13
Definition: bigint.h:1143