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 | |
parent | a5cbd8f304d646352789686a659c6923e320f22d (diff) |
Remove severa global configuration variables related to entropy gathering,
instead passing those values as arguments.
-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 | ||||
-rw-r--r-- | src/base.cpp | 10 | ||||
-rw-r--r-- | src/modules.cpp | 8 | ||||
-rw-r--r-- | src/policy.cpp | 7 |
11 files changed, 24 insertions, 54 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; diff --git a/src/base.cpp b/src/base.cpp index 2117167ad..bae2f4618 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -220,15 +220,7 @@ void RandomNumberGenerator::add_entropy(const byte random[], u32bit length) u32bit RandomNumberGenerator::add_entropy(EntropySource& source, bool slow_poll) { - std::string poll_type; - if(slow_poll) - poll_type = "rng/slow_poll_request"; - else - poll_type = "rng/fast_poll_request"; - - u32bit poll_for = global_config().option_as_u32bit(poll_type); - - SecureVector<byte> buffer(poll_for ? poll_for : 256); + SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); u32bit bytes_gathered = 0; diff --git a/src/modules.cpp b/src/modules.cpp index 5dad0d144..dc7dc917f 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -8,6 +8,7 @@ #include <botan/def_char.h> #include <botan/eng_def.h> #include <botan/timers.h> +#include <botan/parsing.h> #if defined(BOTAN_EXT_MUTEX_PTHREAD) #include <botan/mux_pthr.h> @@ -157,11 +158,12 @@ std::vector<EntropySource*> Builtin_Modules::entropy_sources() const #endif #if defined(BOTAN_EXT_ENTROPY_SRC_EGD) - sources.push_back(new EGD_EntropySource); + sources.push_back(new EGD_EntropySource(split_on("/var/run/egd-pool:/dev/egd-pool", ':'))); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_DEVICE) - sources.push_back(new Device_EntropySource); + sources.push_back( + new Device_EntropySource(split_on("/dev/random:/dev/srandom:/dev/urandom", ':'))); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_CAPI) @@ -173,7 +175,7 @@ std::vector<EntropySource*> Builtin_Modules::entropy_sources() const #endif #if defined(BOTAN_EXT_ENTROPY_SRC_UNIX) - sources.push_back(new Unix_EntropySource); + sources.push_back(new Unix_EntropySource(split_on("/bin:/sbin:/usr/bin:/usr/sbin", ':'))); #endif #if defined(BOTAN_EXT_ENTROPY_SRC_BEOS) diff --git a/src/policy.cpp b/src/policy.cpp index 3c8081fd8..1c4eaa7c1 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -223,13 +223,6 @@ void set_default_config(Config& config) config.set_option("pk/test/private", "basic"); config.set_option("pk/test/private_gen", "all"); - config.set_option("rng/unix_path", "/bin:/sbin:/usr/bin:/usr/sbin"); - config.set_option("rng/es_files", "/dev/random:/dev/srandom:/dev/urandom"); - config.set_option("rng/egd_path", - "/var/run/egd-pool:/dev/egd-pool"); - config.set_option("rng/slow_poll_request", "256"); - config.set_option("rng/fast_poll_request", "64"); - config.set_option("x509/validity_slack", "24h"); config.set_option("x509/v1_assume_ca", "false"); config.set_option("x509/cache_verify_results", "30m"); |