Botan 1.10.17

Functions
Botan::OIDS Namespace Reference

## Functions
void | add_oid (const OID &oid, const std::string &name)
bool | have_oid (const std::string &name)
std::string | lookup (const OID &oid)
OID | lookup (const std::string &name)
bool | name_of (const OID &oid, const std::string &name)

## Function Documentation

## ◆ add_oid()

BOTAN_DLL void Botan::OIDS::add_oid | ( | const OID & | oid,
|  | const std::string & | name
| ) |  |

Register an OID to string mapping.

Parameters

  oid | the oid to register
  name | the name to be associated with the oid

Definition at line 18 of file oids.cpp.

References Botan::Global_State_Management::global_state(), oid, and Botan::Library_State::set().

19 {
20 const std::string oid_str = oid.as_string();
21
22 if(!global_state().is_set("oid2str", oid_str))
23 global_state().set("oid2str", oid_str, name);
24 if(!global_state().is_set("str2oid", name))
25 global_state().set("str2oid", name, oid_str);
26 }
Botan::Global_State_Management::global_state
Library_State & global_state()
Definition: global_state.cpp:32
Botan::Library_State::set
void set(const std::string &section, const std::string &key, const std::string &value, bool overwrite=true)
Definition: libstate.cpp:137
oid
OID oid
Definition: x509_ext.cpp:446

## ◆ have_oid()

BOTAN_DLL bool Botan::OIDS::have_oid | ( | const std::string & | oid | ) |

See if an OID exists in the internal table.

Parameters

  oid | the oid to check for

Returns
  true if the oid is registered

Definition at line 61 of file oids.cpp.

References Botan::Global_State_Management::global_state(), and Botan::Library_State::is_set().

Referenced by Botan::CMS_Encoder::digest(), and Botan::X942_PRF::X942_PRF().

62 {
63 return global_state().is_set("str2oid", name);
64 }
Botan::Library_State::is_set
bool is_set(const std::string &section, const std::string &key) const
Definition: libstate.cpp:126
Botan::Global_State_Management::global_state
Library_State & global_state()
Definition: global_state.cpp:32

## ◆ lookup() [1/2]

BOTAN_DLL std::string Botan::OIDS::lookup | ( | const OID & | oid | ) |

Resolve an OID

Parameters

  oid | the OID to look up

Returns
  name associated with this OID

Definition at line 31 of file oids.cpp.

References Botan::Library_State::get(), Botan::Global_State_Management::global_state(), and oid.

Referenced by Botan::X509_DN::add_attribute(), Botan::X509_Cert_Options::add_ex_constraint(), Botan::AlgorithmIdentifier::AlgorithmIdentifier(), Botan::Attribute::Attribute(), Botan::EAC_Signed_Object::check_signature(), Botan::X509_Object::check_signature(), Botan::X509_DN::contents(), Botan::AlternativeName::contents(), Botan::CMS_Encoder::digest(), Botan::EC_Group::EC_Group(), Botan::X509_DN::get_attribute(), Botan::CMS_Encoder::get_contents(), Botan::Public_Key::get_oid(), Botan::get_pbe(), Botan::X509_Object::hash_used_for_signature(), Botan::CMS_Decoder::layer_type(), Botan::make_public_key(), name_of(), Botan::Certificate_Extension::oid_of(), Botan::X509_Certificate::to_string(), Botan::X509_DN::X509_DN(), and Botan::X942_PRF::X942_PRF().

32 {
33 std::string name = global_state().get("oid2str", oid.as_string());
34 if(name == "")
35 return oid.as_string();
36 return name;
37 }
Botan::Global_State_Management::global_state
Library_State & global_state()
Definition: global_state.cpp:32
Botan::Library_State::get
std::string get(const std::string &section, const std::string &key) const
Definition: libstate.cpp:114
oid
OID oid
Definition: x509_ext.cpp:446

## ◆ lookup() [2/2]

BOTAN_DLL OID Botan::OIDS::lookup | ( | const std::string & | name | ) |

Find the OID to a name. The lookup will be performed in the general OID section of the configuration.

Parameters

  name | the name to resolve

Returns
  OID associated with the specified name

Definition at line 42 of file oids.cpp.

References Botan::Library_State::get(), and Botan::Global_State_Management::global_state().

43 {
44 std::string value = global_state().get("str2oid", name);
45 if(value != "")
46 return OID(value);
47
48 try
49 {
50 return OID(name);
51 }
52 catch(...)
53 {
54 throw Lookup_Error("No object identifier found for " + name);
55 }
56 }
Botan::Global_State_Management::global_state
Library_State & global_state()
Definition: global_state.cpp:32
Botan::Library_State::get
std::string get(const std::string &section, const std::string &key) const
Definition: libstate.cpp:114

## ◆ name_of()

BOTAN_DLL bool Botan::OIDS::name_of | ( | const OID & | oid,
|  | const std::string & | name
| ) |  |

Tests whether the specified OID stands for the specified name.

Parameters

  oid | the OID to check
  name | the name to check

Returns
  true if the specified OID stands for the specified name

Definition at line 69 of file oids.cpp.

References lookup(), and oid.

70 {
71 return (oid == lookup(name));
72 }
oid
OID oid
Definition: x509_ext.cpp:446
Botan::OIDS::lookup
OID lookup(const std::string &name)
Definition: oids.cpp:42