diff options
author | lloyd <[email protected]> | 2015-02-04 04:03:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-02-04 04:03:38 +0000 |
commit | 0dd060fed07b0060f94e3bae62e125a85c1bb877 (patch) | |
tree | ed4bc7a961e2b30f17ed5e80769c84b0c313c8b7 /src/cmd | |
parent | f9a7c85b74be0f4a7273e8e0591703af83036e81 (diff) |
Remove algo factory, engines, global RNG, global state, etc.
Convert all uses of Algorithm_Factory and the engines to using Algo_Registry
The shared pool of entropy sources remains but is moved to EntropySource.
With that and few remaining initializations (default OIDs and aliases)
moved elsewhere, the global state is empty and init and shutdown are no-ops.
Remove almost all of the headers and code for handling the global
state, except LibraryInitializer which remains as a compatability stub.
Update seeding for blinding so only one hacky almost-global RNG
instance needs to be setup instead of across all pubkey uses (it uses
either the system RNG or an AutoSeeded_RNG if the system RNG is not
available).
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/hash.cpp | 7 | ||||
-rw-r--r-- | src/cmd/main.cpp | 4 | ||||
-rw-r--r-- | src/cmd/rng.cpp | 5 | ||||
-rw-r--r-- | src/cmd/speed.cpp | 10 |
4 files changed, 8 insertions, 18 deletions
diff --git a/src/cmd/hash.cpp b/src/cmd/hash.cpp index df332cb23..dd5bc1e82 100644 --- a/src/cmd/hash.cpp +++ b/src/cmd/hash.cpp @@ -6,6 +6,7 @@ #include "apps.h" #include <botan/lookup.h> +#include <botan/filters.h> #include <iostream> #include <fstream> @@ -27,12 +28,6 @@ int hash(int argc, char* argv[]) if(hash == "md5") hash = "MD5"; try { - if(!have_hash(hash)) - { - std::cout << "Unknown hash \"" << argv[1] << "\"" << std::endl; - return 1; - } - Pipe pipe(new Hash_Filter(hash), new Hex_Encoder); int skipped = 0; diff --git a/src/cmd/main.cpp b/src/cmd/main.cpp index 21a9ba78b..4b1e9a62d 100644 --- a/src/cmd/main.cpp +++ b/src/cmd/main.cpp @@ -35,6 +35,8 @@ int help(int , char* argv[]) std::cout << "Available commands:\n"; + Botan::LibraryInitializer init; + size_t idx = 1; for(auto&& app: apps) { @@ -155,8 +157,6 @@ int main(int argc, char* argv[]) { try { - Botan::LibraryInitializer init; - if(argc < 2) return help(argc, argv); diff --git a/src/cmd/rng.cpp b/src/cmd/rng.cpp index 3f48e629f..0c0a5a77e 100644 --- a/src/cmd/rng.cpp +++ b/src/cmd/rng.cpp @@ -5,7 +5,8 @@ */ #include "apps.h" -#include <botan/libstate.h> +#include <botan/entropy_src.h> +#include <botan/auto_rng.h> #if defined(BOTAN_HAS_SYSTEM_RNG) #include <botan/system_rng.h> @@ -48,7 +49,7 @@ int rng(int argc, char* argv[]) return total_collected >= amt; }); - global_state().poll_available_sources(accum); + EntropySource::poll_available_sources(accum); } } catch(std::exception& e) diff --git a/src/cmd/speed.cpp b/src/cmd/speed.cpp index 4558c4250..7e8dbd412 100644 --- a/src/cmd/speed.cpp +++ b/src/cmd/speed.cpp @@ -12,10 +12,6 @@ #include <botan/benchmark.h> #include <botan/aead.h> #include <botan/auto_rng.h> -#include <botan/libstate.h> -#include <botan/pipe.h> -#include <botan/filters.h> -#include <botan/engine.h> #include <botan/parsing.h> #include <botan/symkey.h> #include <botan/hex.h> @@ -163,7 +159,7 @@ void time_transform(std::unique_ptr<Transform> tf, void time_transform(const std::string& algo, RandomNumberGenerator& rng) { std::unique_ptr<Transform> tf; - tf.reset(get_aead(algo, ENCRYPTION)); + tf.reset(get_cipher_mode(algo, ENCRYPTION)); if(Keyed_Transform* keyed = dynamic_cast<Keyed_Transform*>(tf.get())) keyed->set_key(rng.random_vec(keyed->key_spec().maximum_keylength())); @@ -176,12 +172,10 @@ void bench_algo(const std::string& algo, double seconds, size_t buf_size) { - Algorithm_Factory& af = global_state().algorithm_factory(); - std::chrono::milliseconds ms( static_cast<std::chrono::milliseconds::rep>(seconds * 1000)); - std::map<std::string, double> speeds = algorithm_benchmark(algo, af, rng, ms, buf_size); + std::map<std::string, double> speeds = algorithm_benchmark(algo, rng, ms, buf_size); report_results(algo, speeds); |