summaryrefslogtreecommitdiffstats
path: root/old/botan/src/libstate
diff options
context:
space:
mode:
Diffstat (limited to 'old/botan/src/libstate')
-rw-r--r--old/botan/src/libstate/botan.h18
-rw-r--r--old/botan/src/libstate/get_enc.cpp238
-rw-r--r--old/botan/src/libstate/info.txt45
-rw-r--r--old/botan/src/libstate/init.cpp75
-rw-r--r--old/botan/src/libstate/init.h41
-rw-r--r--old/botan/src/libstate/libstate.cpp338
-rw-r--r--old/botan/src/libstate/libstate.h125
-rw-r--r--old/botan/src/libstate/look_pk.cpp76
-rw-r--r--old/botan/src/libstate/look_pk.h78
-rw-r--r--old/botan/src/libstate/lookup.cpp296
-rw-r--r--old/botan/src/libstate/lookup.h239
-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
-rw-r--r--old/botan/src/libstate/pk_engine.cpp175
-rw-r--r--old/botan/src/libstate/pk_engine.h95
-rw-r--r--old/botan/src/libstate/policy.cpp511
-rw-r--r--old/botan/src/libstate/scan_name.cpp74
-rw-r--r--old/botan/src/libstate/scan_name.h77
19 files changed, 2649 insertions, 0 deletions
diff --git a/old/botan/src/libstate/botan.h b/old/botan/src/libstate/botan.h
new file mode 100644
index 0000000..3fa1312
--- /dev/null
+++ b/old/botan/src/libstate/botan.h
@@ -0,0 +1,18 @@
+/**
+* A vague catch all include file for Botan
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/init.h>
+#include <botan/lookup.h>
+#include <botan/libstate.h>
+#include <botan/version.h>
+#include <botan/parsing.h>
+
+#include <botan/rng.h>
+
+#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
+ #include <botan/auto_rng.h>
+#endif
diff --git a/old/botan/src/libstate/get_enc.cpp b/old/botan/src/libstate/get_enc.cpp
new file mode 100644
index 0000000..ab4d158
--- /dev/null
+++ b/old/botan/src/libstate/get_enc.cpp
@@ -0,0 +1,238 @@
+/*
+* PBKDF/EMSA/EME/KDF/MGF Retrieval
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/lookup.h>
+#include <botan/libstate.h>
+#include <botan/scan_name.h>
+
+#if defined(BOTAN_HAS_PBKDF1)
+ #include <botan/pbkdf1.h>
+#endif
+
+#if defined(BOTAN_HAS_PBKDF2)
+ #include <botan/pbkdf2.h>
+ #include <botan/hmac.h>
+#endif
+
+#if defined(BOTAN_HAS_PGPS2K)
+ #include <botan/pgp_s2k.h>
+#endif
+
+#if defined(BOTAN_HAS_MGF1)
+ #include <botan/mgf1.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA1)
+ #include <botan/emsa1.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA1_BSI)
+ #include <botan/emsa1_bsi.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA2)
+ #include <botan/emsa2.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA3)
+ #include <botan/emsa3.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA4)
+ #include <botan/emsa4.h>
+#endif
+
+#if defined(BOTAN_HAS_EMSA_RAW)
+ #include <botan/emsa_raw.h>
+#endif
+
+#if defined(BOTAN_HAS_EME1)
+ #include <botan/eme1.h>
+#endif
+
+#if defined(BOTAN_HAS_EME_PKCS1v15)
+ #include <botan/eme_pkcs.h>
+#endif
+
+#if defined(BOTAN_HAS_KDF1)
+ #include <botan/kdf1.h>
+#endif
+
+#if defined(BOTAN_HAS_KDF2)
+ #include <botan/kdf2.h>
+#endif
+
+#if defined(BOTAN_HAS_X942_PRF)
+ #include <botan/prf_x942.h>
+#endif
+
+#if defined(BOTAN_HAS_SSL_V3_PRF)
+ #include <botan/prf_ssl3.h>
+#endif
+
+#if defined(BOTAN_HAS_TLS_V10_PRF)
+ #include <botan/prf_tls.h>
+#endif
+
+namespace Botan {
+
+/*
+* Get a S2K algorithm by name
+*/
+S2K* get_s2k(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+ Algorithm_Factory& af = global_state().algorithm_factory();
+
+#if defined(BOTAN_HAS_PBKDF1)
+ if(request.algo_name() == "PBKDF1" && request.arg_count() == 1)
+ return new PKCS5_PBKDF1(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_PBKDF2)
+ if(request.algo_name() == "PBKDF2" && request.arg_count() == 1)
+ return new PKCS5_PBKDF2(new HMAC(af.make_hash_function(request.arg(0))));
+#endif
+
+#if defined(BOTAN_HAS_PGPS2K)
+ if(request.algo_name() == "OpenPGP-S2K" && request.arg_count() == 1)
+ return new OpenPGP_S2K(af.make_hash_function(request.arg(0)));
+#endif
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+/*
+* Get an EMSA by name
+*/
+EMSA* get_emsa(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+ Algorithm_Factory& af = global_state().algorithm_factory();
+
+#if defined(BOTAN_HAS_EMSA_RAW)
+ if(request.algo_name() == "Raw" && request.arg_count() == 0)
+ return new EMSA_Raw;
+#endif
+
+#if defined(BOTAN_HAS_EMSA1)
+ if(request.algo_name() == "EMSA1" && request.arg_count() == 1)
+ return new EMSA1(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_EMSA1_BSI)
+ if(request.algo_name() == "EMSA1_BSI" && request.arg_count() == 1)
+ return new EMSA1_BSI(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_EMSA2)
+ if(request.algo_name() == "EMSA2" && request.arg_count() == 1)
+ return new EMSA2(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_EMSA3)
+ if(request.algo_name() == "EMSA3" && request.arg_count() == 1)
+ {
+ if(request.arg(0) == "Raw")
+ return new EMSA3_Raw;
+ return new EMSA3(af.make_hash_function(request.arg(0)));
+ }
+#endif
+
+#if defined(BOTAN_HAS_EMSA4)
+ if(request.algo_name() == "EMSA4" && request.arg_count_between(1, 3))
+ {
+ // 3 args: Hash, MGF, salt size (MGF is hardcoded MGF1 in Botan)
+ if(request.arg_count() == 1)
+ return new EMSA4(af.make_hash_function(request.arg(0)));
+
+ if(request.arg_count() == 2 && request.arg(1) != "MGF1")
+ return new EMSA4(af.make_hash_function(request.arg(0)));
+
+ if(request.arg_count() == 3)
+ return new EMSA4(af.make_hash_function(request.arg(0)),
+ request.arg_as_u32bit(2, 0));
+ }
+#endif
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+/*
+* Get an EME by name
+*/
+EME* get_eme(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+ Algorithm_Factory& af = global_state().algorithm_factory();
+
+ if(request.algo_name() == "Raw")
+ return 0; // No padding
+
+#if defined(BOTAN_HAS_EME_PKCS1v15)
+ if(request.algo_name() == "PKCS1v15" && request.arg_count() == 0)
+ return new EME_PKCS1v15;
+#endif
+
+#if defined(BOTAN_HAS_EME1)
+ if(request.algo_name() == "EME1" && request.arg_count_between(1, 2))
+ {
+ if(request.arg_count() == 1 ||
+ (request.arg_count() == 2 && request.arg(1) == "MGF1"))
+ {
+ return new EME1(af.make_hash_function(request.arg(0)));
+ }
+ }
+#endif
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+/*
+* Get an KDF by name
+*/
+KDF* get_kdf(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+ Algorithm_Factory& af = global_state().algorithm_factory();
+
+ if(request.algo_name() == "Raw")
+ return 0; // No KDF
+
+#if defined(BOTAN_HAS_KDF1)
+ if(request.algo_name() == "KDF1" && request.arg_count() == 1)
+ return new KDF1(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_KDF2)
+ if(request.algo_name() == "KDF2" && request.arg_count() == 1)
+ return new KDF2(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_X942_PRF)
+ if(request.algo_name() == "X9.42-PRF" && request.arg_count() == 1)
+ return new X942_PRF(request.arg(0)); // OID
+#endif
+
+#if defined(BOTAN_HAS_TLS_V10_PRF)
+ if(request.algo_name() == "TLS-PRF" && request.arg_count() == 0)
+ return new TLS_PRF;
+#endif
+
+#if defined(BOTAN_HAS_SSL_V3_PRF)
+ if(request.algo_name() == "SSL3-PRF" && request.arg_count() == 0)
+ return new SSL3_PRF;
+#endif
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+}
diff --git a/old/botan/src/libstate/info.txt b/old/botan/src/libstate/info.txt
new file mode 100644
index 0000000..6eaa2f7
--- /dev/null
+++ b/old/botan/src/libstate/info.txt
@@ -0,0 +1,45 @@
+realname "Botan Libstate Module"
+
+load_on always
+
+define LIBSTATE_MODULE
+
+<add>
+botan.h
+get_enc.cpp
+init.cpp
+init.h
+libstate.cpp
+libstate.h
+look_pk.cpp
+look_pk.h
+lookup.cpp
+lookup.h
+pk_engine.cpp
+pk_engine.h
+policy.cpp
+scan_name.cpp
+scan_name.h
+</add>
+
+<requires>
+algo_factory
+alloc
+bigint
+block
+def_engine
+engine
+filters
+hash
+kdf
+mac
+mode_pad
+mutex
+noop_mutex
+pk_pad
+pubkey
+rng
+s2k
+stream
+system_alloc
+</requires>
diff --git a/old/botan/src/libstate/init.cpp b/old/botan/src/libstate/init.cpp
new file mode 100644
index 0000000..b908de6
--- /dev/null
+++ b/old/botan/src/libstate/init.cpp
@@ -0,0 +1,75 @@
+/**
+* Default Initialization Function
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/init.h>
+#include <botan/parsing.h>
+#include <botan/libstate.h>
+
+namespace Botan {
+
+/*
+* Library Initialization
+*/
+void LibraryInitializer::initialize(const std::string& arg_string)
+ {
+ bool thread_safe = false;
+
+ const std::vector<std::string> arg_list = split_on(arg_string, ' ');
+ for(u32bit j = 0; j != arg_list.size(); ++j)
+ {
+ if(arg_list[j].size() == 0)
+ continue;
+
+ std::string name, value;
+
+ if(arg_list[j].find('=') == std::string::npos)
+ {
+ name = arg_list[j];
+ value = "true";
+ }
+ else
+ {
+ std::vector<std::string> name_and_value = split_on(arg_list[j], '=');
+ name = name_and_value[0];
+ value = name_and_value[1];
+ }
+
+ bool is_on =
+ (value == "1" || value == "true" || value == "yes" || value == "on");
+
+ if(name == "thread_safe")
+ thread_safe = is_on;
+ }
+
+ try
+ {
+ /*
+ This two stage initialization process is because Library_State's
+ constructor will implicitly refer to global state through the
+ allocators and so for, so global_state() has to be a valid
+ reference before initialize() can be called. Yeah, gross.
+ */
+ set_global_state(new Library_State);
+
+ global_state().initialize(thread_safe);
+ }
+ catch(...)
+ {
+ deinitialize();
+ throw;
+ }
+ }
+
+/*
+* Library Shutdown
+*/
+void LibraryInitializer::deinitialize()
+ {
+ set_global_state(0);
+ }
+
+}
diff --git a/old/botan/src/libstate/init.h b/old/botan/src/libstate/init.h
new file mode 100644
index 0000000..254f945
--- /dev/null
+++ b/old/botan/src/libstate/init.h
@@ -0,0 +1,41 @@
+/**
+* Library Initialization
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_LIBRARY_INITIALIZER_H__
+#define BOTAN_LIBRARY_INITIALIZER_H__
+
+#include <botan/build.h>
+#include <string>
+
+namespace Botan {
+
+/**
+* This class represents the Library Initialization/Shutdown Object. It
+* has to exceed the lifetime of any Botan object used in an
+* application. You can call initialize/deinitialize or use
+* LibraryInitializer in the RAII style.
+*/
+class BOTAN_DLL LibraryInitializer
+ {
+ public:
+ static void initialize(const std::string& options = "");
+
+ static void deinitialize();
+
+ /**
+ * Initialize the library
+ * @param thread_safe if the library should use a thread-safe mutex
+ */
+ LibraryInitializer(const std::string& options = "")
+ { LibraryInitializer::initialize(options); }
+
+ ~LibraryInitializer() { LibraryInitializer::deinitialize(); }
+ };
+
+}
+
+#endif
diff --git a/old/botan/src/libstate/libstate.cpp b/old/botan/src/libstate/libstate.cpp
new file mode 100644
index 0000000..3275c64
--- /dev/null
+++ b/old/botan/src/libstate/libstate.cpp
@@ -0,0 +1,338 @@
+/*
+* Library Internal/Global State
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/libstate.h>
+#include <botan/init.h>
+#include <botan/engine.h>
+#include <botan/stl_util.h>
+#include <botan/mutex.h>
+#include <botan/mux_noop.h>
+#include <botan/charset.h>
+#include <botan/defalloc.h>
+#include <botan/def_eng.h>
+#include <algorithm>
+
+#if defined(BOTAN_HAS_MUTEX_PTHREAD)
+ #include <botan/mux_pthr.h>
+#elif defined(BOTAN_HAS_MUTEX_WIN32)
+ #include <botan/mux_win32.h>
+#elif defined(BOTAN_HAS_MUTEX_QT)
+ #include <botan/mux_qt.h>
+#endif
+
+#if defined(BOTAN_HAS_ALLOC_MMAP)
+ #include <botan/mmap_mem.h>
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_IA32_ASSEMBLER)
+ #include <botan/eng_ia32.h>
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER)
+ #include <botan/eng_amd64.h>
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER)
+ #include <botan/eng_sse2.h>
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_GNU_MP)
+ #include <botan/eng_gmp.h>
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_OPENSSL)
+ #include <botan/eng_ossl.h>
+#endif
+
+namespace Botan {
+
+/*
+* Botan's global state
+*/
+namespace {
+
+Library_State* global_lib_state = 0;
+
+}
+
+/*
+* Access the global state object
+*/
+Library_State& global_state()
+ {
+ /* Lazy initialization. Botan still needs to be deinitialized later
+ on or memory might leak.
+ */
+ if(!global_lib_state)
+ LibraryInitializer::initialize("thread_safe=true");
+
+ return (*global_lib_state);
+ }
+
+/*
+* Set a new global state object
+*/
+void set_global_state(Library_State* new_state)
+ {
+ delete swap_global_state(new_state);
+ }
+
+/*
+* Swap two global state objects
+*/
+Library_State* swap_global_state(Library_State* new_state)
+ {
+ Library_State* old_state = global_lib_state;
+ global_lib_state = new_state;
+ return old_state;
+ }
+
+/*
+* Get a new mutex object
+*/
+Mutex* Library_State::get_mutex() const
+ {
+ return mutex_factory->make();
+ }
+
+/*
+* Get an allocator by its name
+*/
+Allocator* Library_State::get_allocator(const std::string& type) const
+ {
+ Mutex_Holder lock(allocator_lock);
+
+ if(type != "")
+ return search_map<std::string, Allocator*>(alloc_factory, type, 0);
+
+ if(!cached_default_allocator)
+ {
+ std::string chosen = this->option("base/default_allocator");
+
+ if(chosen == "")
+ chosen = "malloc";
+
+ cached_default_allocator =
+ search_map<std::string, Allocator*>(alloc_factory, chosen, 0);
+ }
+
+ return cached_default_allocator;
+ }
+
+/*
+* Create a new name to object mapping
+*/
+void Library_State::add_allocator(Allocator* allocator)
+ {
+ Mutex_Holder lock(allocator_lock);
+
+ allocator->init();
+
+ allocators.push_back(allocator);
+ alloc_factory[allocator->type()] = allocator;
+ }
+
+/*
+* Set the default allocator type
+*/
+void Library_State::set_default_allocator(const std::string& type)
+ {
+ Mutex_Holder lock(allocator_lock);
+
+ if(type == "")
+ return;
+
+ this->set("conf", "base/default_allocator", type);
+ cached_default_allocator = 0;
+ }
+
+/*
+* Get a configuration value
+*/
+std::string Library_State::get(const std::string& section,
+ const std::string& key) const
+ {
+ Mutex_Holder lock(config_lock);
+
+ return search_map<std::string, std::string>(config,
+ section + "/" + key, "");
+ }
+
+/*
+* See if a particular option has been set
+*/
+bool Library_State::is_set(const std::string& section,
+ const std::string& key) const
+ {
+ Mutex_Holder lock(config_lock);
+
+ return search_map(config, section + "/" + key, false, true);
+ }
+
+/*
+* Set a configuration value
+*/
+void Library_State::set(const std::string& section, const std::string& key,
+ const std::string& value, bool overwrite)
+ {
+ Mutex_Holder lock(config_lock);
+
+ std::string full_key = section + "/" + key;
+
+ std::map<std::string, std::string>::const_iterator i =
+ config.find(full_key);
+
+ if(overwrite || i == config.end() || i->second == "")
+ config[full_key] = value;
+ }
+
+/*
+* Add an alias
+*/
+void Library_State::add_alias(const std::string& key, const std::string& value)
+ {
+ set("alias", key, value);
+ }
+
+/*
+* Dereference an alias to a fixed name
+*/
+std::string Library_State::deref_alias(const std::string& key) const
+ {
+ std::string result = key;
+ while(is_set("alias", result))
+ result = get("alias", result);
+ return result;
+ }
+
+/*
+* Set/Add an option
+*/
+void Library_State::set_option(const std::string key,
+ const std::string& value)
+ {
+ set("conf", key, value);
+ }
+
+/*
+* Get an option value
+*/
+std::string Library_State::option(const std::string& key) const
+ {
+ return get("conf", key);
+ }
+
+/**
+Return a reference to the Algorithm_Factory
+*/
+Algorithm_Factory& Library_State::algorithm_factory()
+ {
+ if(!m_algorithm_factory)
+ throw Invalid_State("Uninitialized in Library_State::algorithm_factory");
+ return *m_algorithm_factory;
+ }
+
+/*
+* Load a set of modules
+*/
+void Library_State::initialize(bool thread_safe)
+ {
+ if(mutex_factory)
+ throw Invalid_State("Library_State has already been initialized");
+
+ if(!thread_safe)
+ {
+ mutex_factory = new Noop_Mutex_Factory;
+ }
+ else
+ {
+#if defined(BOTAN_HAS_MUTEX_PTHREAD)
+ mutex_factory = new Pthread_Mutex_Factory;
+#elif defined(BOTAN_HAS_MUTEX_WIN32)
+ mutex_factory = new Win32_Mutex_Factory;
+#elif defined(BOTAN_HAS_MUTEX_QT)
+ mutex_factory Qt_Mutex_Factory;
+#else
+ throw Invalid_State("Could not find a thread-safe mutex object to use");
+#endif
+ }
+
+ allocator_lock = mutex_factory->make();
+ config_lock = mutex_factory->make();
+
+ cached_default_allocator = 0;
+
+ add_allocator(new Malloc_Allocator);
+ add_allocator(new Locking_Allocator(mutex_factory->make()));
+
+#if defined(BOTAN_HAS_ALLOC_MMAP)
+ add_allocator(new MemoryMapping_Allocator(mutex_factory->make()));
+#endif
+
+ set_default_allocator("locking");
+
+ load_default_config();
+
+ std::vector<Engine*> engines;
+
+#if defined(BOTAN_HAS_ENGINE_GNU_MP)
+ engines.push_back(new GMP_Engine);
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_OPENSSL)
+ engines.push_back(new OpenSSL_Engine);
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER)
+ engines.push_back(new SSE2_Assembler_Engine);
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER)
+ engines.push_back(new AMD64_Assembler_Engine);
+#endif
+
+#if defined(BOTAN_HAS_ENGINE_IA32_ASSEMBLER)
+ engines.push_back(new IA32_Assembler_Engine);
+#endif
+
+ engines.push_back(new Default_Engine);
+
+ m_algorithm_factory = new Algorithm_Factory(engines, *mutex_factory);
+ }
+
+/*
+* Library_State Constructor
+*/
+Library_State::Library_State()
+ {
+ mutex_factory = 0;
+ allocator_lock = config_lock = 0;
+ cached_default_allocator = 0;
+ m_algorithm_factory = 0;
+ }
+
+/*
+* Library_State Destructor
+*/
+Library_State::~Library_State()
+ {
+ delete m_algorithm_factory;
+
+ cached_default_allocator = 0;
+
+ for(u32bit j = 0; j != allocators.size(); ++j)
+ {
+ allocators[j]->destroy();
+ delete allocators[j];
+ }
+
+ delete allocator_lock;
+ delete mutex_factory;
+ delete config_lock;
+ }
+
+}
diff --git a/old/botan/src/libstate/libstate.h b/old/botan/src/libstate/libstate.h
new file mode 100644
index 0000000..2493863
--- /dev/null
+++ b/old/botan/src/libstate/libstate.h
@@ -0,0 +1,125 @@
+/*
+* Library Internal/Global State
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_LIB_STATE_H__
+#define BOTAN_LIB_STATE_H__
+
+#include <botan/types.h>
+#include <botan/allocate.h>
+#include <botan/algo_factory.h>
+
+#include <string>
+#include <vector>
+#include <map>
+
+namespace Botan {
+
+/*
+* Global State Container Base
+*/
+class BOTAN_DLL Library_State
+ {
+ public:
+ Library_State();
+ ~Library_State();
+
+ void initialize(bool thread_safe);
+
+ Algorithm_Factory& algorithm_factory();
+
+ Allocator* get_allocator(const std::string& = "") const;
+ void add_allocator(Allocator*);
+ void set_default_allocator(const std::string&);
+
+ /**
+ * Get a parameter value as std::string.
+ * @param section the section of the desired key
+ * @param key the desired keys name
+ * @result the value of the parameter
+ */
+ std::string get(const std::string& section,
+ const std::string& key) const;
+
+ /**
+ * Check whether a certain parameter is set
+ * or not.
+ * @param section the section of the desired key
+ * @param key the desired keys name
+ * @result true if the parameters value is set,
+ * false otherwise
+ */
+ bool is_set(const std::string& section, const std::string& key) const;
+
+ /**
+ * Set a configuration parameter.
+ * @param section the section of the desired key
+ * @param key the desired keys name
+ * @param overwrite if set to true, the parameters value
+ * will be overwritten even if it is already set, otherwise
+ * no existing values will be overwritten.
+ */
+ void set(const std::string& section, const std::string& key,
+ const std::string& value, bool overwrite = true);
+
+ /**
+ * Get a parameters value out of the "conf" section (
+ * referred to as option).
+ * @param key the desired keys name
+ */
+ std::string option(const std::string& key) const;
+
+ /**
+ * Set an option.
+ * @param key the key of the option to set
+ * @param value the value to set
+ */
+ void set_option(const std::string key, const std::string& value);
+
+ /**
+ * Add a parameter value to the "alias" section.
+ * @param key the name of the parameter which shall have a new alias
+ * @param value the new alias
+ */
+ void add_alias(const std::string&, const std::string&);
+
+ /**
+ * Resolve an alias.
+ * @param alias the alias to resolve.
+ * @return what the alias stands for
+ */
+ std::string deref_alias(const std::string&) const;
+
+ class Mutex* get_mutex() const;
+ private:
+ void load_default_config();
+
+ Library_State(const Library_State&) {}
+ Library_State& operator=(const Library_State&) { return (*this); }
+
+ class Mutex_Factory* mutex_factory;
+
+ std::map<std::string, std::string> config;
+ class Mutex* config_lock;
+
+ class Mutex* allocator_lock;
+ std::map<std::string, Allocator*> alloc_factory;
+ mutable Allocator* cached_default_allocator;
+ std::vector<Allocator*> allocators;
+
+ Algorithm_Factory* m_algorithm_factory;
+ };
+
+/*
+* Global State
+*/
+BOTAN_DLL Library_State& global_state();
+BOTAN_DLL void set_global_state(Library_State*);
+BOTAN_DLL Library_State* swap_global_state(Library_State*);
+
+}
+
+#endif
diff --git a/old/botan/src/libstate/look_pk.cpp b/old/botan/src/libstate/look_pk.cpp
new file mode 100644
index 0000000..8eb4738
--- /dev/null
+++ b/old/botan/src/libstate/look_pk.cpp
@@ -0,0 +1,76 @@
+/*
+* PK Algorithm Lookup
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/look_pk.h>
+#include <botan/lookup.h>
+
+namespace Botan {
+
+/*
+* Get a PK_Encryptor object
+*/
+PK_Encryptor* get_pk_encryptor(const PK_Encrypting_Key& key,
+ const std::string& eme)
+ {
+ return new PK_Encryptor_MR_with_EME(key, get_eme(eme));
+ }
+
+/*
+* Get a PK_Decryptor object
+*/
+PK_Decryptor* get_pk_decryptor(const PK_Decrypting_Key& key,
+ const std::string& eme)
+ {
+ return new PK_Decryptor_MR_with_EME(key, get_eme(eme));
+ }
+
+/*
+* Get a PK_Signer object
+*/
+PK_Signer* get_pk_signer(const PK_Signing_Key& key,
+ const std::string& emsa,
+ Signature_Format sig_format)
+ {
+ PK_Signer* signer = new PK_Signer(key, get_emsa(emsa));
+ signer->set_output_format(sig_format);
+ return signer;
+ }
+
+/*
+* Get a PK_Verifier object
+*/
+PK_Verifier* get_pk_verifier(const PK_Verifying_with_MR_Key& key,
+ const std::string& emsa,
+ Signature_Format sig_format)
+ {
+ PK_Verifier* verifier = new PK_Verifier_with_MR(key, get_emsa(emsa));
+ verifier->set_input_format(sig_format);
+ return verifier;
+ }
+
+/*
+* Get a PK_Verifier object
+*/
+PK_Verifier* get_pk_verifier(const PK_Verifying_wo_MR_Key& key,
+ const std::string& emsa,
+ Signature_Format sig_format)
+ {
+ PK_Verifier* verifier = new PK_Verifier_wo_MR(key, get_emsa(emsa));
+ verifier->set_input_format(sig_format);
+ return verifier;
+ }
+
+/*
+* Get a PK_Key_Agreement object
+*/
+PK_Key_Agreement* get_pk_kas(const PK_Key_Agreement_Key& key,
+ const std::string& kdf)
+ {
+ return new PK_Key_Agreement(key, get_kdf(kdf));
+ }
+
+}
diff --git a/old/botan/src/libstate/look_pk.h b/old/botan/src/libstate/look_pk.h
new file mode 100644
index 0000000..27b67dc
--- /dev/null
+++ b/old/botan/src/libstate/look_pk.h
@@ -0,0 +1,78 @@
+/*
+* PK Algorithm Lookup
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_PK_LOOKUP_H__
+#define BOTAN_PK_LOOKUP_H__
+
+#include <botan/build.h>
+#include <botan/pubkey.h>
+
+namespace Botan {
+
+/**
+* Public key encryptor factory method.
+* @param key the key that will work inside the encryptor
+* @param pad determines the algorithm and encoding
+* @return the public key encryptor object
+*/
+BOTAN_DLL PK_Encryptor* get_pk_encryptor(const PK_Encrypting_Key& key,
+ const std::string& pad);
+
+/**
+* Public key decryptor factory method.
+* @param key the key that will work inside the decryptor
+* @param pad determines the algorithm and encoding
+* @return the public key decryptor object
+*/
+BOTAN_DLL PK_Decryptor* get_pk_decryptor(const PK_Decrypting_Key& key,
+ const std::string& pad);
+
+/**
+* Public key signer factory method.
+* @param key the key that will work inside the signer
+* @param pad determines the algorithm, encoding and hash algorithm
+* @param sig_format the signature format to be used
+* @return the public key signer object
+*/
+BOTAN_DLL PK_Signer* get_pk_signer(const PK_Signing_Key& key,
+ const std::string& pad,
+ Signature_Format = IEEE_1363);
+
+/**
+* Public key verifier factory method.
+* @param key the key that will work inside the verifier
+* @param pad determines the algorithm, encoding and hash algorithm
+* @param sig_format the signature format to be used
+* @return the public key verifier object
+*/
+BOTAN_DLL PK_Verifier* get_pk_verifier(const PK_Verifying_with_MR_Key& key,
+ const std::string& pad,
+ Signature_Format = IEEE_1363);
+
+/**
+* Public key verifier factory method.
+* @param key the key that will work inside the verifier
+* @param pad determines the algorithm, encoding and hash algorithm
+* @param sig_form the signature format to be used
+* @return the public key verifier object
+*/
+BOTAN_DLL PK_Verifier* get_pk_verifier(const PK_Verifying_wo_MR_Key& key,
+ const std::string& pad,
+ Signature_Format sig_form = IEEE_1363);
+
+/**
+* Public key key agreement factory method.
+* @param key the key that will work inside the key agreement
+* @param pad determines the algorithm, encoding and hash algorithm
+* @return the public key verifier object
+*/
+BOTAN_DLL PK_Key_Agreement* get_pk_kas(const PK_Key_Agreement_Key& key,
+ const std::string& pad);
+
+}
+
+#endif
diff --git a/old/botan/src/libstate/lookup.cpp b/old/botan/src/libstate/lookup.cpp
new file mode 100644
index 0000000..3b49116
--- /dev/null
+++ b/old/botan/src/libstate/lookup.cpp
@@ -0,0 +1,296 @@
+/*
+* Algorithm Retrieval
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/lookup.h>
+#include <botan/libstate.h>
+#include <botan/engine.h>
+
+namespace Botan {
+
+/**
+* Acquire a block cipher
+*/
+const BlockCipher* retrieve_block_cipher(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.prototype_block_cipher(algo_spec);
+ }
+
+/**
+* Get a block cipher by name
+*/
+BlockCipher* get_block_cipher(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.make_block_cipher(algo_spec);
+ }
+
+/**
+* Acquire a stream cipher
+*/
+const StreamCipher* retrieve_stream_cipher(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.prototype_stream_cipher(algo_spec);
+ }
+
+/**
+* Get a stream cipher by name
+*/
+StreamCipher* get_stream_cipher(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.make_stream_cipher(algo_spec);
+ }
+
+/**
+* Acquire a hash function
+*/
+const HashFunction* retrieve_hash(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.prototype_hash_function(algo_spec);
+ }
+
+/**
+* Get a hash function by name
+*/
+HashFunction* get_hash(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.make_hash_function(algo_spec);
+ }
+
+/**
+* Query if Botan has the named hash function
+*/
+bool have_hash(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.prototype_hash_function(algo_spec);
+ }
+
+/**
+* Acquire an authentication code
+*/
+const MessageAuthenticationCode* retrieve_mac(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.prototype_mac(algo_spec);
+ }
+
+/**
+* Get a MAC by name
+*/
+MessageAuthenticationCode* get_mac(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.make_mac(algo_spec);
+ }
+
+/**
+* Query if Botan has the named MAC
+*/
+bool have_mac(const std::string& algo_spec)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+ return af.prototype_mac(algo_spec);
+ }
+
+/**
+* Query if an algorithm exists
+*/
+bool have_algorithm(const std::string& name)
+ {
+ if(retrieve_block_cipher(name))
+ return true;
+ if(retrieve_stream_cipher(name))
+ return true;
+ if(retrieve_hash(name))
+ return true;
+ if(retrieve_mac(name))
+ return true;
+ return false;
+ }
+
+/**
+* Query if Botan has the named block cipher
+*/
+bool have_block_cipher(const std::string& name)
+ {
+ return (retrieve_block_cipher(name) != 0);
+ }
+
+/**
+* Query if Botan has the named stream cipher
+*/
+bool have_stream_cipher(const std::string& name)
+ {
+ return (retrieve_stream_cipher(name) != 0);
+ }
+
+/**
+* Query the block size of a cipher or hash
+*/
+u32bit block_size_of(const std::string& name)
+ {
+ const BlockCipher* cipher = retrieve_block_cipher(name);
+ if(cipher)
+ return cipher->BLOCK_SIZE;
+
+ const HashFunction* hash = retrieve_hash(name);
+ if(hash)
+ return hash->HASH_BLOCK_SIZE;
+
+ throw Algorithm_Not_Found(name);
+ }
+
+/**
+* Query the OUTPUT_LENGTH of a hash or MAC
+*/
+u32bit output_length_of(const std::string& name)
+ {
+ const HashFunction* hash = retrieve_hash(name);
+ if(hash)
+ return hash->OUTPUT_LENGTH;
+
+ const MessageAuthenticationCode* mac = retrieve_mac(name);
+ if(mac)
+ return mac->OUTPUT_LENGTH;
+
+ throw Algorithm_Not_Found(name);
+ }
+
+/**
+* Check if a keylength is valid for this algo
+*/
+bool valid_keylength_for(u32bit key_len, const std::string& name)
+ {
+ const BlockCipher* bc = retrieve_block_cipher(name);
+ if(bc)
+ return bc->valid_keylength(key_len);
+
+ const StreamCipher* sc = retrieve_stream_cipher(name);
+ if(sc)
+ return sc->valid_keylength(key_len);
+
+ const MessageAuthenticationCode* mac = retrieve_mac(name);
+ if(mac)
+ return mac->valid_keylength(key_len);
+
+ throw Algorithm_Not_Found(name);
+ }
+
+/**
+* Query the MINIMUM_KEYLENGTH of an algorithm
+*/
+u32bit min_keylength_of(const std::string& name)
+ {
+ const BlockCipher* bc = retrieve_block_cipher(name);
+ if(bc)
+ return bc->MINIMUM_KEYLENGTH;
+
+ const StreamCipher* sc = retrieve_stream_cipher(name);
+ if(sc)
+ return sc->MINIMUM_KEYLENGTH;
+
+ const MessageAuthenticationCode* mac = retrieve_mac(name);
+ if(mac)
+ return mac->MINIMUM_KEYLENGTH;
+
+ throw Algorithm_Not_Found(name);
+ }
+
+/**
+* Query the MAXIMUM_KEYLENGTH of an algorithm
+*/
+u32bit max_keylength_of(const std::string& name)
+ {
+ const BlockCipher* bc = retrieve_block_cipher(name);
+ if(bc)
+ return bc->MAXIMUM_KEYLENGTH;
+
+ const StreamCipher* sc = retrieve_stream_cipher(name);
+ if(sc)
+ return sc->MAXIMUM_KEYLENGTH;
+
+ const MessageAuthenticationCode* mac = retrieve_mac(name);
+ if(mac)
+ return mac->MAXIMUM_KEYLENGTH;
+
+ throw Algorithm_Not_Found(name);
+ }
+
+/**
+* Query the KEYLENGTH_MULTIPLE of an algorithm
+*/
+u32bit keylength_multiple_of(const std::string& name)
+ {
+ const BlockCipher* bc = retrieve_block_cipher(name);
+ if(bc)
+ return bc->KEYLENGTH_MULTIPLE;
+
+ const StreamCipher* sc = retrieve_stream_cipher(name);
+ if(sc)
+ return sc->KEYLENGTH_MULTIPLE;
+
+ const MessageAuthenticationCode* mac = retrieve_mac(name);
+ if(mac)
+ return mac->KEYLENGTH_MULTIPLE;
+
+ throw Algorithm_Not_Found(name);
+ }
+
+/**
+* Get a cipher object
+*/
+Keyed_Filter* get_cipher(const std::string& algo_spec,
+ Cipher_Dir direction)
+ {
+ Algorithm_Factory& af = global_state().algorithm_factory();
+
+ Algorithm_Factory::Engine_Iterator i(af);
+
+ while(Engine* engine = i.next())
+ {
+ Keyed_Filter* algo = engine->get_cipher(algo_spec, direction, af);
+ if(algo)
+ return algo;
+ }
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+/**
+* Get a cipher object
+*/
+Keyed_Filter* get_cipher(const std::string& algo_spec,
+ const SymmetricKey& key,
+ const InitializationVector& iv,
+ Cipher_Dir direction)
+ {
+ Keyed_Filter* cipher = get_cipher(algo_spec, direction);
+ cipher->set_key(key);
+
+ if(iv.length())
+ cipher->set_iv(iv);
+
+ return cipher;
+ }
+
+/**
+* Get a cipher object
+*/
+Keyed_Filter* get_cipher(const std::string& algo_spec,
+ const SymmetricKey& key,
+ Cipher_Dir direction)
+ {
+ return get_cipher(algo_spec,
+ key, InitializationVector(), direction);
+ }
+
+}
diff --git a/old/botan/src/libstate/lookup.h b/old/botan/src/libstate/lookup.h
new file mode 100644
index 0000000..0f48ddd
--- /dev/null
+++ b/old/botan/src/libstate/lookup.h
@@ -0,0 +1,239 @@
+/*
+* Algorithm Lookup
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_LOOKUP_H__
+#define BOTAN_LOOKUP_H__
+
+#include <botan/block_cipher.h>
+#include <botan/stream_cipher.h>
+#include <botan/hash.h>
+#include <botan/mac.h>
+#include <botan/s2k.h>
+
+#include <botan/filters.h>
+#include <botan/mode_pad.h>
+#include <botan/kdf.h>
+#include <botan/eme.h>
+#include <botan/emsa.h>
+
+namespace Botan {
+
+/*
+* Retrieve an object from the lookup table
+*/
+// NOTE: these functions return internally stored objects, library
+// retains ownership
+
+BOTAN_DLL const BlockCipher*
+retrieve_block_cipher(const std::string&);
+
+BOTAN_DLL const StreamCipher*
+retrieve_stream_cipher(const std::string&);
+
+BOTAN_DLL const HashFunction*
+retrieve_hash(const std::string&);
+
+BOTAN_DLL const MessageAuthenticationCode*
+retrieve_mac(const std::string&);
+
+/*
+* Get an algorithm object
+*/
+// NOTE: these functions create and return new objects, letting the
+// caller assume ownership of them
+
+/**
+* Block cipher factory method.
+* @param algo_spec the name of the desired block cipher
+* @return a pointer to the block cipher object
+*/
+BOTAN_DLL BlockCipher* get_block_cipher(const std::string& name);
+
+
+/**
+* Stream cipher factory method.
+* @param algo_spec the name of the desired stream cipher
+* @return a pointer to the stream cipher object
+*/
+BOTAN_DLL StreamCipher* get_stream_cipher(const std::string& name);
+
+/**
+* Hash function factory method.
+* @param algo_spec the name of the desired hash function
+* @return a pointer to the hash function object
+*/
+BOTAN_DLL HashFunction* get_hash(const std::string& name);
+
+/**
+* MAC factory method.
+* @param algo_spec the name of the desired MAC
+* @return a pointer to the MAC object
+*/
+BOTAN_DLL MessageAuthenticationCode* get_mac(const std::string& name);
+
+/**
+* String to key algorithm factory method.
+* @param name the name of the desired string to key (S2K) algorithm
+* @return a pointer to the string to key algorithm object
+*/
+BOTAN_DLL S2K* get_s2k(const std::string& name);
+
+/*
+* Get an EMSA/EME/KDF/MGF function
+*/
+// NOTE: these functions create and return new objects, letting the
+// caller assume ownership of them
+
+/**
+* Factory method for EME (message-encoding methods for encryption) objects
+* @param name the name of the EME to create
+* @return a pointer to the desired EME object
+*/
+BOTAN_DLL EME* get_eme(const std::string& name);
+
+/**
+* Factory method for EMSA (message-encoding methods for signatures
+* with appendix) objects
+* @param name the name of the EME to create
+* @return a pointer to the desired EME object
+*/
+BOTAN_DLL EMSA* get_emsa(const std::string& name);
+
+/**
+* Factory method for KDF (key derivation function)
+* @param name the name of the KDF to create
+* @return a pointer to the desired KDF object
+*/
+BOTAN_DLL KDF* get_kdf(const std::string& name);
+
+/*
+* Get a cipher object
+*/
+
+/**
+* Factory method for general symmetric cipher filters.
+* @param algo_spec the name of the desired cipher
+* @param key the key to be used for encryption/decryption performed by
+* the filter
+* @param iv the initialization vector to be used
+* @param direction determines whether the filter will be an encrypting or decrypting
+* filter
+* @return a pointer to the encryption or decryption filter
+*/
+BOTAN_DLL Keyed_Filter* get_cipher(const std::string& name,
+ const SymmetricKey& key,
+ const InitializationVector& iv,
+ Cipher_Dir dir);
+/**
+* Factory method for general symmetric cipher filters.
+* @param algo_spec the name of the desired cipher
+* @param key the key to be used for encryption/decryption performed by
+* the filter
+* @param direction determines whether the filter will be an encrypting or decrypting
+* filter
+* @return a pointer to the encryption or decryption filter
+*/
+BOTAN_DLL Keyed_Filter* get_cipher(const std::string& name,
+ const SymmetricKey& key,
+ Cipher_Dir dir);
+
+/** Factory method for general symmetric cipher filters. No key will
+* be set in the filter.
+* @param algo_spec the name of the desired cipher
+
+* @param direction determines whether the filter will be an encrypting or
+* decrypting filter
+* @return a pointer to the encryption or decryption filter
+*/
+BOTAN_DLL Keyed_Filter* get_cipher(const std::string& name, Cipher_Dir dir);
+
+/**
+* Check if an algorithm exists.
+* @param name the name of the algorithm to check for
+* @return true if the algorithm exists, false otherwise
+*/
+BOTAN_DLL bool have_algorithm(const std::string& name);
+
+/**
+* Check if a block cipher algorithm exists.
+* @param name the name of the algorithm to check for
+* @return true if the algorithm exists, false otherwise
+*/
+BOTAN_DLL bool have_block_cipher(const std::string& name);
+
+/**
+* Check if a stream cipher algorithm exists.
+* @param name the name of the algorithm to check for
+* @return true if the algorithm exists, false otherwise
+*/
+BOTAN_DLL bool have_stream_cipher(const std::string& name);
+
+/**
+* Check if a hash algorithm exists.
+* @param algo_spec the name of the algorithm to check for
+* @return true if the algorithm exists, false otherwise
+*/
+BOTAN_DLL bool have_hash(const std::string& name);
+
+/**
+* Check if a MAC algorithm exists.
+* @param algo_spec the name of the algorithm to check for
+* @return true if the algorithm exists, false otherwise
+*/
+BOTAN_DLL bool have_mac(const std::string& name);
+
+/*
+* Query information about an algorithm
+*/
+
+/**
+* Find out the block size of a certain symmetric algorithm.
+* @param name the name of the algorithm
+* @return the block size of the specified algorithm
+*/
+BOTAN_DLL u32bit block_size_of(const std::string& name);
+
+/**
+* Find out the output length of a certain symmetric algorithm.
+* @param name the name of the algorithm
+* @return the output length of the specified algorithm
+*/
+BOTAN_DLL u32bit output_length_of(const std::string& name);
+
+/**
+* Find out the whether a certain key length is allowd for a given
+* symmetric algorithm.
+* @param key_len the key length in question
+* @param name the name of the algorithm
+* @return true if the key length is valid for that algorithm, false otherwise
+*/
+BOTAN_DLL bool valid_keylength_for(u32bit keylen, const std::string& name);
+
+/**
+* Find out the minimum key size of a certain symmetric algorithm.
+* @param name the name of the algorithm
+* @return the minimum key length of the specified algorithm
+*/
+BOTAN_DLL u32bit min_keylength_of(const std::string& name);
+
+/**
+* Find out the maximum key size of a certain symmetric algorithm.
+* @param name the name of the algorithm
+* @return the maximum key length of the specified algorithm
+*/
+BOTAN_DLL u32bit max_keylength_of(const std::string& name);
+
+/**
+* Find out the size any valid key is a multiple of for a certain algorithm.
+* @param name the name of the algorithm
+* @return the size any valid key is a multiple of
+*/
+BOTAN_DLL u32bit keylength_multiple_of(const std::string& name);
+
+}
+
+#endif
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
diff --git a/old/botan/src/libstate/pk_engine.cpp b/old/botan/src/libstate/pk_engine.cpp
new file mode 100644
index 0000000..790ddcd
--- /dev/null
+++ b/old/botan/src/libstate/pk_engine.cpp
@@ -0,0 +1,175 @@
+/*
+* PK Engine Lookup
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/pk_engine.h>
+#include <botan/libstate.h>
+#include <botan/engine.h>
+
+namespace Botan {
+
+namespace Engine_Core {
+
+#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
+/*
+* Acquire an IF op
+*/
+IF_Operation* if_op(const BigInt& e, const BigInt& n, const BigInt& d,
+ const BigInt& p, const BigInt& q, const BigInt& d1,
+ const BigInt& d2, const BigInt& c)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ IF_Operation* op = engine->if_op(e, n, d, p, q, d1, d2, c);
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::if_op: Unable to find a working engine");
+ }
+#endif
+
+#if defined(BOTAN_HAS_DSA)
+/*
+* Acquire a DSA op
+*/
+DSA_Operation* dsa_op(const DL_Group& group, const BigInt& y, const BigInt& x)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ DSA_Operation* op = engine->dsa_op(group, y, x);
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::dsa_op: Unable to find a working engine");
+ }
+#endif
+
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+/*
+* Acquire a NR op
+*/
+NR_Operation* nr_op(const DL_Group& group, const BigInt& y, const BigInt& x)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ NR_Operation* op = engine->nr_op(group, y, x);
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::nr_op: Unable to find a working engine");
+ }
+#endif
+
+#if defined(BOTAN_HAS_ELGAMAL)
+/*
+* Acquire an ElGamal op
+*/
+ELG_Operation* elg_op(const DL_Group& group, const BigInt& y, const BigInt& x)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ ELG_Operation* op = engine->elg_op(group, y, x);
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::elg_op: Unable to find a working engine");
+ }
+#endif
+
+#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
+/*
+* Acquire a DH op
+*/
+DH_Operation* dh_op(const DL_Group& group, const BigInt& x)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ DH_Operation* op = engine->dh_op(group, x);
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::dh_op: Unable to find a working engine");
+ }
+#endif
+
+#if defined(BOTAN_HAS_ECDSA)
+/*
+* Acquire an ECDSA op
+*/
+ECDSA_Operation* ecdsa_op(const EC_Domain_Params& dom_pars,
+ const BigInt& priv_key,
+ const PointGFp& pub_key)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ ECDSA_Operation* op = engine->ecdsa_op(dom_pars, priv_key, pub_key);
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::ecdsa_op: Unable to find a working engine");
+ }
+#endif
+
+#if defined(BOTAN_HAS_ECKAEG)
+/*
+* Acquire a ECKAEG op
+*/
+ECKAEG_Operation* eckaeg_op(const EC_Domain_Params& dom_pars,
+ const BigInt& priv_key,
+ const PointGFp& pub_key)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ ECKAEG_Operation* op = engine->eckaeg_op(dom_pars, priv_key, pub_key);
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::eckaeg_op: Unable to find a working engine");
+ }
+#endif
+
+/*
+* Acquire a modular exponentiator
+*/
+Modular_Exponentiator* mod_exp(const BigInt& n, Power_Mod::Usage_Hints hints)
+ {
+ Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
+
+ while(const Engine* engine = i.next())
+ {
+ Modular_Exponentiator* op = engine->mod_exp(n, hints);
+
+ if(op)
+ return op;
+ }
+
+ throw Lookup_Error("Engine_Core::mod_exp: Unable to find a working engine");
+ }
+
+}
+
+}
diff --git a/old/botan/src/libstate/pk_engine.h b/old/botan/src/libstate/pk_engine.h
new file mode 100644
index 0000000..256a47c
--- /dev/null
+++ b/old/botan/src/libstate/pk_engine.h
@@ -0,0 +1,95 @@
+/**
+* Engine for PK
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_ENGINE_PK_LOOKUP_H__
+#define BOTAN_ENGINE_PK_LOOKUP_H__
+
+#include <botan/bigint.h>
+#include <botan/pow_mod.h>
+
+#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
+ #include <botan/if_op.h>
+#endif
+
+#if defined(BOTAN_HAS_DSA)
+ #include <botan/dsa_op.h>
+#endif
+
+#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
+ #include <botan/dh_op.h>
+#endif
+
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+ #include <botan/nr_op.h>
+#endif
+
+#if defined(BOTAN_HAS_ELGAMAL)
+ #include <botan/elg_op.h>
+#endif
+
+#if defined(BOTAN_HAS_ECDSA)
+ #include <botan/ecdsa_op.h>
+ #include <botan/ec_dompar.h>
+#endif
+
+#if defined(BOTAN_HAS_ECKAEG)
+ #include <botan/eckaeg_op.h>
+ #include <botan/ec_dompar.h>
+#endif
+
+namespace Botan {
+
+class Algorithm_Factory;
+class Keyed_Filter;
+class Modular_Exponentiator;
+
+namespace Engine_Core {
+
+/*
+* Get an operation from an Engine
+*/
+Modular_Exponentiator* mod_exp(const BigInt&, Power_Mod::Usage_Hints);
+
+#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
+IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&,
+ const BigInt&, const BigInt&, const BigInt&,
+ const BigInt&, const BigInt&);
+#endif
+
+#if defined(BOTAN_HAS_DSA)
+DSA_Operation* dsa_op(const DL_Group&, const BigInt&, const BigInt&);
+#endif
+
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+NR_Operation* nr_op(const DL_Group&, const BigInt&, const BigInt&);
+#endif
+
+#if defined(BOTAN_HAS_ELGAMAL)
+ELG_Operation* elg_op(const DL_Group&, const BigInt&, const BigInt&);
+#endif
+
+#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
+DH_Operation* dh_op(const DL_Group&, const BigInt&);
+#endif
+
+#if defined(BOTAN_HAS_ECDSA)
+ECDSA_Operation* ecdsa_op(const EC_Domain_Params& dom_pars,
+ const BigInt& priv_key,
+ const PointGFp& pub_key);
+#endif
+
+#if defined(BOTAN_HAS_ECKAEG)
+ECKAEG_Operation* eckaeg_op(const EC_Domain_Params& dom_pars,
+ const BigInt& priv_key,
+ const PointGFp& pub_key);
+#endif
+
+}
+
+}
+
+#endif
diff --git a/old/botan/src/libstate/policy.cpp b/old/botan/src/libstate/policy.cpp
new file mode 100644
index 0000000..dfc1dfc
--- /dev/null
+++ b/old/botan/src/libstate/policy.cpp
@@ -0,0 +1,511 @@
+/*
+* Default Policy
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/libstate.h>
+
+namespace Botan {
+
+namespace {
+
+/*
+* OID loading helper function
+*/
+void add_oid(Library_State& config,
+ const std::string& oid_str,
+ const std::string& name)
+ {
+ if(!config.is_set("oid2str", oid_str))
+ config.set("oid2str", oid_str, name);
+ if(!config.is_set("str2oid", name))
+ config.set("str2oid", name, oid_str);
+ }
+
+/*
+* Load all of the default OIDs
+*/
+void set_default_oids(Library_State& config)
+ {
+ /* Public key types */
+ add_oid(config, "1.2.840.113549.1.1.1", "RSA");
+ add_oid(config, "2.5.8.1.1", "RSA"); // RSA alternate
+ add_oid(config, "1.2.840.10040.4.1", "DSA");
+ add_oid(config, "1.2.840.10046.2.1", "DH");
+ add_oid(config, "1.3.6.1.4.1.3029.1.2.1", "ELG");
+ add_oid(config, "1.3.6.1.4.1.25258.1.1", "RW");
+ add_oid(config, "1.3.6.1.4.1.25258.1.2", "NR");
+ add_oid(config, "1.2.840.10045.2.1", "ECDSA"); // X9.62
+
+ /* Ciphers */
+ add_oid(config, "1.3.14.3.2.7", "DES/CBC");
+ add_oid(config, "1.2.840.113549.3.7", "TripleDES/CBC");
+ add_oid(config, "1.2.840.113549.3.2", "RC2/CBC");
+ add_oid(config, "1.2.840.113533.7.66.10", "CAST-128/CBC");
+ add_oid(config, "2.16.840.1.101.3.4.1.2", "AES-128/CBC");
+ add_oid(config, "2.16.840.1.101.3.4.1.22", "AES-192/CBC");
+ add_oid(config, "2.16.840.1.101.3.4.1.42", "AES-256/CBC");
+
+ /* Hash Functions */
+ add_oid(config, "1.2.840.113549.2.5", "MD5");
+ add_oid(config, "1.3.6.1.4.1.11591.12.2", "Tiger(24,3)");
+
+ add_oid(config, "1.3.14.3.2.26", "SHA-160");
+ add_oid(config, "2.16.840.1.101.3.4.2.4", "SHA-224");
+ add_oid(config, "2.16.840.1.101.3.4.2.1", "SHA-256");
+ add_oid(config, "2.16.840.1.101.3.4.2.2", "SHA-384");
+ add_oid(config, "2.16.840.1.101.3.4.2.3", "SHA-512");
+
+ /* Key Wrap */
+ add_oid(config, "1.2.840.113549.1.9.16.3.6", "KeyWrap.TripleDES");
+ add_oid(config, "1.2.840.113549.1.9.16.3.7", "KeyWrap.RC2");
+ add_oid(config, "1.2.840.113533.7.66.15", "KeyWrap.CAST-128");
+ add_oid(config, "2.16.840.1.101.3.4.1.5", "KeyWrap.AES-128");
+ add_oid(config, "2.16.840.1.101.3.4.1.25", "KeyWrap.AES-192");
+ add_oid(config, "2.16.840.1.101.3.4.1.45", "KeyWrap.AES-256");
+
+ /* Compression */
+ add_oid(config, "1.2.840.113549.1.9.16.3.8", "Compression.Zlib");
+
+ /* Public key signature schemes */
+ add_oid(config, "1.2.840.113549.1.1.1", "RSA/EME-PKCS1-v1_5");
+ add_oid(config, "1.2.840.113549.1.1.2", "RSA/EMSA3(MD2)");
+ add_oid(config, "1.2.840.113549.1.1.4", "RSA/EMSA3(MD5)");
+ add_oid(config, "1.2.840.113549.1.1.5", "RSA/EMSA3(SHA-160)");
+ add_oid(config, "1.2.840.113549.1.1.11", "RSA/EMSA3(SHA-256)");
+ add_oid(config, "1.2.840.113549.1.1.12", "RSA/EMSA3(SHA-384)");
+ add_oid(config, "1.2.840.113549.1.1.13", "RSA/EMSA3(SHA-512)");
+ add_oid(config, "1.3.36.3.3.1.2", "RSA/EMSA3(RIPEMD-160)");
+
+ add_oid(config, "1.2.840.10040.4.3", "DSA/EMSA1(SHA-160)");
+ add_oid(config, "2.16.840.1.101.3.4.3.1", "DSA/EMSA1(SHA-224)");
+ add_oid(config, "2.16.840.1.101.3.4.3.2", "DSA/EMSA1(SHA-256)");
+
+ add_oid(config, "1.2.840.10045.4.1", "ECDSA/EMSA1_BSI(SHA-160)");
+ add_oid(config, "1.2.840.10045.4.3.1", "ECDSA/EMSA1_BSI(SHA-224)");
+ add_oid(config, "1.2.840.10045.4.3.2", "ECDSA/EMSA1_BSI(SHA-256)");
+ add_oid(config, "1.2.840.10045.4.3.3", "ECDSA/EMSA1_BSI(SHA-384)");
+ add_oid(config, "1.2.840.10045.4.3.4", "ECDSA/EMSA1_BSI(SHA-512)");
+
+ add_oid(config, "1.2.840.10045.4.3.1", "ECDSA/EMSA1(SHA-224)");
+ add_oid(config, "1.2.840.10045.4.3.2", "ECDSA/EMSA1(SHA-256)");
+ add_oid(config, "1.2.840.10045.4.3.3", "ECDSA/EMSA1(SHA-384)");
+ add_oid(config, "1.2.840.10045.4.3.4", "ECDSA/EMSA1(SHA-512)");
+
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.1.1", "RW/EMSA2(RIPEMD-160)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.1.2", "RW/EMSA2(SHA-160)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.1.3", "RW/EMSA2(SHA-224)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.1.4", "RW/EMSA2(SHA-256)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.1.5", "RW/EMSA2(SHA-384)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.1.6", "RW/EMSA2(SHA-512)");
+
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.2.1", "RW/EMSA4(RIPEMD-160)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.2.2", "RW/EMSA4(SHA-160)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.2.3", "RW/EMSA4(SHA-224)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.2.4", "RW/EMSA4(SHA-256)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.2.5", "RW/EMSA4(SHA-384)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.1.2.6", "RW/EMSA4(SHA-512)");
+
+ add_oid(config, "1.3.6.1.4.1.25258.2.2.1.1", "NR/EMSA2(RIPEMD-160)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.2.1.2", "NR/EMSA2(SHA-160)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.2.1.3", "NR/EMSA2(SHA-224)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.2.1.4", "NR/EMSA2(SHA-256)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.2.1.5", "NR/EMSA2(SHA-384)");
+ add_oid(config, "1.3.6.1.4.1.25258.2.2.1.6", "NR/EMSA2(SHA-512)");
+
+ add_oid(config, "2.5.4.3", "X520.CommonName");
+ add_oid(config, "2.5.4.4", "X520.Surname");
+ add_oid(config, "2.5.4.5", "X520.SerialNumber");
+ add_oid(config, "2.5.4.6", "X520.Country");
+ add_oid(config, "2.5.4.7", "X520.Locality");
+ add_oid(config, "2.5.4.8", "X520.State");
+ add_oid(config, "2.5.4.10", "X520.Organization");
+ add_oid(config, "2.5.4.11", "X520.OrganizationalUnit");
+ add_oid(config, "2.5.4.12", "X520.Title");
+ add_oid(config, "2.5.4.42", "X520.GivenName");
+ add_oid(config, "2.5.4.43", "X520.Initials");
+ add_oid(config, "2.5.4.44", "X520.GenerationalQualifier");
+ add_oid(config, "2.5.4.46", "X520.DNQualifier");
+ add_oid(config, "2.5.4.65", "X520.Pseudonym");
+
+ add_oid(config, "1.2.840.113549.1.5.12", "PKCS5.PBKDF2");
+ add_oid(config, "1.2.840.113549.1.5.1", "PBE-PKCS5v15(MD2,DES/CBC)");
+ add_oid(config, "1.2.840.113549.1.5.4", "PBE-PKCS5v15(MD2,RC2/CBC)");
+ add_oid(config, "1.2.840.113549.1.5.3", "PBE-PKCS5v15(MD5,DES/CBC)");
+ add_oid(config, "1.2.840.113549.1.5.6", "PBE-PKCS5v15(MD5,RC2/CBC)");
+ add_oid(config, "1.2.840.113549.1.5.10", "PBE-PKCS5v15(SHA-160,DES/CBC)");
+ add_oid(config, "1.2.840.113549.1.5.11", "PBE-PKCS5v15(SHA-160,RC2/CBC)");
+ add_oid(config, "1.2.840.113549.1.5.13", "PBE-PKCS5v20");
+
+ add_oid(config, "1.2.840.113549.1.9.1", "PKCS9.EmailAddress");
+ add_oid(config, "1.2.840.113549.1.9.2", "PKCS9.UnstructuredName");
+ add_oid(config, "1.2.840.113549.1.9.3", "PKCS9.ContentType");
+ add_oid(config, "1.2.840.113549.1.9.4", "PKCS9.MessageDigest");
+ add_oid(config, "1.2.840.113549.1.9.7", "PKCS9.ChallengePassword");
+ add_oid(config, "1.2.840.113549.1.9.14", "PKCS9.ExtensionRequest");
+
+ add_oid(config, "1.2.840.113549.1.7.1", "CMS.DataContent");
+ add_oid(config, "1.2.840.113549.1.7.2", "CMS.SignedData");
+ add_oid(config, "1.2.840.113549.1.7.3", "CMS.EnvelopedData");
+ add_oid(config, "1.2.840.113549.1.7.5", "CMS.DigestedData");
+ add_oid(config, "1.2.840.113549.1.7.6", "CMS.EncryptedData");
+ add_oid(config, "1.2.840.113549.1.9.16.1.2", "CMS.AuthenticatedData");
+ add_oid(config, "1.2.840.113549.1.9.16.1.9", "CMS.CompressedData");
+
+ add_oid(config, "2.5.29.14", "X509v3.SubjectKeyIdentifier");
+ add_oid(config, "2.5.29.15", "X509v3.KeyUsage");
+ add_oid(config, "2.5.29.17", "X509v3.SubjectAlternativeName");
+ add_oid(config, "2.5.29.18", "X509v3.IssuerAlternativeName");
+ add_oid(config, "2.5.29.19", "X509v3.BasicConstraints");
+ add_oid(config, "2.5.29.20", "X509v3.CRLNumber");
+ add_oid(config, "2.5.29.21", "X509v3.ReasonCode");
+ add_oid(config, "2.5.29.23", "X509v3.HoldInstructionCode");
+ add_oid(config, "2.5.29.24", "X509v3.InvalidityDate");
+ add_oid(config, "2.5.29.32", "X509v3.CertificatePolicies");
+ add_oid(config, "2.5.29.35", "X509v3.AuthorityKeyIdentifier");
+ add_oid(config, "2.5.29.36", "X509v3.PolicyConstraints");
+ add_oid(config, "2.5.29.37", "X509v3.ExtendedKeyUsage");
+
+ add_oid(config, "2.5.29.32.0", "X509v3.AnyPolicy");
+
+ add_oid(config, "1.3.6.1.5.5.7.3.1", "PKIX.ServerAuth");
+ add_oid(config, "1.3.6.1.5.5.7.3.2", "PKIX.ClientAuth");
+ add_oid(config, "1.3.6.1.5.5.7.3.3", "PKIX.CodeSigning");
+ add_oid(config, "1.3.6.1.5.5.7.3.4", "PKIX.EmailProtection");
+ add_oid(config, "1.3.6.1.5.5.7.3.5", "PKIX.IPsecEndSystem");
+ add_oid(config, "1.3.6.1.5.5.7.3.6", "PKIX.IPsecTunnel");
+ add_oid(config, "1.3.6.1.5.5.7.3.7", "PKIX.IPsecUser");
+ add_oid(config, "1.3.6.1.5.5.7.3.8", "PKIX.TimeStamping");
+ add_oid(config, "1.3.6.1.5.5.7.3.9", "PKIX.OCSPSigning");
+
+ add_oid(config, "1.3.6.1.5.5.7.8.5", "PKIX.XMPPAddr");
+
+ /* CVC */
+ add_oid(config, "0.4.0.127.0.7.3.1.2.1",
+ "CertificateHolderAuthorizationTemplate");
+ }
+
+/*
+* Set the default algorithm aliases
+*/
+void set_default_aliases(Library_State& config)
+ {
+ config.add_alias("OpenPGP.Cipher.1", "IDEA");
+ config.add_alias("OpenPGP.Cipher.2", "TripleDES");
+ config.add_alias("OpenPGP.Cipher.3", "CAST-128");
+ config.add_alias("OpenPGP.Cipher.4", "Blowfish");
+ config.add_alias("OpenPGP.Cipher.5", "SAFER-SK(13)");
+ config.add_alias("OpenPGP.Cipher.7", "AES-128");
+ config.add_alias("OpenPGP.Cipher.8", "AES-192");
+ config.add_alias("OpenPGP.Cipher.9", "AES-256");
+ config.add_alias("OpenPGP.Cipher.10", "Twofish");
+
+ config.add_alias("OpenPGP.Digest.1", "MD5");
+ config.add_alias("OpenPGP.Digest.2", "SHA-1");
+ config.add_alias("OpenPGP.Digest.3", "RIPEMD-160");
+ config.add_alias("OpenPGP.Digest.5", "MD2");
+ config.add_alias("OpenPGP.Digest.6", "Tiger(24,3)");
+ config.add_alias("OpenPGP.Digest.8", "SHA-256");
+
+ config.add_alias("TLS.Digest.0", "Parallel(MD5,SHA-160)");
+
+ config.add_alias("EME-PKCS1-v1_5", "PKCS1v15");
+ config.add_alias("OAEP-MGF1", "EME1");
+ config.add_alias("EME-OAEP", "EME1");
+ config.add_alias("X9.31", "EMSA2");
+ config.add_alias("EMSA-PKCS1-v1_5", "EMSA3");
+ config.add_alias("PSS-MGF1", "EMSA4");
+ config.add_alias("EMSA-PSS", "EMSA4");
+
+ config.add_alias("Rijndael", "AES");
+ config.add_alias("3DES", "TripleDES");
+ config.add_alias("DES-EDE", "TripleDES");
+ config.add_alias("CAST5", "CAST-128");
+ config.add_alias("SHA1", "SHA-160");
+ config.add_alias("SHA-1", "SHA-160");
+ config.add_alias("MARK-4", "ARC4(256)");
+ config.add_alias("OMAC", "CMAC");
+ config.add_alias("GOST", "GOST-28147-89");
+ }
+
+/*
+* Set the default configuration toggles
+*/
+void set_default_config(Library_State& config)
+ {
+ config.set_option("base/default_allocator", "malloc");
+
+ config.set_option("x509/exts/basic_constraints", "critical");
+ config.set_option("x509/exts/subject_key_id", "yes");
+ config.set_option("x509/exts/authority_key_id", "yes");
+ config.set_option("x509/exts/subject_alternative_name", "yes");
+ config.set_option("x509/exts/issuer_alternative_name", "no");
+ config.set_option("x509/exts/key_usage", "critical");
+ config.set_option("x509/exts/extended_key_usage", "yes");
+ config.set_option("x509/exts/crl_number", "yes");
+ }
+
+/*
+* Set the built-in discrete log groups
+*/
+void set_default_dl_groups(Library_State& config)
+ {
+ config.set("dl", "modp/ietf/768",
+ "-----BEGIN X942 DH PARAMETERS-----"
+ "MIHIAmEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxObIlFK"
+ "CHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjo2IP//"
+ "////////AgECAmB//////////+SH7VEQtGEaYmMxRcBuDmiUgScERTPmOgEF31Md"
+ "ic2RKKUEPMcaAm73yozZ5p0hjZgVhTb5L4obp/Catrao4SLyQtq7MS8/Y3omIXTT"
+ "HRsQf/////////8="
+ "-----END X942 DH PARAMETERS-----");
+
+ config.set("dl", "modp/ietf/1024",
+ "-----BEGIN X942 DH PARAMETERS-----"
+ "MIIBCgKBgQD//////////8kP2qIhaMI0xMZii4DcHNEpAk4IimfMdAILvqY7E5si"
+ "UUoIeY40BN3vlRmzzTpDGzArCm3yXxQ3T+E1bW1RwkXkhbV2Yl5+xvRMQummN+1r"
+ "C/9ctvQGt+3uOGv7Womfpa6fJBF8Sx/mSShmUezmU4H//////////wIBAgKBgH//"
+ "////////5IftURC0YRpiYzFFwG4OaJSBJwRFM+Y6AQXfUx2JzZEopQQ8xxoCbvfK"
+ "jNnmnSGNmBWFNvkvihun8Jq2tqjhIvJC2rsxLz9jeiYhdNMb9rWF/65begNb9vcc"
+ "Nf2tRM/S10+SCL4lj/MklDMo9nMpwP//////////"
+ "-----END X942 DH PARAMETERS-----");
+
+ config.set("dl", "modp/ietf/1536",
+ "-----BEGIN X942 DH PARAMETERS-----"
+ "MIIBigKBwQD//////////8kP2qIhaMI0xMZii4DcHNEpAk4IimfMdAILvqY7E5si"
+ "UUoIeY40BN3vlRmzzTpDGzArCm3yXxQ3T+E1bW1RwkXkhbV2Yl5+xvRMQummN+1r"
+ "C/9ctvQGt+3uOGv7Womfpa6fJBF8Sx/mSShmUezkWz3CAHy4oWO/BZjaSDYcVdOa"
+ "aRY/qP0kz1+DZV0j3KOtlhxi81YghVK7ntUpB3CWlm1nDDVOSryYBPF0bAjKI3Mn"
+ "//////////8CAQICgcB//////////+SH7VEQtGEaYmMxRcBuDmiUgScERTPmOgEF"
+ "31Mdic2RKKUEPMcaAm73yozZ5p0hjZgVhTb5L4obp/Catrao4SLyQtq7MS8/Y3om"
+ "IXTTG/a1hf+uW3oDW/b3HDX9rUTP0tdPkgi+JY/zJJQzKPZyLZ7hAD5cULHfgsxt"
+ "JBsOKunNNIsf1H6SZ6/Bsq6R7lHWyw4xeasQQqldz2qUg7hLSzazhhqnJV5MAni6"
+ "NgRlEbmT//////////8="
+ "-----END X942 DH PARAMETERS-----");
+
+ config.set("dl", "modp/ietf/2048",
+ "-----BEGIN X942 DH PARAMETERS-----"
+ "MIICDAKCAQEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb"
+ "IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft"
+ "awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT"
+ "mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh"
+ "fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq"
+ "5RXSJhiY+gUQFXKOWoqsqmj//////////wIBAgKCAQB//////////+SH7VEQtGEa"
+ "YmMxRcBuDmiUgScERTPmOgEF31Mdic2RKKUEPMcaAm73yozZ5p0hjZgVhTb5L4ob"
+ "p/Catrao4SLyQtq7MS8/Y3omIXTTG/a1hf+uW3oDW/b3HDX9rUTP0tdPkgi+JY/z"
+ "JJQzKPZyLZ7hAD5cULHfgsxtJBsOKunNNIsf1H6SZ6/Bsq6R7lHWyw4xeasQQqld"
+ "z2qUg7hLSzazhhqnJV5MAni6NgRlDBC+GUgvIxcbZx3xzzuWDAdDAc2TwdF2A9FH"
+ "2uKu+DemKWTvFeX7SqwLjBzKpL51SrVyiukTDEx9AogKuUctRVZVNH//////////"
+ "-----END X942 DH PARAMETERS-----");
+
+ config.set("dl", "modp/ietf/3072",
+ "-----BEGIN X942 DH PARAMETERS-----"
+ "MIIDDAKCAYEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb"
+ "IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft"
+ "awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT"
+ "mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh"
+ "fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq"
+ "5RXSJhiY+gUQFXKOWoqqxC2tMxcNBFB6M6hVIavfHLpk7PuFBFjb7wqK6nFXXQYM"
+ "fbOXD4Wm4eTHq/WujNsJM9cejJTgSiVhnc7j0iYa0u5r8S/6BtmKCGTYdgJzPshq"
+ "ZFIfKxgXeyAMu+EXV3phXWx3CYjAutlG4gjiT6B05asxQ9tb/OD9EI5LgtEgqTrS"
+ "yv//////////AgECAoIBgH//////////5IftURC0YRpiYzFFwG4OaJSBJwRFM+Y6"
+ "AQXfUx2JzZEopQQ8xxoCbvfKjNnmnSGNmBWFNvkvihun8Jq2tqjhIvJC2rsxLz9j"
+ "eiYhdNMb9rWF/65begNb9vccNf2tRM/S10+SCL4lj/MklDMo9nItnuEAPlxQsd+C"
+ "zG0kGw4q6c00ix/UfpJnr8GyrpHuUdbLDjF5qxBCqV3PapSDuEtLNrOGGqclXkwC"
+ "eLo2BGUMEL4ZSC8jFxtnHfHPO5YMB0MBzZPB0XYD0Ufa4q74N6YpZO8V5ftKrAuM"
+ "HMqkvnVKtXKK6RMMTH0CiAq5Ry1FVWIW1pmLhoIoPRnUKpDV745dMnZ9woIsbfeF"
+ "RXU4q66DBj7Zy4fC03DyY9X610ZthJnrj0ZKcCUSsM7ncekTDWl3NfiX/QNsxQQy"
+ "bDsBOZ9kNTIpD5WMC72QBl3wi6u9MK62O4TEYF1so3EEcSfQOnLVmKHtrf5wfohH"
+ "JcFokFSdaWV//////////w=="
+ "-----END X942 DH PARAMETERS-----");
+
+ config.set("dl", "modp/ietf/4096",
+ "-----BEGIN X942 DH PARAMETERS-----"
+ "MIIEDAKCAgEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76m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HVWxzi1yerQaEdo6FfjkvBHHi2XxzrKW8f7c"
+ "X35CRWyRERcCUgG+A4n1q9QNEfhjmjn+MjZ1GDWl5eRDF8HC7v1Opb/RYEP0PLQZ"
+ "gfat7p0DFZ562dE8UzaVCfwfonwW75iHcDpVtRsiy/RM0BKu4LJ5jmKEI0KO/NWk"
+ "DK72v1DY6ohev3Omuf15teGPZ9E0GsgjenXDz8kgBKHFpA42a8RNABdq9xwV5IyG"
+ "034BNyPKrHIjqzv01U8YKHE7K0pv5A+rdEBctziwZMBuzHbp7///////////AgEC"
+ "-----END X942 DH PARAMETERS-----");
+
+ config.set("dl", "dsa/jce/512",
+ "-----BEGIN DSA PARAMETERS-----"
+ "MIGdAkEA/KaCzo4Syrom78z3EQ5SbbB4sF7ey80etKII864WF64B81uRpH5t9jQT"
+ "xeEu0ImbzRMqzVDZkVG9xD7nN1kuFwIVAJYu3cw2nLqOuyYO5rahJtk0bjjFAkEA"
+ "3gtU76vylwh+5iPVylWIxkgo70/eT/uuHs0gBndrBbEbgeo83pvDlkwWh8UyW/Q9"
+ "fM76DQqGvl3/3dDRFD3NdQ=="
+ "-----END DSA PARAMETERS-----");
+
+ config.set("dl", "dsa/jce/768",
+ "-----BEGIN DSA PARAMETERS-----"
+ "MIHdAmEA6eZCWZ01XzfJf/01ZxILjiXJzUPpJ7OpZw++xdiQFBki0sOzrSSACTeZ"
+ "hp0ehGqrSfqwrSbSzmoiIZ1HC859d31KIfvpwnC1f2BwAvPO+Dk2lM9F7jaIwRqM"
+ "VqsSej2vAhUAnNvYTJ8awvOND4D0KrlS5zOL9RECYQDe7p717RUWzn5pXmcrjO5F"
+ "5s17NuDmOF+JS6hhY/bz5sbU6KgRRtQBfe/dccvZD6Akdlm4i3zByJT0gmn9Txqs"
+ "CjBTjf9rP8ds+xMcnnlltYhYqwpDtVczWRKoqlR/lWg="
+ "-----END DSA PARAMETERS-----");
+
+ config.set("dl", "dsa/jce/1024",
+ "-----BEGIN DSA PARAMETERS-----"
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t/kd7NukRriJkPePL/kfL+fNQ/0uRtGOraH3u2YCxh"
+ "f27zpLKE8v2boQo2BC3o+oeiyjZZf+yBFXoUheRAQd8CgwERy4gLvm7UlIFIhvll"
+ "zcMTX1zPE4Nyi/ZbgG+WksCxDWxMCcdabKO0ATyxarLBBfa+I66pAA6rIXiYX5cs"
+ "mAV+HIbkTnIYaI6krg82NtzKdFydzU5q/7Z8y8E9YTE="
+ "-----END DSA PARAMETERS-----");
+
+ config.set("dl", "dsa/botan/3072",
+ "-----BEGIN DSA PARAMETERS-----"
+ "MIIDLAKCAYEA5LUIgHWWY1heFCRgyi2d/xMviuTIQN2jomZoiRJP5WOLhOiim3rz"
+ "+hIJvmv8S1By7Tsrc4e68/hX9HioAijvNgC3az3Pth0g00RlslBtLK+H3259wM6R"
+ "vS0Wekb2rcwxxTHk+cervbkq3fNbCoBsZikqX14X6WTdCZkDczrEKKs12A6m9oW/"
+ "uovkBo5UGK5eytno/wc94rY+Tn6tNciptwtb1Hz7iNNztm83kxk5sKtxvVWVgJCG"
+ "2gFVM30YWg5Ps2pRmxtiArhZHmACRJzxzTpmOE9tIHOxzXO+ypO68eGmEX0COPIi"
+ "rh7X/tGFqJDn9n+rj+uXU8wTSlGD3+h64llfe1wtn7tCJJ/dWVE+HTOWs+sv2GaE"
+ "8oWoRI/nV6ApiBxAdguU75Gb35dAw4OJWZ7FGm6btRmo4GhJHpzgovz+PLYNZs8N"
+ "+tIKjsaEBIaEphREV1vRck1zUrRKdgB3s71r04XOWwpyUMwL92jagpI4Buuc+7E4"
+ "hDcxthggjHWbAiEAs+vTZOxp74zzuvZDt1c0sWM5suSeXN4bWcHp+0DuDFsCggGA"
+ "K+0h7vg5ZKIwrom7px2ffDnFL8gim047x+WUTTKdoQ8BDqyee69sAJ/E6ylgcj4r"
+ "Vt9GY+TDrIAOkljeL3ZJ0gZ4KJP4Ze/KSY0u7zAHTqXop6smJxKk2UovOwuaku5A"
+ "D7OKPMWaXcfkNtXABLIuNQKDgbUck0B+sy1K4P1Cy0XhLQ7O6KJiOO3iCCp7FSIR"
+ "PGbO+NdFxs88uUX4TS9N4W1Epx3hmCcOE/A1U8iLjTI60LlIob8hA6lJl5tu0W+1"
+ "88lT2Vt8jojKZ9z1pjb7nKOdkkIV96iE7Wx+48ltjZcVQnl0t8Q1EoLhPTdz99KL"
+ "RS8QiSoTx1hzKN6kgntrNpsqjcFyrcWD9R8qZZjFSD5bxGewL5HQWcQC0Y4sJoD3"
+ "dqoG9JKAoscsF8xC1bbnQMXEsas8UcLtCSviotiwU65Xc9FCXtKwjwbi3VBZLfGk"
+ "eMFVkc39EVZP+I/zi3IdQjkv2kcyEtz9jS2IqXagCv/m//tDCjWeZMorNRyiQSOU"
+ "-----END DSA PARAMETERS-----");
+ }
+}
+
+/*
+* Set the default policy
+*/
+void Library_State::load_default_config()
+ {
+ set_default_config(*this);
+ set_default_aliases(*this);
+ set_default_oids(*this);
+ set_default_dl_groups(*this);
+ }
+
+}
diff --git a/old/botan/src/libstate/scan_name.cpp b/old/botan/src/libstate/scan_name.cpp
new file mode 100644
index 0000000..ef77187
--- /dev/null
+++ b/old/botan/src/libstate/scan_name.cpp
@@ -0,0 +1,74 @@
+/**
+SCAN Name Abstraction
+(C) 2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/scan_name.h>
+#include <botan/parsing.h>
+#include <botan/libstate.h>
+#include <stdexcept>
+
+namespace Botan {
+
+namespace {
+
+std::vector<std::string>
+parse_and_deref_aliases(const std::string& algo_spec)
+ {
+ std::vector<std::string> parts = parse_algorithm_name(algo_spec);
+ std::vector<std::string> out;
+
+ for(size_t i = 0; i != parts.size(); ++i)
+ {
+ std::string part_i = global_state().deref_alias(parts[i]);
+
+ if(i == 0 && part_i.find_first_of(",()") != std::string::npos)
+ {
+ std::vector<std::string> parts_i = parse_and_deref_aliases(part_i);
+
+ for(size_t j = 0; j != parts_i.size(); ++j)
+ out.push_back(parts_i[j]);
+ }
+ else
+ out.push_back(part_i);
+ }
+
+ return out;
+ }
+
+}
+
+SCAN_Name::SCAN_Name(const std::string& algo_spec)
+ {
+ orig_algo_spec = algo_spec;
+
+ name = parse_and_deref_aliases(algo_spec);
+
+ if(name.size() == 0)
+ throw Decoding_Error("Bad SCAN name " + algo_spec);
+ }
+
+std::string SCAN_Name::arg(u32bit i) const
+ {
+ if(i >= arg_count())
+ throw std::range_error("SCAN_Name::argument");
+ return name[i+1];
+ }
+
+std::string SCAN_Name::arg(u32bit i, const std::string& def_value) const
+ {
+ if(i >= arg_count())
+ return def_value;
+ return name[i+1];
+ }
+
+u32bit SCAN_Name::arg_as_u32bit(u32bit i, u32bit def_value) const
+ {
+ if(i >= arg_count())
+ return def_value;
+ return to_u32bit(name[i+1]);
+ }
+
+}
diff --git a/old/botan/src/libstate/scan_name.h b/old/botan/src/libstate/scan_name.h
new file mode 100644
index 0000000..9e7af40
--- /dev/null
+++ b/old/botan/src/libstate/scan_name.h
@@ -0,0 +1,77 @@
+/**
+SCAN Name Abstraction
+(C) 2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_SCAN_NAME_H__
+#define BOTAN_SCAN_NAME_H__
+
+#include <botan/types.h>
+#include <string>
+#include <vector>
+#include <set>
+
+namespace Botan {
+
+/**
+A class encapsulating a SCAN name (similar to JCE conventions)
+http://www.users.zetnet.co.uk/hopwood/crypto/scan/
+*/
+class SCAN_Name
+ {
+ public:
+ /**
+ @param algo_spec A SCAN name
+ */
+ SCAN_Name(const std::string& algo_spec);
+
+ /**
+ @return the original input string
+ */
+ std::string as_string() const { return orig_algo_spec; }
+
+ /**
+ @return the algorithm name
+ */
+ std::string algo_name() const { return name[0]; }
+
+ /**
+ @return the number of arguments
+ */
+ u32bit arg_count() const { return name.size() - 1; }
+
+ /**
+ @return if the number of arguments is between lower and upper
+ */
+ bool arg_count_between(u32bit lower, u32bit upper) const
+ { return ((arg_count() >= lower) && (arg_count() <= upper)); }
+
+ /**
+ @param i which argument
+ @return the ith argument
+ */
+ std::string arg(u32bit i) const;
+
+ /**
+ @param i which argument
+ @param def_value the default value
+ @return the ith argument or the default value
+ */
+ std::string arg(u32bit i, const std::string& def_value) const;
+
+ /**
+ @param i which argument
+ @param def_value the default value
+ @return the ith argument as a u32bit, or the default value
+ */
+ u32bit arg_as_u32bit(u32bit i, u32bit def_value) const;
+ private:
+ std::string orig_algo_spec;
+ std::vector<std::string> name;
+ };
+
+}
+
+#endif