summaryrefslogtreecommitdiffstats
path: root/old/botan/src/libstate/oid_lookup
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
parentb984b0b62076067f1f75db5a7eda5aaa2cdaad2a (diff)
Mark repository as deprecatedHEADmaster
Diffstat (limited to 'old/botan/src/libstate/oid_lookup')
-rw-r--r--old/botan/src/libstate/oid_lookup/info.txt14
-rw-r--r--old/botan/src/libstate/oid_lookup/oids.cpp76
-rw-r--r--old/botan/src/libstate/oid_lookup/oids.h58
3 files changed, 148 insertions, 0 deletions
diff --git a/old/botan/src/libstate/oid_lookup/info.txt b/old/botan/src/libstate/oid_lookup/info.txt
new file mode 100644
index 0000000..609eb91
--- /dev/null
+++ b/old/botan/src/libstate/oid_lookup/info.txt
@@ -0,0 +1,14 @@
+realname "OID Lookup"
+
+load_on dep
+
+define OID_LOOKUP
+
+<add>
+oids.cpp
+oids.h
+</add>
+
+<requires>
+asn1
+</requires>
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));
+ }
+
+}
+
+}
diff --git a/old/botan/src/libstate/oid_lookup/oids.h b/old/botan/src/libstate/oid_lookup/oids.h
new file mode 100644
index 0000000..fdfe61f
--- /dev/null
+++ b/old/botan/src/libstate/oid_lookup/oids.h
@@ -0,0 +1,58 @@
+/*
+* OID Registry
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_OIDS_H__
+#define BOTAN_OIDS_H__
+
+#include <botan/asn1_oid.h>
+
+namespace Botan {
+
+namespace OIDS {
+
+/**
+* Register an OID to string mapping.
+* @param oid the oid to register
+* @param name the name to be associated with the oid
+*/
+BOTAN_DLL void add_oid(const OID& oid, const std::string& name);
+
+/**
+* See if an OID exists in the internal table.
+* @param oid the oid to check for
+* @return true if the oid is registered
+*/
+BOTAN_DLL bool have_oid(const std::string& oid);
+
+/**
+* Resolve an OID
+* @param oid the OID to look up
+* @return the name associated with this OID
+*/
+BOTAN_DLL std::string lookup(const OID& oid);
+
+/**
+* Find the OID to a name. The lookup will be performed in the
+* general OID section of the configuration.
+* @param name the name to resolve
+* @return the OID associated with the specified name
+*/
+BOTAN_DLL OID lookup(const std::string& name);
+
+/**
+* Tests whether the specified OID stands for the specified name.
+* @param oid the OID to check
+* @param name the name to check
+* @return true if the specified OID stands for the specified name
+*/
+BOTAN_DLL bool name_of(const OID& oid, const std::string& name);
+
+}
+
+}
+
+#endif