From f8ff9cf9ec97a63d6947d80209fa72cff23cadf6 Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 18 Jan 2014 23:44:52 +0000 Subject: Fix algo factory compile --- src/lib/algo_factory/algo_factory.h | 4 -- src/lib/kdf/kdf.cpp | 2 +- src/lib/libstate/entropy_srcs.cpp | 123 ++++++++++++++++++++++++++++++++++++ src/lib/libstate/global_rng.cpp | 123 ------------------------------------ src/lib/pubkey/pubkey.cpp | 1 - src/lib/tls/tls_handshake_state.cpp | 1 - src/lib/tls/tls_session_key.cpp | 1 - 7 files changed, 124 insertions(+), 131 deletions(-) create mode 100644 src/lib/libstate/entropy_srcs.cpp delete mode 100644 src/lib/libstate/global_rng.cpp (limited to 'src') diff --git a/src/lib/algo_factory/algo_factory.h b/src/lib/algo_factory/algo_factory.h index 61f939cd9..40d1be5ad 100644 --- a/src/lib/algo_factory/algo_factory.h +++ b/src/lib/algo_factory/algo_factory.h @@ -205,10 +205,6 @@ class BOTAN_DLL Algorithm_Factory friend class Engine_Iterator; private: - Algorithm_Factory(const Algorithm_Factory&) {} - Algorithm_Factory& operator=(const Algorithm_Factory&) - { return (*this); } - Engine* get_engine_n(size_t n) const; std::vector engines; diff --git a/src/lib/kdf/kdf.cpp b/src/lib/kdf/kdf.cpp index 84a0cdd15..39ef9db13 100644 --- a/src/lib/kdf/kdf.cpp +++ b/src/lib/kdf/kdf.cpp @@ -5,7 +5,7 @@ * Distributed under the terms of the Botan license */ -#include +#include #include #include diff --git a/src/lib/libstate/entropy_srcs.cpp b/src/lib/libstate/entropy_srcs.cpp new file mode 100644 index 000000000..b6dc6b559 --- /dev/null +++ b/src/lib/libstate/entropy_srcs.cpp @@ -0,0 +1,123 @@ +/* +* Global PRNG +* (C) 2008-2010 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include + +#if defined(BOTAN_HAS_ENTROPY_SRC_HIGH_RESOLUTION_TIMER) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) + #include +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER) + #include +#endif + +namespace Botan { + +std::vector> Library_State::entropy_sources() + { + std::vector> sources; + +#if defined(BOTAN_HAS_ENTROPY_SRC_HIGH_RESOLUTION_TIMER) + sources.push_back(std::unique_ptr(new High_Resolution_Timestamp)); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND) + sources.push_back(std::unique_ptr(new Intel_Rdrand)); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) + sources.push_back(std::unique_ptr(new UnixProcessInfo_EntropySource)); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM) + sources.push_back(std::unique_ptr(new Device_EntropySource( + { "/dev/random", "/dev/srandom", "/dev/urandom" } + ))); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) + sources.push_back(std::unique_ptr(new Win32_CAPI_EntropySource)); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER) + sources.push_back(std::unique_ptr( + new ProcWalking_EntropySource("/proc"))); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) + sources.push_back(std::unique_ptr(new Win32_EntropySource)); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) + sources.push_back(std::unique_ptr(new BeOS_EntropySource)); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) + sources.push_back(std::unique_ptr( + new Unix_EntropySource( + { "/bin", "/sbin", "/usr/bin", "/usr/sbin" } + ))); +#endif + +#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) + sources.push_back(std::unique_ptr( + 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 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/lib/libstate/global_rng.cpp b/src/lib/libstate/global_rng.cpp deleted file mode 100644 index b6dc6b559..000000000 --- a/src/lib/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 - -#if defined(BOTAN_HAS_ENTROPY_SRC_HIGH_RESOLUTION_TIMER) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) - #include -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER) - #include -#endif - -namespace Botan { - -std::vector> Library_State::entropy_sources() - { - std::vector> sources; - -#if defined(BOTAN_HAS_ENTROPY_SRC_HIGH_RESOLUTION_TIMER) - sources.push_back(std::unique_ptr(new High_Resolution_Timestamp)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND) - sources.push_back(std::unique_ptr(new Intel_Rdrand)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) - sources.push_back(std::unique_ptr(new UnixProcessInfo_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM) - sources.push_back(std::unique_ptr(new Device_EntropySource( - { "/dev/random", "/dev/srandom", "/dev/urandom" } - ))); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_CAPI) - sources.push_back(std::unique_ptr(new Win32_CAPI_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER) - sources.push_back(std::unique_ptr( - new ProcWalking_EntropySource("/proc"))); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32) - sources.push_back(std::unique_ptr(new Win32_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_BEOS) - sources.push_back(std::unique_ptr(new BeOS_EntropySource)); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_UNIX_PROCESS_RUNNER) - sources.push_back(std::unique_ptr( - new Unix_EntropySource( - { "/bin", "/sbin", "/usr/bin", "/usr/sbin" } - ))); -#endif - -#if defined(BOTAN_HAS_ENTROPY_SRC_EGD) - sources.push_back(std::unique_ptr( - 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 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/lib/pubkey/pubkey.cpp b/src/lib/pubkey/pubkey.cpp index 2a0acb6ac..a2c5cb745 100644 --- a/src/lib/pubkey/pubkey.cpp +++ b/src/lib/pubkey/pubkey.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include namespace Botan { diff --git a/src/lib/tls/tls_handshake_state.cpp b/src/lib/tls/tls_handshake_state.cpp index 84b22cc09..a7317a333 100644 --- a/src/lib/tls/tls_handshake_state.cpp +++ b/src/lib/tls/tls_handshake_state.cpp @@ -8,7 +8,6 @@ #include #include #include -#include namespace Botan { diff --git a/src/lib/tls/tls_session_key.cpp b/src/lib/tls/tls_session_key.cpp index c13bc5af3..8bf0c94c1 100644 --- a/src/lib/tls/tls_session_key.cpp +++ b/src/lib/tls/tls_session_key.cpp @@ -8,7 +8,6 @@ #include #include #include -#include namespace Botan { -- cgit v1.2.3