Coverage Report

Created: 2020-05-23 13:54

/src/botan/build/include/botan/oids.h
Line
Count
Source (jump to first uncovered line)
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, or an empty string
37
*/
38
BOTAN_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
*/
46
BOTAN_UNSTABLE_API OID str2oid_or_empty(const std::string& name);
47
48
BOTAN_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
*/
55
BOTAN_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
*/
63
inline bool BOTAN_DEPRECATED("Use oid == OID::from_string(name)") name_of(const OID& oid, const std::string& name)
64
0
   {
65
0
   return (oid == str2oid_or_empty(name));
66
0
   }
67
68
/**
69
* Prefer oid2str_or_empty
70
*/
71
inline std::string lookup(const OID& oid)
72
0
   {
73
0
   return oid2str_or_empty(oid);
74
0
   }
75
76
/**
77
* Prefer str2oid_or_empty
78
*/
79
inline OID lookup(const std::string& name)
80
0
   {
81
0
   return str2oid_or_empty(name);
82
0
   }
83
84
inline std::string BOTAN_DEPRECATED("Use oid2str_or_empty") oid2str(const OID& oid)
85
0
   {
86
0
   return oid2str_or_empty(oid);
87
0
   }
88
89
inline OID BOTAN_DEPRECATED("Use str2oid_or_empty") str2oid(const std::string& name)
90
0
   {
91
0
   return str2oid_or_empty(name);
92
0
   }
93
94
}
95
96
}
97
98
#endif