Botan 1.10.17
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
oidthe oid to register
namethe name to be associated with the oid

Definition at line 18 of file oids.cpp.

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 }
void set(const std::string &section, const std::string &key, const std::string &value, bool overwrite=true)
Definition libstate.cpp:137
std::string as_string() const
Definition asn1_oid.cpp:50
Library_State & global_state()

References add_oid(), Botan::OID::as_string(), Botan::global_state(), and Botan::Library_State::set().

Referenced by add_oid().

◆ have_oid()

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

See if an OID exists in the internal table.

Parameters
oidthe oid to check for
Returns
true if the oid is registered

Definition at line 61 of file oids.cpp.

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

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

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

◆ lookup() [1/2]

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

Resolve an OID

Parameters
oidthe OID to look up
Returns
name associated with this OID

Definition at line 31 of file oids.cpp.

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

References Botan::OID::as_string(), Botan::Library_State::get(), Botan::global_state(), and lookup().

Referenced by Botan::X509_DN::add_attribute(), Botan::X509_Cert_Options::add_ex_constraint(), Botan::AlgorithmIdentifier::AlgorithmIdentifier(), Botan::AlgorithmIdentifier::AlgorithmIdentifier(), Botan::Attribute::Attribute(), Botan::EAC_Signed_Object::check_signature(), Botan::X509_Object::check_signature(), Botan::choose_sig_format(), Botan::AlternativeName::contents(), Botan::X509_DN::contents(), Botan::CVC_EAC::create_cvc_req(), Botan::CVC_EAC::create_self_signed_cert(), Botan::CMS_Encoder::digest(), Botan::EC_Group::EC_Group(), Botan::EC_Group::EC_Group(), Botan::CMS_Encoder::encrypt(), 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::PKCS8::load_key(), lookup(), lookup(), Botan::make_cvc_cert(), Botan::make_private_key(), Botan::make_public_key(), name_of(), Botan::Certificate_Extension::oid_of(), Botan::CMS_Encoder::sign(), Botan::X509_Certificate::to_string(), Botan::X509_DN::X509_DN(), and Botan::X942_PRF::X942_PRF().

◆ 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
namethe name to resolve
Returns
OID associated with the specified name

Definition at line 42 of file oids.cpp.

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 }
OID(const std::string &str="")
Definition asn1_oid.cpp:19
Lookup_Error(const std::string &err)
Definition exceptn.h:37

References Botan::Library_State::get(), Botan::global_state(), lookup(), Botan::Lookup_Error::Lookup_Error(), and Botan::OID::OID().

◆ 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
oidthe OID to check
namethe name to check
Returns
true if the specified OID stands for the specified name

Definition at line 69 of file oids.cpp.

70 {
71 return (oid == lookup(name));
72 }
std::string lookup(const OID &oid)
Definition oids.cpp:31

References lookup(), and name_of().

Referenced by name_of().