Botan  1.10.9
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

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.

References Botan::OID::as_string(), Botan::Global_State_Management::global_state(), 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  }
Library_State & global_state()
void set(const std::string &section, const std::string &key, const std::string &value, bool overwrite=true)
Definition: libstate.cpp:137
OID oid
Definition: x509_ext.cpp:446
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.

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  }
Library_State & global_state()
bool is_set(const std::string &section, const std::string &key) const
Definition: libstate.cpp:126
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.

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

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::choose_sig_format(), Botan::X509_DN::contents(), Botan::AlternativeName::contents(), Botan::CVC_EAC::create_cvc_req(), Botan::CVC_EAC::create_self_signed_cert(), Botan::CMS_Encoder::digest(), 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(), 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().

32  {
33  std::string name = global_state().get("oid2str", oid.as_string());
34  if(name == "")
35  return oid.as_string();
36  return name;
37  }
Library_State & global_state()
std::string get(const std::string &section, const std::string &key) const
Definition: libstate.cpp:114
OID oid
Definition: x509_ext.cpp:446
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.

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  }
Library_State & global_state()
std::string get(const std::string &section, const std::string &key) const
Definition: libstate.cpp:114
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.

References lookup().

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