diff options
author | lloyd <[email protected]> | 2014-01-01 21:20:55 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-01 21:20:55 +0000 |
commit | 197dc467dec28a04c3b2f30da7cef122dfbb13e9 (patch) | |
tree | cdbd3ddaec051c72f0a757db461973d90c37b97a /src/libstate | |
parent | 62faac373c07cfe10bc8c309e89ebdd30d8e5eaa (diff) |
Shuffle things around. Add NIST X.509 test to build.
Diffstat (limited to 'src/libstate')
-rw-r--r-- | src/libstate/botan.h | 23 | ||||
-rw-r--r-- | src/libstate/global_rng.cpp | 123 | ||||
-rw-r--r-- | src/libstate/global_state.cpp | 91 | ||||
-rw-r--r-- | src/libstate/global_state.h | 69 | ||||
-rw-r--r-- | src/libstate/info.txt | 21 | ||||
-rw-r--r-- | src/libstate/init.cpp | 47 | ||||
-rw-r--r-- | src/libstate/init.h | 48 | ||||
-rw-r--r-- | src/libstate/libstate.cpp | 104 | ||||
-rw-r--r-- | src/libstate/libstate.h | 60 | ||||
-rw-r--r-- | src/libstate/lookup.cpp | 124 | ||||
-rw-r--r-- | src/libstate/lookup.h | 276 |
11 files changed, 0 insertions, 986 deletions
diff --git a/src/libstate/botan.h b/src/libstate/botan.h deleted file mode 100644 index 42d3dc392..000000000 --- a/src/libstate/botan.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -* A vague catch all include file for Botan -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_BOTAN_H__ -#define BOTAN_BOTAN_H__ - -#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 - -#endif diff --git a/src/libstate/global_rng.cpp b/src/libstate/global_rng.cpp deleted file mode 100644 index b6dc6b559..000000000 --- a/src/libstate/global_rng.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* -* Global PRNG -* (C) 2008-2010 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/libstate.h> - -#if defined(BOTAN_HAS_ENTROPY_SRC_HIGH_RESOLUTION_TIMER) - #include <botan/internal/hres_timer.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND) - #include <botan/internal/rdrand.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM) - #include <botan/internal/dev_random.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) - #include <botan/internal/es_egd.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) - #include <botan/internal/unix_procs.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) - #include <botan/internal/es_beos.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) - #include <botan/internal/es_capi.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) - #include <botan/internal/es_win32.h> -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER) - #include <botan/internal/proc_walk.h> -#endif - -namespace Botan { - -std::vector<std::unique_ptr<EntropySource>> Library_State::entropy_sources() - { - std::vector<std::unique_ptr<EntropySource>> sources; - -#if defined(BOTAN_HAS_ENTROPY_SRC_HIGH_RESOLUTION_TIMER) - sources.push_back(std::unique_ptr<EntropySource>(new High_Resolution_Timestamp)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND) - sources.push_back(std::unique_ptr<EntropySource>(new Intel_Rdrand)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) - sources.push_back(std::unique_ptr<EntropySource>(new UnixProcessInfo_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM) - sources.push_back(std::unique_ptr<EntropySource>(new Device_EntropySource( - { "/dev/random", "/dev/srandom", "/dev/urandom" } - ))); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) - sources.push_back(std::unique_ptr<EntropySource>(new Win32_CAPI_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER) - sources.push_back(std::unique_ptr<EntropySource>( - new ProcWalking_EntropySource("/proc"))); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) - sources.push_back(std::unique_ptr<EntropySource>(new Win32_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) - sources.push_back(std::unique_ptr<EntropySource>(new BeOS_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) - sources.push_back(std::unique_ptr<EntropySource>( - new Unix_EntropySource( - { "/bin", "/sbin", "/usr/bin", "/usr/sbin" } - ))); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) - sources.push_back(std::unique_ptr<EntropySource>( - new EGD_EntropySource({ "/var/run/egd-pool", "/dev/egd-pool" }) - )); -#endif - - return sources; - } - -void Library_State::poll_available_sources(class Entropy_Accumulator& accum) - { - std::lock_guard<std::mutex> lock(m_entropy_src_mutex); - - const size_t poll_bits = accum.desired_remaining_bits(); - - if(!m_sources.empty()) - { - size_t poll_attempt = 0; - - while(!accum.polling_goal_achieved() && poll_attempt < poll_bits) - { - const size_t src_idx = poll_attempt % m_sources.size(); - m_sources[src_idx]->poll(accum); - ++poll_attempt; - } - } - } - -} - diff --git a/src/libstate/global_state.cpp b/src/libstate/global_state.cpp deleted file mode 100644 index 6a846d9b0..000000000 --- a/src/libstate/global_state.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Global State Management -* (C) 2010 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/global_state.h> -#include <botan/libstate.h> - -namespace Botan { - -/* -* @todo There should probably be a lock to avoid racy manipulation -* of the state among different threads -*/ - -namespace Global_State_Management { - -/* -* Botan's global state -*/ -namespace { - -Library_State* global_lib_state = nullptr; - -} - -/* -* 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) - { - global_lib_state = new Library_State; - global_lib_state->initialize(); - } - - return (*global_lib_state); - } - -/* -* Set a new global state object -*/ -void set_global_state(Library_State* new_state) - { - delete swap_global_state(new_state); - } - -/* -* Set a new global state object unless one already existed -*/ -bool set_global_state_unless_set(Library_State* new_state) - { - if(global_lib_state) - { - delete new_state; - return false; - } - else - { - delete swap_global_state(new_state); - return true; - } - } - -/* -* 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; - } - -/* -* Query if library is initialized -*/ -bool global_state_exists() - { - return (global_lib_state != nullptr); - } - -} - -} diff --git a/src/libstate/global_state.h b/src/libstate/global_state.h deleted file mode 100644 index 486aed17e..000000000 --- a/src/libstate/global_state.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Global State Management -* (C) 2010 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_GLOBAL_STATE_H__ -#define BOTAN_GLOBAL_STATE_H__ - -#include <botan/build.h> - -namespace Botan { - -/* -* Forward declare to avoid recursive dependency between this header -* and libstate.h -*/ -class Library_State; - -/** -* Namespace for management of the global state -*/ -namespace Global_State_Management { - -/** -* Access the global library state -* @return reference to the global library state -*/ -BOTAN_DLL Library_State& global_state(); - -/** -* Set the global state object -* @param state the new global state to use -*/ -BOTAN_DLL void set_global_state(Library_State* state); - -/** -* Set the global state object unless it is already set -* @param state the new global state to use -* @return true if the state parameter is now being used as the global -* state, or false if one was already set, in which case the -* parameter was deleted immediately -*/ -BOTAN_DLL bool set_global_state_unless_set(Library_State* state); - -/** -* Swap the current state for another -* @param new_state the new state object to use -* @return previous state (or NULL if none) -*/ -BOTAN_DLL Library_State* swap_global_state(Library_State* new_state); - -/** -* Query if the library is currently initialized -* @return true iff the library is initialized -*/ -BOTAN_DLL bool global_state_exists(); - -} - -/* -* Insert into Botan ns for convenience/backwards compatability -*/ -using Global_State_Management::global_state; - -} - -#endif diff --git a/src/libstate/info.txt b/src/libstate/info.txt deleted file mode 100644 index 49a6d38ee..000000000 --- a/src/libstate/info.txt +++ /dev/null @@ -1,21 +0,0 @@ -load_on always - -<requires> -algo_factory -alloc -bigint -block -core_engine -engine -filters -hash -hmac -kdf -mac -mode_pad -pbkdf -pk_pad -pubkey -rng -stream -</requires> diff --git a/src/libstate/init.cpp b/src/libstate/init.cpp deleted file mode 100644 index 2d724f366..000000000 --- a/src/libstate/init.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -* Default Initialization Function -* (C) 1999-2009 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/init.h> -#include <botan/libstate.h> -#include <botan/global_state.h> - -namespace Botan { - -/* -* Library Initialization -*/ -void LibraryInitializer::initialize(const std::string&) - { - - try - { - /* - This two stage initialization process is because Library_State's - constructor will implicitly refer to global state through the - allocators and so forth, so global_state() has to be a valid - reference before initialize() can be called. Yeah, gross. - */ - Global_State_Management::set_global_state(new Library_State); - - global_state().initialize(); - } - catch(...) - { - deinitialize(); - throw; - } - } - -/* -* Library Shutdown -*/ -void LibraryInitializer::deinitialize() - { - Global_State_Management::set_global_state(nullptr); - } - -} diff --git a/src/libstate/init.h b/src/libstate/init.h deleted file mode 100644 index 2d70e4370..000000000 --- a/src/libstate/init.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -* 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: - /** - * Initialize the library - * @param options a string listing initialization options - */ - static void initialize(const std::string& options = ""); - - /** - * Shutdown the library - */ - static void deinitialize(); - - /** - * Initialize the library - * @param options a string listing initialization options - */ - LibraryInitializer(const std::string& options = "") - { LibraryInitializer::initialize(options); } - - ~LibraryInitializer() { LibraryInitializer::deinitialize(); } - }; - -} - -#endif diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp deleted file mode 100644 index 649dcc9b4..000000000 --- a/src/libstate/libstate.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* -* Library Internal/Global State -* (C) 1999-2010 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/libstate.h> -#include <botan/charset.h> -#include <botan/engine.h> -#include <botan/cpuid.h> -#include <botan/oids.h> -#include <botan/internal/core_engine.h> -#include <botan/internal/stl_util.h> -#include <algorithm> - -#if defined(BOTAN_HAS_SELFTESTS) - #include <botan/selftest.h> -#endif - -#if defined(BOTAN_HAS_ENGINE_ASSEMBLER) - #include <botan/internal/asm_engine.h> -#endif - -#if defined(BOTAN_HAS_ENGINE_AES_ISA) - #include <botan/internal/aes_isa_engine.h> -#endif - -#if defined(BOTAN_HAS_ENGINE_SIMD) - #include <botan/internal/simd_engine.h> -#endif - -#if defined(BOTAN_HAS_ENGINE_GNU_MP) - #include <botan/internal/gnump_engine.h> -#endif - -#if defined(BOTAN_HAS_ENGINE_OPENSSL) - #include <botan/internal/openssl_engine.h> -#endif - -namespace Botan { - -/* -* Return a reference to the Algorithm_Factory -*/ -Algorithm_Factory& Library_State::algorithm_factory() const - { - if(!m_algorithm_factory) - throw Invalid_State("Uninitialized in Library_State::algorithm_factory"); - return *m_algorithm_factory; - } - -/* -* Return a reference to the global PRNG -*/ -RandomNumberGenerator& Library_State::global_rng() - { - return *m_global_prng; - } - -void Library_State::initialize() - { - if(m_algorithm_factory.get()) - throw Invalid_State("Library_State has already been initialized"); - - CPUID::initialize(); - - SCAN_Name::set_default_aliases(); - OIDS::set_defaults(); - - m_algorithm_factory.reset(new Algorithm_Factory()); - -#if defined(BOTAN_HAS_ENGINE_GNU_MP) - algorithm_factory().add_engine(new GMP_Engine); -#endif - -#if defined(BOTAN_HAS_ENGINE_OPENSSL) - algorithm_factory().add_engine(new OpenSSL_Engine); -#endif - -#if defined(BOTAN_HAS_ENGINE_AES_ISA) - algorithm_factory().add_engine(new AES_ISA_Engine); -#endif - -#if defined(BOTAN_HAS_ENGINE_SIMD) - algorithm_factory().add_engine(new SIMD_Engine); -#endif - -#if defined(BOTAN_HAS_ENGINE_ASSEMBLER) - algorithm_factory().add_engine(new Assembler_Engine); -#endif - - algorithm_factory().add_engine(new Core_Engine); - - m_sources = entropy_sources(); - - m_global_prng.reset(new Serialized_RNG()); - -#if defined(BOTAN_HAS_SELFTESTS) - confirm_startup_self_tests(algorithm_factory()); -#endif - } - -} diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h deleted file mode 100644 index d8734966a..000000000 --- a/src/libstate/libstate.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* 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/global_state.h> -#include <botan/algo_factory.h> -#include <botan/rng.h> -#include <mutex> -#include <string> -#include <vector> -#include <map> -#include <memory> - -namespace Botan { - -/** -* Global Library State -*/ -class BOTAN_DLL Library_State - { - public: - Library_State() {} - - Library_State(const Library_State&) = delete; - Library_State& operator=(const Library_State&) = delete; - - void initialize(); - - /** - * @return global Algorithm_Factory - */ - Algorithm_Factory& algorithm_factory() const; - - /** - * @return global RandomNumberGenerator - */ - RandomNumberGenerator& global_rng(); - - void poll_available_sources(class Entropy_Accumulator& accum); - - private: - static std::vector<std::unique_ptr<EntropySource>> entropy_sources(); - - std::unique_ptr<Serialized_RNG> m_global_prng; - - std::mutex m_entropy_src_mutex; - std::vector<std::unique_ptr<EntropySource>> m_sources; - - std::unique_ptr<Algorithm_Factory> m_algorithm_factory; - }; - -} - -#endif diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp deleted file mode 100644 index 85f93bb95..000000000 --- a/src/libstate/lookup.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* -* 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 { - -/* -* Get a PBKDF algorithm by name -*/ -PBKDF* get_pbkdf(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(PBKDF* pbkdf = af.make_pbkdf(algo_spec)) - return pbkdf; - - throw Algorithm_Not_Found(algo_spec); - } - -/* -* Query if an algorithm exists -*/ -bool have_algorithm(const std::string& name) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(af.prototype_block_cipher(name)) - return true; - if(af.prototype_stream_cipher(name)) - return true; - if(af.prototype_hash_function(name)) - return true; - if(af.prototype_mac(name)) - return true; - return false; - } - -/* -* Query the block size of a cipher or hash -*/ -size_t block_size_of(const std::string& name) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(const BlockCipher* cipher = af.prototype_block_cipher(name)) - return cipher->block_size(); - - if(const HashFunction* hash = af.prototype_hash_function(name)) - return hash->hash_block_size(); - - throw Algorithm_Not_Found(name); - } - -/* -* Query the output_length() of a hash or MAC -*/ -size_t output_length_of(const std::string& name) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(const HashFunction* hash = af.prototype_hash_function(name)) - return hash->output_length(); - - if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) - return mac->output_length(); - - 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()) - { - if(Keyed_Filter* algo = engine->get_cipher(algo_spec, direction, af)) - 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/src/libstate/lookup.h b/src/libstate/lookup.h deleted file mode 100644 index e0024c224..000000000 --- a/src/libstate/lookup.h +++ /dev/null @@ -1,276 +0,0 @@ -/* -* 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/libstate.h> -#include <botan/engine.h> -#include <botan/filters.h> -#include <botan/mode_pad.h> -#include <botan/kdf.h> -#include <botan/eme.h> -#include <botan/emsa.h> -#include <botan/pbkdf.h> - -namespace Botan { - -/** -* Retrieve an object prototype from the global factory -* @param algo_spec an algorithm name -* @return constant prototype object (use clone to create usable object), - library retains ownership -*/ -inline const BlockCipher* -retrieve_block_cipher(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.prototype_block_cipher(algo_spec); - } - -/** -* Retrieve an object prototype from the global factory -* @param algo_spec an algorithm name -* @return constant prototype object (use clone to create usable object), - library retains ownership -*/ -inline const StreamCipher* -retrieve_stream_cipher(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.prototype_stream_cipher(algo_spec); - } - -/** -* Retrieve an object prototype from the global factory -* @param algo_spec an algorithm name -* @return constant prototype object (use clone to create usable object), - library retains ownership -*/ -inline const HashFunction* -retrieve_hash(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.prototype_hash_function(algo_spec); - } - -/** -* Retrieve an object prototype from the global factory -* @param algo_spec an algorithm name -* @return constant prototype object (use clone to create usable object), - library retains ownership -*/ -inline const MessageAuthenticationCode* -retrieve_mac(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.prototype_mac(algo_spec); - } - -/* -* Get an algorithm object -* NOTE: these functions create and return new objects, letting the -* caller assume ownership of them -*/ - -/** -* Block cipher factory method. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the desired block cipher -* @return pointer to the block cipher object -*/ -inline BlockCipher* get_block_cipher(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.make_block_cipher(algo_spec); - } - -/** -* Stream cipher factory method. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the desired stream cipher -* @return pointer to the stream cipher object -*/ -inline StreamCipher* get_stream_cipher(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.make_stream_cipher(algo_spec); - } - -/** -* Hash function factory method. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the desired hash function -* @return pointer to the hash function object -*/ -inline HashFunction* get_hash(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.make_hash_function(algo_spec); - } - -/** -* MAC factory method. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the desired MAC -* @return pointer to the MAC object -*/ -inline MessageAuthenticationCode* get_mac(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return af.make_mac(algo_spec); - } - -/** -* Password based key derivation function factory method -* @param algo_spec the name of the desired PBKDF algorithm -* @return pointer to newly allocated object of that type -*/ -BOTAN_DLL PBKDF* get_pbkdf(const std::string& algo_spec); - -/** -* @deprecated Use get_pbkdf -* @param algo_spec the name of the desired algorithm -* @return pointer to newly allocated object of that type -*/ -inline PBKDF* get_s2k(const std::string& algo_spec) - { - return get_pbkdf(algo_spec); - } - -/* -* 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 pointer to newly allocated encryption or decryption filter -*/ -BOTAN_DLL Keyed_Filter* get_cipher(const std::string& algo_spec, - const SymmetricKey& key, - const InitializationVector& iv, - Cipher_Dir direction); - -/** -* 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 pointer to the encryption or decryption filter -*/ -BOTAN_DLL Keyed_Filter* get_cipher(const std::string& algo_spec, - const SymmetricKey& key, - Cipher_Dir direction); - -/** -* 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 pointer to the encryption or decryption filter -*/ -BOTAN_DLL Keyed_Filter* get_cipher(const std::string& algo_spec, - Cipher_Dir direction); - -/** -* Check if an 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_algorithm(const std::string& algo_spec); - -/** -* Check if a block cipher algorithm exists. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm to check for -* @return true if the algorithm exists, false otherwise -*/ -inline bool have_block_cipher(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_block_cipher(algo_spec) != nullptr); - } - -/** -* Check if a stream cipher algorithm exists. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm to check for -* @return true if the algorithm exists, false otherwise -*/ -inline bool have_stream_cipher(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_stream_cipher(algo_spec) != nullptr); - } - -/** -* Check if a hash algorithm exists. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm to check for -* @return true if the algorithm exists, false otherwise -*/ -inline bool have_hash(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_hash_function(algo_spec) != nullptr); - } - -/** -* Check if a MAC algorithm exists. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm to check for -* @return true if the algorithm exists, false otherwise -*/ -inline bool have_mac(const std::string& algo_spec) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_mac(algo_spec) != nullptr); - } - -/* -* Query information about an algorithm -*/ - -/** -* Find out the block size of a certain symmetric algorithm. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm -* @return block size of the specified algorithm -*/ -BOTAN_DLL size_t block_size_of(const std::string& algo_spec); - -/** -* Find out the output length of a certain symmetric algorithm. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm -* @return output length of the specified algorithm -*/ -BOTAN_DLL size_t output_length_of(const std::string& algo_spec); - -} - -#endif |