diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index a8a70d105..90300dc1d 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -68,15 +67,6 @@ namespace po = boost::program_options; namespace ripple { -boost::filesystem::path -getEntropyFile(Config const& config) -{ - auto const path = config.legacy("database_path"); - if (path.empty ()) - return {}; - return boost::filesystem::path (path) / "random.seed"; -} - bool adjustDescriptorLimit(int needed, beast::Journal j) { @@ -489,13 +479,6 @@ int run (int argc, char** argv) config->setup (configFile, bool (vm.count ("quiet")), bool(vm.count("silent")), bool(vm.count("standalone"))); - { - // Stir any previously saved entropy into the pool: - auto entropy = getEntropyFile (*config); - if (!entropy.empty ()) - crypto_prng().load_state(entropy.string ()); - } - if (vm.count("vacuum")) { DatabaseCon::Setup dbSetup = setup_DatabaseCon(*config); @@ -738,11 +721,6 @@ int run (int argc, char** argv) // Block until we get a stop RPC. app->run(); - // Try to write out some entropy to use the next time we start. - auto entropy = getEntropyFile (app->config()); - if (!entropy.empty ()) - crypto_prng().save_state(entropy.string ()); - return 0; } diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index bf79cf801..6f32c88d2 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -81,9 +81,6 @@ public: /** Returns the full path and filename of the debug log file. */ boost::filesystem::path getDebugLogFile () const; - /** Returns the full path and filename of the entropy seed file. */ - boost::filesystem::path getEntropyFile () const; - private: boost::filesystem::path CONFIG_FILE; public: diff --git a/src/ripple/crypto/csprng.h b/src/ripple/crypto/csprng.h index 736f00127..a06b8a2e7 100644 --- a/src/ripple/crypto/csprng.h +++ b/src/ripple/crypto/csprng.h @@ -61,14 +61,6 @@ public: void mix_entropy (void* buffer = nullptr, std::size_t count = 0); - /** Load entropy from the specified file */ - void - load_state (std::string const& file); - - /** Save entropy to the specified file */ - void - save_state (std::string const& file); - /** Generate a random integer */ result_type operator()(); diff --git a/src/ripple/crypto/impl/csprng.cpp b/src/ripple/crypto/impl/csprng.cpp index 1e3ce92a5..e284bd415 100644 --- a/src/ripple/crypto/impl/csprng.cpp +++ b/src/ripple/crypto/impl/csprng.cpp @@ -50,27 +50,6 @@ csprng_engine::~csprng_engine () RAND_cleanup (); } -void -csprng_engine::load_state (std::string const& file) -{ - if (!file.empty()) - { - std::lock_guard lock (mutex_); - RAND_load_file (file.c_str (), kilobytes(1)); - RAND_write_file (file.c_str ()); - } -} - -void -csprng_engine::save_state (std::string const& file) -{ - if (!file.empty()) - { - std::lock_guard lock (mutex_); - RAND_write_file (file.c_str ()); - } -} - void csprng_engine::mix_entropy (void* buffer, std::size_t count) { diff --git a/src/test/core/CryptoPRNG_test.cpp b/src/test/core/CryptoPRNG_test.cpp index c57796b4a..3dfc985a6 100644 --- a/src/test/core/CryptoPRNG_test.cpp +++ b/src/test/core/CryptoPRNG_test.cpp @@ -49,74 +49,10 @@ class CryptoPRNG_test : public beast::unit_test::suite } } - void - testSaveLoad() - { - testcase ("Save/Load State"); - try - { - // create a temporary path to write crypto state files - beast::temp_dir td; - - auto stateFile = boost::filesystem::path {td.file("cryptostate")}; - auto& engine = crypto_prng(); - engine.save_state(stateFile.string()); - - size_t size_before_load; - std::string data_before_load, data_after_load; - - { - boost::system::error_code ec; - size_before_load = file_size(stateFile, ec); - if(! BEAST_EXPECTS(!ec, ec.message())) - return; - if(! BEAST_EXPECT(size_before_load > 0)) - return; - - std::ifstream ifs( - stateFile.string(), - std::ios::in | std::ios::binary); - data_before_load = - std::string{std::istreambuf_iterator{ifs}, {}}; - BEAST_EXPECT(data_before_load.size() == size_before_load); - } - - engine.load_state(stateFile.string()); - - // load_state actually causes a new state file to be written - // ...verify it has changed - - { - boost::system::error_code ec; - size_t size_after_load = file_size(stateFile, ec); - if(! BEAST_EXPECTS(!ec, ec.message())) - return; - BEAST_EXPECT(size_after_load == size_before_load); - - std::ifstream ifs( - stateFile.string(), - std::ios::in | std::ios::binary); - data_after_load = - std::string{std::istreambuf_iterator{ifs}, {}}; - BEAST_EXPECT(data_after_load.size() == size_after_load); - BEAST_EXPECT(data_after_load != data_before_load); - } - - // verify the loaded engine works - engine(); - pass(); - } - catch(std::exception&) - { - fail(); - } - } - public: void run () override { testGetValues(); - testSaveLoad(); } };