Botan 3.0.0
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
14
15namespace Botan {
16
17namespace OIDS {
18
19/**
20* Register an OID to string mapping.
21* @param oid the oid to register
22* @param name the name to be associated with the oid
23*/
24BOTAN_DEPRECATED("Use OID::register_oid")
25inline void add_oid(const OID& oid, std::string_view name)
26 {
27 OID::register_oid(oid, name);
28 }
29
30BOTAN_DEPRECATED("Use OID::register_oid")
32void add_oid2str(const OID& oid, std::string_view name);
33
34BOTAN_DEPRECATED("Use OID::register_oid")
36void add_str2oid(const OID& oid, std::string_view name);
37
38BOTAN_DEPRECATED("Use OID::register_oid")
39inline void add_oidstr(const char* oidstr, const char* name)
40 {
41 OID::register_oid(OID(oidstr), name);
42 }
43
44/**
45* Resolve an OID
46* @param oid the OID to look up
47* @return name associated with this OID, or an empty string
48*/
49BOTAN_DEPRECATED("Use OID::human_name_or_empty")
50inline std::string oid2str_or_empty(const OID& oid)
51 {
52 return oid.human_name_or_empty();
53 }
54
55/**
56* Find the OID to a name. The lookup will be performed in the
57* general OID section of the configuration.
58* @param name the name to resolve
59* @return OID associated with the specified name
60*/
61BOTAN_DEPRECATED("Use OID::from_name")
62inline OID str2oid_or_empty(std::string_view name)
63 {
64 return OID::from_name(name).value_or(OID());
65 }
66
67BOTAN_DEPRECATED("Use OID::human_name_or_empty")
68inline std::string oid2str_or_throw(const OID& oid)
69 {
70 std::string s = oid.human_name_or_empty();
71 if(s.empty())
72 throw Lookup_Error("No name associated with OID " + oid.to_string());
73 return s;
74 }
75
76BOTAN_DEPRECATED("Use OID::human_name_or_empty")
77inline std::string lookup(const OID& oid)
78 {
79 return oid.human_name_or_empty();
80 }
81
82BOTAN_DEPRECATED("Use OID::from_name")
83inline OID lookup(std::string_view name)
84 {
85 return OID::from_name(name).value_or(OID());
86 }
87
88}
89
90}
91
92#endif
std::string name
#define BOTAN_DEPRECATED_HEADER(hdr)
Definition: compiler.h:148
#define BOTAN_UNSTABLE_API
Definition: compiler.h:44
Definition: alg_id.cpp:12
Definition: bigint.h:1092