summaryrefslogtreecommitdiffstats
path: root/old/botan/src/libstate/oid_lookup/oids.cpp
diff options
context:
space:
mode:
authorDavid Clark <david.a.clark@nokia.com>2010-11-18 16:20:48 +1000
committerDavid Clark <david.a.clark@nokia.com>2010-11-18 16:20:48 +1000
commitc223232bc15106750da632598047a35ad3762723 (patch)
tree403f7aa2c3a5a912edce6feae869046c89d29178 /old/botan/src/libstate/oid_lookup/oids.cpp
parentb984b0b62076067f1f75db5a7eda5aaa2cdaad2a (diff)
Mark repository as deprecatedHEADmaster
Diffstat (limited to 'old/botan/src/libstate/oid_lookup/oids.cpp')
-rw-r--r--old/botan/src/libstate/oid_lookup/oids.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/old/botan/src/libstate/oid_lookup/oids.cpp b/old/botan/src/libstate/oid_lookup/oids.cpp
new file mode 100644
index 0000000..232c633
--- /dev/null
+++ b/old/botan/src/libstate/oid_lookup/oids.cpp
@@ -0,0 +1,76 @@
+/*
+* OID Registry
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/oids.h>
+#include <botan/libstate.h>
+
+namespace Botan {
+
+namespace OIDS {
+
+/*
+* Register an OID to string mapping
+*/
+void add_oid(const OID& oid, const std::string& name)
+ {
+ const std::string oid_str = oid.as_string();
+
+ if(!global_state().is_set("oid2str", oid_str))
+ global_state().set("oid2str", oid_str, name);
+ if(!global_state().is_set("str2oid", name))
+ global_state().set("str2oid", name, oid_str);
+ }
+
+/*
+* Do an OID to string lookup
+*/
+std::string lookup(const OID& oid)
+ {
+ std::string name = global_state().get("oid2str", oid.as_string());
+ if(name == "")
+ return oid.as_string();
+ return name;
+ }
+
+/*
+* Do a string to OID lookup
+*/
+OID lookup(const std::string& name)
+ {
+ std::string value = global_state().get("str2oid", name);
+ if(value != "")
+ return OID(value);
+
+ try
+ {
+ return OID(name);
+ }
+ catch(Exception)
+ {
+ throw Lookup_Error("No object identifier found for " + name);
+ }
+ }
+
+/*
+* Check to see if an OID exists in the table
+*/
+bool have_oid(const std::string& name)
+ {
+ return global_state().is_set("str2oid", name);
+ }
+
+/*
+* Check to see if an OID exists in the table
+*/
+bool name_of(const OID& oid, const std::string& name)
+ {
+ return (oid == lookup(name));
+ }
+
+}
+
+}