diff options
author | lloyd <[email protected]> | 2008-04-10 05:50:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-04-10 05:50:57 +0000 |
commit | 59e71322cad61ff2f09664fc3e59b5446af4566a (patch) | |
tree | d6bf11f3541d891228f755eeb0a2fef1904852eb /modules | |
parent | a5cbd8f304d646352789686a659c6923e320f22d (diff) |
Remove severa global configuration variables related to entropy gathering,
instead passing those values as arguments.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/es_dev/es_dev.cpp | 9 | ||||
-rw-r--r-- | modules/es_dev/es_dev.h | 4 | ||||
-rw-r--r-- | modules/es_egd/es_egd.cpp | 15 | ||||
-rw-r--r-- | modules/es_egd/es_egd.h | 4 | ||||
-rw-r--r-- | modules/es_unix/es_unix.cpp | 5 | ||||
-rw-r--r-- | modules/es_unix/es_unix.h | 3 | ||||
-rw-r--r-- | modules/es_unix/unix_cmd.cpp | 8 | ||||
-rw-r--r-- | modules/es_unix/unix_cmd.h | 5 |
8 files changed, 18 insertions, 35 deletions
diff --git a/modules/es_dev/es_dev.cpp b/modules/es_dev/es_dev.cpp index ade41f2eb..6045989b5 100644 --- a/modules/es_dev/es_dev.cpp +++ b/modules/es_dev/es_dev.cpp @@ -95,16 +95,11 @@ int Device_Reader::open(const std::string& pathname) *************************************************/ u32bit Device_EntropySource::slow_poll(byte output[], u32bit length) { - std::vector<std::string> sources = - global_config().option_as_list("rng/es_files"); - u32bit read = 0; - for(size_t j = 0; j != sources.size(); ++j) + for(size_t j = 0; j != fsnames.size(); ++j) { - const std::string source = sources[j]; - - Device_Reader reader(Device_Reader::open(source)); + Device_Reader reader(Device_Reader::open(fsnames[j])); read += reader.get(output + read, length - read); diff --git a/modules/es_dev/es_dev.h b/modules/es_dev/es_dev.h index 8572094b7..c2b64e9f1 100644 --- a/modules/es_dev/es_dev.h +++ b/modules/es_dev/es_dev.h @@ -7,6 +7,7 @@ #define BOTAN_ENTROPY_SRC_DEVICE_H__ #include <botan/base.h> +#include <vector> namespace Botan { @@ -16,7 +17,10 @@ namespace Botan { class Device_EntropySource : public EntropySource { public: + Device_EntropySource(const std::vector<std::string>& fs) : fsnames(fs) {} u32bit slow_poll(byte[], u32bit); + private: + std::vector<std::string> fsnames; }; } diff --git a/modules/es_egd/es_egd.cpp b/modules/es_egd/es_egd.cpp index 9d3f4c29f..6b32d1d7f 100644 --- a/modules/es_egd/es_egd.cpp +++ b/modules/es_egd/es_egd.cpp @@ -21,21 +21,6 @@ namespace Botan { /************************************************* -* EGD_EntropySource Constructor * -*************************************************/ -EGD_EntropySource::EGD_EntropySource(const std::string& egd_paths) - { - std::vector<std::string> path_list = split_on(egd_paths, ':'); - std::vector<std::string> defaults = - global_config().option_as_list("rng/egd_path"); - - for(u32bit j = 0; j != path_list.size(); j++) - paths.push_back(path_list[j]); - for(u32bit j = 0; j != defaults.size(); j++) - paths.push_back(defaults[j]); - } - -/************************************************* * Gather Entropy from EGD * *************************************************/ u32bit EGD_EntropySource::do_poll(byte output[], u32bit length, diff --git a/modules/es_egd/es_egd.h b/modules/es_egd/es_egd.h index 664609cba..20df8b606 100644 --- a/modules/es_egd/es_egd.h +++ b/modules/es_egd/es_egd.h @@ -19,10 +19,10 @@ class EGD_EntropySource : public EntropySource { public: u32bit slow_poll(byte[], u32bit); - EGD_EntropySource(const std::string& = ""); + EGD_EntropySource(const std::vector<std::string>& p) : paths(p) {} private: u32bit do_poll(byte[], u32bit, const std::string&) const; - std::vector<std::string> paths; + const std::vector<std::string> paths; }; } diff --git a/modules/es_unix/es_unix.cpp b/modules/es_unix/es_unix.cpp index bc34fa8bf..466c0accb 100644 --- a/modules/es_unix/es_unix.cpp +++ b/modules/es_unix/es_unix.cpp @@ -28,7 +28,8 @@ bool Unix_Program_Cmp(const Unix_Program& a, const Unix_Program& b) /************************************************* * Unix_EntropySource Constructor * *************************************************/ -Unix_EntropySource::Unix_EntropySource() +Unix_EntropySource::Unix_EntropySource(const std::vector<std::string>& path) : + PATH(path) { add_default_sources(sources); } @@ -86,8 +87,6 @@ void Unix_EntropySource::do_slow_poll() const u32bit TRY_TO_GET = 16 * 1024; const u32bit MINIMAL_WORKING = 32; - const std::string PATH = global_config().option("rng/unix_path"); - u32bit got = 0; for(u32bit j = 0; j != sources.size(); j++) { diff --git a/modules/es_unix/es_unix.h b/modules/es_unix/es_unix.h index 2bc6e9329..a1e279633 100644 --- a/modules/es_unix/es_unix.h +++ b/modules/es_unix/es_unix.h @@ -19,13 +19,14 @@ class Unix_EntropySource : public Buffered_EntropySource { public: void add_sources(const Unix_Program[], u32bit); - Unix_EntropySource(); + Unix_EntropySource(const std::vector<std::string>& path); private: static void add_default_sources(std::vector<Unix_Program>&); void do_fast_poll(); void do_slow_poll(); + const std::vector<std::string> PATH; std::vector<Unix_Program> sources; }; diff --git a/modules/es_unix/unix_cmd.cpp b/modules/es_unix/unix_cmd.cpp index a83063f7f..6fcfa0d40 100644 --- a/modules/es_unix/unix_cmd.cpp +++ b/modules/es_unix/unix_cmd.cpp @@ -128,10 +128,8 @@ std::string DataSource_Command::id() const /************************************************* * Create the pipe * *************************************************/ -void DataSource_Command::create_pipe(const std::string& path) +void DataSource_Command::create_pipe(const std::vector<std::string>& paths) { - const std::vector<std::string> paths = split_on(path, ':'); - bool found_something = false; for(u32bit j = 0; j != paths.size(); j++) { @@ -216,7 +214,7 @@ void DataSource_Command::shutdown_pipe() * DataSource_Command Constructor * *************************************************/ DataSource_Command::DataSource_Command(const std::string& prog_and_args, - const std::string& path) : + const std::vector<std::string>& paths) : MAX_BLOCK_USECS(100000), KILL_WAIT(10000) { arg_list = split_on(prog_and_args, ' '); @@ -227,7 +225,7 @@ DataSource_Command::DataSource_Command(const std::string& prog_and_args, throw Invalid_Argument("DataSource_Command: Too many args"); pipe = 0; - create_pipe(path); + create_pipe(paths); } /************************************************* diff --git a/modules/es_unix/unix_cmd.h b/modules/es_unix/unix_cmd.h index 42211b0a4..0e187db03 100644 --- a/modules/es_unix/unix_cmd.h +++ b/modules/es_unix/unix_cmd.h @@ -39,10 +39,11 @@ class DataSource_Command : public DataSource int fd() const; - DataSource_Command(const std::string&, const std::string&); + DataSource_Command(const std::string&, + const std::vector<std::string>& paths); ~DataSource_Command(); private: - void create_pipe(const std::string&); + void create_pipe(const std::vector<std::string>&); void shutdown_pipe(); const u32bit MAX_BLOCK_USECS, KILL_WAIT; |