mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-18 10:05:51 +00:00
Remove unused functions & cleanup code:
* Remove superseded ECDSA key functions * Remove unused string helper functions * Remove beast::FatalError * Cleanup SSL context generation * Improve parsing of RPC commands during startup
This commit is contained in:
@@ -1551,11 +1551,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\beast\core\core.unity.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\beast\core\FatalError.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\beast\core\FatalError.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\core\HeapBlock.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\beast\core\LexicalCast.cpp">
|
||||
@@ -2099,12 +2094,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\crypto\impl\ECDSAKey.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\impl\ECDSAKey.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\crypto\impl\ec_key.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
@@ -2135,10 +2124,6 @@
|
||||
</None>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\RFC1751.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\crypto\tests\CKey.test.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\JsonPropertyStream.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
|
||||
@@ -235,9 +235,6 @@
|
||||
<Filter Include="ripple\crypto\impl">
|
||||
<UniqueIdentifier>{8EF07519-1C32-2E82-D707-702EB0157733}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ripple\crypto\tests">
|
||||
<UniqueIdentifier>{ACAAFBB2-022D-2EAB-80CD-FBE3D9432F17}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ripple\json">
|
||||
<UniqueIdentifier>{BEDCC703-A2C8-FF25-7E1E-3471BD39ED98}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -2049,12 +2046,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\beast\core\core.unity.cpp">
|
||||
<Filter>ripple\beast\core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\beast\core\FatalError.cpp">
|
||||
<Filter>ripple\beast\core</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\beast\core\FatalError.h">
|
||||
<Filter>ripple\beast\core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\core\HeapBlock.h">
|
||||
<Filter>ripple\beast\core</Filter>
|
||||
</ClInclude>
|
||||
@@ -2631,12 +2622,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\crypto\impl\csprng.cpp">
|
||||
<Filter>ripple\crypto\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\crypto\impl\ECDSAKey.cpp">
|
||||
<Filter>ripple\crypto\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\impl\ECDSAKey.h">
|
||||
<Filter>ripple\crypto\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\crypto\impl\ec_key.cpp">
|
||||
<Filter>ripple\crypto\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -2667,9 +2652,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\crypto\RFC1751.h">
|
||||
<Filter>ripple\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\crypto\tests\CKey.test.cpp">
|
||||
<Filter>ripple\crypto\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\JsonPropertyStream.cpp">
|
||||
<Filter>ripple\json\impl</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -67,6 +67,11 @@
|
||||
#include <ripple/protocol/SecretKey.h>
|
||||
#include <ripple/protocol/STParsedJSON.h>
|
||||
#include <ripple/protocol/types.h>
|
||||
#include <ripple/resource/Charge.h>
|
||||
#include <ripple/resource/Consumer.h>
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <ripple/rpc/Context.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/shamap/Family.h>
|
||||
#include <ripple/unity/git_id.h>
|
||||
#include <ripple/websocket/MakeServer.h>
|
||||
@@ -527,7 +532,7 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void setup() override;
|
||||
bool setup() override;
|
||||
void doStart() override;
|
||||
void run() override;
|
||||
bool isShutdown() override;
|
||||
@@ -861,14 +866,6 @@ public:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void exitWithCode(int code)
|
||||
{
|
||||
StopSustain();
|
||||
// VFALCO This breaks invariants: automatic objects
|
||||
// will not have destructors called.
|
||||
std::exit(code);
|
||||
}
|
||||
|
||||
void onDeadlineTimer (DeadlineTimer& timer) override
|
||||
{
|
||||
if (timer == m_entropyTimer)
|
||||
@@ -925,7 +922,7 @@ public:
|
||||
private:
|
||||
void addTxnSeqField();
|
||||
void addValidationSeqFields();
|
||||
void updateTables ();
|
||||
bool updateTables ();
|
||||
void startGenesisLedger ();
|
||||
|
||||
std::shared_ptr<Ledger>
|
||||
@@ -947,7 +944,7 @@ private:
|
||||
// Or better yet refactor these initializations into RAII classes
|
||||
// which are members of the Application object.
|
||||
//
|
||||
void ApplicationImp::setup()
|
||||
bool ApplicationImp::setup()
|
||||
{
|
||||
// VFALCO NOTE: 0 means use heuristics to determine the thread count.
|
||||
m_jobQueue->setThreadCount (0, config_->standalone());
|
||||
@@ -983,7 +980,7 @@ void ApplicationImp::setup()
|
||||
if (!initSqliteDbs ())
|
||||
{
|
||||
JLOG(m_journal.fatal()) << "Cannot create database connections!";
|
||||
exitWithCode(3);
|
||||
return false;
|
||||
}
|
||||
|
||||
getLedgerDB ().getSession ()
|
||||
@@ -997,7 +994,8 @@ void ApplicationImp::setup()
|
||||
mTxnDB->setupCheckpointing (m_jobQueue.get(), logs());
|
||||
mLedgerDB->setupCheckpointing (m_jobQueue.get(), logs());
|
||||
|
||||
updateTables ();
|
||||
if (!updateTables ())
|
||||
return false;
|
||||
|
||||
// Configure the amendments the server supports
|
||||
{
|
||||
@@ -1041,7 +1039,7 @@ void ApplicationImp::setup()
|
||||
{
|
||||
JLOG(m_journal.error()) <<
|
||||
"The specified ledger could not be loaded.";
|
||||
exitWithCode(-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (startUp == Config::NETWORK)
|
||||
@@ -1064,13 +1062,13 @@ void ApplicationImp::setup()
|
||||
if (!cluster_->load (config().section(SECTION_CLUSTER_NODES)))
|
||||
{
|
||||
JLOG(m_journal.fatal()) << "Invalid entry in cluster configuration.";
|
||||
Throw<std::exception>();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!validators_->load (config().section (SECTION_VALIDATORS)))
|
||||
{
|
||||
JLOG(m_journal.fatal()) << "Invalid entry in validator configuration.";
|
||||
Throw<std::exception>();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (validators_->size () == 0 && !config_->standalone())
|
||||
@@ -1102,7 +1100,8 @@ void ApplicationImp::setup()
|
||||
// start first consensus round
|
||||
if (! m_networkOPs->beginConsensus(m_ledgerMaster->getClosedLedger()->info().hash))
|
||||
{
|
||||
LogicError ("Unable to start consensus");
|
||||
JLOG(m_journal.fatal()) << "Unable to start consensus";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_overlay->setupValidatorKeyManifests (*config_, getWalletDB ());
|
||||
@@ -1125,7 +1124,7 @@ void ApplicationImp::setup()
|
||||
{
|
||||
JLOG(m_journal.fatal()) << "Could not create Websocket for [" <<
|
||||
port.name << "]";
|
||||
Throw<std::exception> ();
|
||||
return false;
|
||||
}
|
||||
websocketServers_.emplace_back (std::move (server));
|
||||
}
|
||||
@@ -1153,6 +1152,42 @@ void ApplicationImp::setup()
|
||||
|
||||
m_networkOPs->setStandAlone ();
|
||||
}
|
||||
|
||||
//
|
||||
// Execute start up rpc commands.
|
||||
//
|
||||
for (auto cmd : config_->section(SECTION_RPC_STARTUP).lines())
|
||||
{
|
||||
Json::Reader jrReader;
|
||||
Json::Value jvCommand;
|
||||
|
||||
if (! jrReader.parse (cmd, jvCommand))
|
||||
{
|
||||
JLOG(m_journal.fatal()) <<
|
||||
"Couldn't parse entry in [" << SECTION_RPC_STARTUP <<
|
||||
"]: '" << cmd;
|
||||
}
|
||||
|
||||
if (!config_->quiet())
|
||||
{
|
||||
JLOG(m_journal.fatal()) << "Startup RPC: " << jvCommand << std::endl;
|
||||
}
|
||||
|
||||
Resource::Charge loadType = Resource::feeReferenceRPC;
|
||||
Resource::Consumer c;
|
||||
RPC::Context context { journal ("RPCHandler"), jvCommand, *this,
|
||||
loadType, getOPs (), getLedgerMaster(), c, Role::ADMIN };
|
||||
|
||||
Json::Value jvResult;
|
||||
RPC::doCommand (context, jvResult);
|
||||
|
||||
if (!config_->quiet())
|
||||
{
|
||||
JLOG(m_journal.fatal()) << "Result: " << jvResult << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1812,12 +1847,12 @@ void ApplicationImp::addValidationSeqFields ()
|
||||
tr.commit();
|
||||
}
|
||||
|
||||
void ApplicationImp::updateTables ()
|
||||
bool ApplicationImp::updateTables ()
|
||||
{
|
||||
if (config_->section (ConfigSection::nodeDatabase ()).empty ())
|
||||
{
|
||||
JLOG (m_journal.fatal()) << "The [node_db] configuration setting has been updated and must be set";
|
||||
exitWithCode(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
// perform any needed table updates
|
||||
@@ -1828,7 +1863,7 @@ void ApplicationImp::updateTables ()
|
||||
if (schemaHas (getTxnDB (), "AccountTransactions", 0, "PRIMARY", m_journal))
|
||||
{
|
||||
JLOG (m_journal.fatal()) << "AccountTransactions database should not have a primary key";
|
||||
exitWithCode(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
addValidationSeqFields ();
|
||||
@@ -1848,6 +1883,8 @@ void ApplicationImp::updateTables ()
|
||||
|
||||
getNodeStore().import (*source);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
virtual ~Application () = default;
|
||||
|
||||
virtual void setup() = 0;
|
||||
virtual bool setup() = 0;
|
||||
virtual void doStart() = 0;
|
||||
virtual void run() = 0;
|
||||
virtual bool isShutdown () = 0;
|
||||
|
||||
@@ -110,43 +110,6 @@ adjustDescriptorLimit(int needed, beast::Journal j)
|
||||
return true;
|
||||
}
|
||||
|
||||
void startServer (Application& app)
|
||||
{
|
||||
//
|
||||
// Execute start up rpc commands.
|
||||
//
|
||||
if (app.config().RPC_STARTUP.isArray ())
|
||||
{
|
||||
for (int i = 0; i != app.config().RPC_STARTUP.size (); ++i)
|
||||
{
|
||||
Json::Value const& jvCommand = app.config().RPC_STARTUP[i];
|
||||
|
||||
if (!app.config().quiet())
|
||||
std::cerr << "Startup RPC: " << jvCommand << std::endl;
|
||||
|
||||
Resource::Charge loadType = Resource::feeReferenceRPC;
|
||||
Resource::Consumer c;
|
||||
RPC::Context context {app.journal ("RPCHandler"), jvCommand, app,
|
||||
loadType, app.getOPs (), app.getLedgerMaster(), c, Role::ADMIN};
|
||||
|
||||
Json::Value jvResult;
|
||||
RPC::doCommand (context, jvResult);
|
||||
|
||||
if (!app.config().quiet())
|
||||
std::cerr << "Result: " << jvResult << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
app.doStart();
|
||||
// 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 ());
|
||||
}
|
||||
|
||||
void printHelp (const po::options_description& desc)
|
||||
{
|
||||
std::cerr
|
||||
@@ -468,7 +431,12 @@ int run (int argc, char** argv)
|
||||
std::move(config),
|
||||
std::move(logs),
|
||||
std::move(timeKeeper));
|
||||
app->setup ();
|
||||
|
||||
if (!app->setup ())
|
||||
{
|
||||
StopSustain();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// With our configuration parsed, ensure we have
|
||||
// enough file descriptors available:
|
||||
@@ -480,7 +448,17 @@ int run (int argc, char** argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
startServer (*app);
|
||||
// Start the server
|
||||
app->doStart();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
|
||||
TaggedCache<uint256, ValidationSet> mValidations;
|
||||
ValidationSet mCurrentValidations;
|
||||
ValidationVector mStaleValidations;
|
||||
std::vector<STValidation::pointer> mStaleValidations;
|
||||
|
||||
bool mWriting;
|
||||
beast::Journal j_;
|
||||
@@ -156,12 +156,6 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
void tune (int size, int age) override
|
||||
{
|
||||
mValidations.setTargetSize (size);
|
||||
mValidations.setTargetAge (age);
|
||||
}
|
||||
|
||||
ValidationSet getValidations (uint256 const& ledger) override
|
||||
{
|
||||
{
|
||||
@@ -191,58 +185,6 @@ private:
|
||||
(val->getSeenTime() < (now + VALIDATION_VALID_LOCAL)));
|
||||
}
|
||||
|
||||
void getValidationCount (uint256 const& ledger, bool currentOnly,
|
||||
int& trusted, int& untrusted) override
|
||||
{
|
||||
trusted = untrusted = 0;
|
||||
ScopedLockType sl (mLock);
|
||||
auto set = findSet (ledger);
|
||||
|
||||
if (set)
|
||||
{
|
||||
for (auto& it: *set)
|
||||
{
|
||||
bool isTrusted = it.second->isTrusted ();
|
||||
|
||||
if (isTrusted && currentOnly && ! current (it.second))
|
||||
{
|
||||
JLOG (j_.trace()) << "VC: Untrusted due to time " << ledger;
|
||||
isTrusted = false;
|
||||
}
|
||||
|
||||
if (isTrusted)
|
||||
++trusted;
|
||||
else
|
||||
++untrusted;
|
||||
}
|
||||
}
|
||||
|
||||
JLOG (j_.trace()) << "VC: " << ledger << "t:" << trusted << " u:" << untrusted;
|
||||
}
|
||||
|
||||
void getValidationTypes (uint256 const& ledger, int& full, int& partial) override
|
||||
{
|
||||
full = partial = 0;
|
||||
ScopedLockType sl (mLock);
|
||||
auto set = findSet (ledger);
|
||||
|
||||
if (set)
|
||||
{
|
||||
for (auto& it:*set)
|
||||
{
|
||||
if (it.second->isTrusted ())
|
||||
{
|
||||
if (it.second->isFull ())
|
||||
++full;
|
||||
else
|
||||
++partial;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JLOG (j_.trace()) << "VC: " << ledger << "f:" << full << " p:" << partial;
|
||||
}
|
||||
|
||||
int getTrustedValidationCount (uint256 const& ledger) override
|
||||
{
|
||||
int trusted = 0;
|
||||
@@ -470,7 +412,7 @@ private:
|
||||
|
||||
while (!mStaleValidations.empty ())
|
||||
{
|
||||
ValidationVector vector;
|
||||
std::vector<STValidation::pointer> vector;
|
||||
vector.reserve (512);
|
||||
mStaleValidations.swap (vector);
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ using ValidationSet = hash_map<NodeID, STValidation::pointer>;
|
||||
|
||||
using ValidationCounter = std::pair<int, NodeID>;
|
||||
using LedgerToValidationCounter = hash_map<uint256, ValidationCounter>;
|
||||
using ValidationVector = std::vector<STValidation::pointer>;
|
||||
|
||||
class Validations
|
||||
{
|
||||
@@ -48,12 +47,6 @@ public:
|
||||
|
||||
virtual ValidationSet getValidations (uint256 const& ledger) = 0;
|
||||
|
||||
virtual void getValidationCount (
|
||||
uint256 const& ledger, bool currentOnly, int& trusted,
|
||||
int& untrusted) = 0;
|
||||
virtual void getValidationTypes (
|
||||
uint256 const& ledger, int& full, int& partial) = 0;
|
||||
|
||||
virtual int getTrustedValidationCount (uint256 const& ledger) = 0;
|
||||
|
||||
/** Returns fees reported by trusted validators in the given ledger. */
|
||||
@@ -76,8 +69,6 @@ public:
|
||||
virtual std::list <STValidation::pointer>
|
||||
getCurrentTrustedValidations () = 0;
|
||||
|
||||
virtual void tune (int size, int age) = 0;
|
||||
|
||||
virtual void flush () = 0;
|
||||
|
||||
virtual void sweep () = 0;
|
||||
|
||||
@@ -88,8 +88,6 @@ std::pair<Blob, bool> strUnHex (std::string const& strSrc);
|
||||
Blob strCopy (std::string const& strSrc);
|
||||
std::string strCopy (Blob const& vucSrc);
|
||||
|
||||
bool parseIpPort (std::string const& strSource, std::string& strIP, int& iPort);
|
||||
|
||||
bool parseUrl (std::string const& strUrl, std::string& strScheme,
|
||||
std::string& strDomain, int& iPort, std::string& strPath);
|
||||
|
||||
|
||||
@@ -132,38 +132,6 @@ std::string strCopy (Blob const& vucSrc)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// IP Port parsing
|
||||
//
|
||||
// <-- iPort: "" = -1
|
||||
// VFALCO TODO Make this not require boost... and especially boost::asio
|
||||
bool parseIpPort (std::string const& strSource, std::string& strIP, int& iPort)
|
||||
{
|
||||
boost::smatch smMatch;
|
||||
bool bValid = false;
|
||||
|
||||
static boost::regex reEndpoint ("\\`\\s*(\\S+)(?:\\s+(\\d+))?\\s*\\'");
|
||||
|
||||
if (boost::regex_match (strSource, smMatch, reEndpoint))
|
||||
{
|
||||
boost::system::error_code err;
|
||||
std::string strIPRaw = smMatch[1];
|
||||
std::string strPortRaw = smMatch[2];
|
||||
|
||||
boost::asio::ip::address addrIP = boost::asio::ip::address::from_string (strIPRaw, err);
|
||||
|
||||
bValid = !err;
|
||||
|
||||
if (bValid)
|
||||
{
|
||||
strIP = addrIP.to_string ();
|
||||
iPort = strPortRaw.empty () ? -1 : beast::lexicalCastThrow <int> (strPortRaw);
|
||||
}
|
||||
}
|
||||
|
||||
return bValid;
|
||||
}
|
||||
|
||||
// TODO Callers should be using beast::URL and beast::parse_URL instead.
|
||||
bool parseUrl (std::string const& strUrl, std::string& strScheme, std::string& strDomain, int& iPort, std::string& strPath)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/basics/make_SSLContext.h>
|
||||
#include <ripple/beast/container/aged_unordered_set.h>
|
||||
#include <ripple/beast/core/FatalError.h>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
@@ -82,7 +81,7 @@ static rsa_ptr rsa_generate_key (int n_bits)
|
||||
RSA* rsa = RSA_generate_key (n_bits, RSA_F4, nullptr, nullptr);
|
||||
|
||||
if (rsa == nullptr)
|
||||
Throw<std::runtime_error> ("RSA_generate_key failed");
|
||||
LogicError ("RSA_generate_key failed");
|
||||
|
||||
return rsa_ptr (rsa);
|
||||
}
|
||||
@@ -96,7 +95,7 @@ static evp_pkey_ptr evp_pkey_new()
|
||||
EVP_PKEY* evp_pkey = EVP_PKEY_new();
|
||||
|
||||
if (evp_pkey == nullptr)
|
||||
Throw<std::runtime_error> ("EVP_PKEY_new failed");
|
||||
LogicError ("EVP_PKEY_new failed");
|
||||
|
||||
return evp_pkey_ptr (evp_pkey);
|
||||
}
|
||||
@@ -104,7 +103,7 @@ static evp_pkey_ptr evp_pkey_new()
|
||||
static void evp_pkey_assign_rsa (EVP_PKEY* evp_pkey, rsa_ptr&& rsa)
|
||||
{
|
||||
if (! EVP_PKEY_assign_RSA (evp_pkey, rsa.get()))
|
||||
Throw<std::runtime_error> ("EVP_PKEY_assign_RSA failed");
|
||||
LogicError ("EVP_PKEY_assign_RSA failed");
|
||||
|
||||
rsa.release();
|
||||
}
|
||||
@@ -118,7 +117,7 @@ static x509_ptr x509_new()
|
||||
X509* x509 = X509_new();
|
||||
|
||||
if (x509 == nullptr)
|
||||
Throw<std::runtime_error> ("X509_new failed");
|
||||
LogicError ("X509_new failed");
|
||||
|
||||
X509_set_version (x509, NID_X509);
|
||||
|
||||
@@ -139,19 +138,19 @@ static void x509_set_pubkey (X509* x509, EVP_PKEY* evp_pkey)
|
||||
static void x509_sign (X509* x509, EVP_PKEY* evp_pkey)
|
||||
{
|
||||
if (! X509_sign (x509, evp_pkey, EVP_sha1()))
|
||||
Throw<std::runtime_error> ("X509_sign failed");
|
||||
LogicError ("X509_sign failed");
|
||||
}
|
||||
|
||||
static void ssl_ctx_use_certificate (SSL_CTX* const ctx, x509_ptr& cert)
|
||||
{
|
||||
if (SSL_CTX_use_certificate (ctx, cert.release()) <= 0)
|
||||
Throw<std::runtime_error> ("SSL_CTX_use_certificate failed");
|
||||
LogicError ("SSL_CTX_use_certificate failed");
|
||||
}
|
||||
|
||||
static void ssl_ctx_use_privatekey (SSL_CTX* const ctx, evp_pkey_ptr& key)
|
||||
{
|
||||
if (SSL_CTX_use_PrivateKey (ctx, key.release()) <= 0)
|
||||
Throw<std::runtime_error> ("SSL_CTX_use_PrivateKey failed");
|
||||
LogicError ("SSL_CTX_use_PrivateKey failed");
|
||||
}
|
||||
|
||||
// track when SSL connections have last negotiated
|
||||
@@ -174,9 +173,8 @@ make_DH(std::string const& params)
|
||||
auto const* p (
|
||||
reinterpret_cast <std::uint8_t const*>(¶ms [0]));
|
||||
DH* const dh = d2i_DHparams (nullptr, &p, params.size ());
|
||||
if (p == nullptr)
|
||||
beast::FatalError ("d2i_DHparams returned nullptr.",
|
||||
__FILE__, __LINE__);
|
||||
if (dh == nullptr)
|
||||
LogicError ("d2i_DHparams returned nullptr.");
|
||||
return dh_ptr(dh);
|
||||
}
|
||||
|
||||
@@ -289,7 +287,7 @@ getDH (int keyLength)
|
||||
}
|
||||
else
|
||||
{
|
||||
beast::FatalError ("unsupported key length", __FILE__, __LINE__);
|
||||
LogicError ("unsupported key length.");
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -364,36 +362,16 @@ error_message (std::string const& what,
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
initCommon (boost::asio::ssl::context& context)
|
||||
{
|
||||
context.set_options (
|
||||
boost::asio::ssl::context::default_workarounds |
|
||||
boost::asio::ssl::context::no_sslv2 |
|
||||
boost::asio::ssl::context::no_sslv3 |
|
||||
boost::asio::ssl::context::single_dh_use);
|
||||
|
||||
SSL_CTX_set_tmp_dh_callback (
|
||||
context.native_handle (),
|
||||
tmp_dh_handler);
|
||||
|
||||
SSL_CTX_set_info_callback (
|
||||
context.native_handle (),
|
||||
info_handler);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
initAnonymous (
|
||||
boost::asio::ssl::context& context, std::string const& cipherList)
|
||||
{
|
||||
initCommon(context);
|
||||
int const result = SSL_CTX_set_cipher_list (
|
||||
context.native_handle (),
|
||||
cipherList.c_str ());
|
||||
if (result != 1)
|
||||
Throw<std::invalid_argument> ("SSL_CTX_set_cipher_list failed");
|
||||
LogicError ("SSL_CTX_set_cipher_list failed");
|
||||
|
||||
using namespace openssl;
|
||||
|
||||
@@ -414,8 +392,6 @@ void
|
||||
initAuthenticated (boost::asio::ssl::context& context,
|
||||
std::string key_file, std::string cert_file, std::string chain_file)
|
||||
{
|
||||
initCommon (context);
|
||||
|
||||
SSL_CTX* const ssl = context.native_handle ();
|
||||
|
||||
bool cert_set = false;
|
||||
@@ -429,9 +405,8 @@ initAuthenticated (boost::asio::ssl::context& context,
|
||||
|
||||
if (ec)
|
||||
{
|
||||
beast::FatalError (error_message (
|
||||
"Problem with SSL certificate file.", ec).c_str(),
|
||||
__FILE__, __LINE__);
|
||||
LogicError (error_message (
|
||||
"Problem with SSL certificate file.", ec).c_str());
|
||||
}
|
||||
|
||||
cert_set = true;
|
||||
@@ -444,10 +419,9 @@ initAuthenticated (boost::asio::ssl::context& context,
|
||||
|
||||
if (!f)
|
||||
{
|
||||
beast::FatalError (error_message (
|
||||
LogicError (error_message (
|
||||
"Problem opening SSL chain file.", boost::system::error_code (errno,
|
||||
boost::system::generic_category())).c_str(),
|
||||
__FILE__, __LINE__);
|
||||
boost::system::generic_category())).c_str());
|
||||
}
|
||||
|
||||
try
|
||||
@@ -462,16 +436,14 @@ initAuthenticated (boost::asio::ssl::context& context,
|
||||
if (! cert_set)
|
||||
{
|
||||
if (SSL_CTX_use_certificate (ssl, x) != 1)
|
||||
beast::FatalError ("Problem retrieving SSL certificate from chain file.",
|
||||
__FILE__, __LINE__);
|
||||
LogicError ("Problem retrieving SSL certificate from chain file.");
|
||||
|
||||
cert_set = true;
|
||||
}
|
||||
else if (SSL_CTX_add_extra_chain_cert (ssl, x) != 1)
|
||||
{
|
||||
X509_free (x);
|
||||
beast::FatalError ("Problem adding SSL chain certificate.",
|
||||
__FILE__, __LINE__);
|
||||
LogicError ("Problem adding SSL chain certificate.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,8 +452,7 @@ initAuthenticated (boost::asio::ssl::context& context,
|
||||
catch (std::exception const&)
|
||||
{
|
||||
fclose (f);
|
||||
beast::FatalError ("Reading the SSL chain file generated an exception.",
|
||||
__FILE__, __LINE__);
|
||||
LogicError ("Reading the SSL chain file generated an exception.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,19 +465,37 @@ initAuthenticated (boost::asio::ssl::context& context,
|
||||
|
||||
if (ec)
|
||||
{
|
||||
beast::FatalError (error_message (
|
||||
"Problem using the SSL private key file.", ec).c_str(),
|
||||
__FILE__, __LINE__);
|
||||
LogicError (error_message (
|
||||
"Problem using the SSL private key file.", ec).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (SSL_CTX_check_private_key (ssl) != 1)
|
||||
{
|
||||
beast::FatalError ("Invalid key in SSL private key file.",
|
||||
__FILE__, __LINE__);
|
||||
LogicError ("Invalid key in SSL private key file.");
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<boost::asio::ssl::context>
|
||||
get_context ()
|
||||
{
|
||||
auto c = std::make_shared<boost::asio::ssl::context> (
|
||||
boost::asio::ssl::context::sslv23);
|
||||
|
||||
c->set_options (
|
||||
boost::asio::ssl::context::default_workarounds |
|
||||
boost::asio::ssl::context::no_sslv2 |
|
||||
boost::asio::ssl::context::no_sslv3 |
|
||||
boost::asio::ssl::context::single_dh_use);
|
||||
|
||||
SSL_CTX_set_tmp_dh_callback (
|
||||
c->native_handle (), tmp_dh_handler);
|
||||
SSL_CTX_set_info_callback (
|
||||
c->native_handle (), info_handler);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // openssl
|
||||
|
||||
@@ -517,9 +506,7 @@ make_SSLContext()
|
||||
static auto const context =
|
||||
[]()
|
||||
{
|
||||
auto const context = std::make_shared<
|
||||
boost::asio::ssl::context>(
|
||||
boost::asio::ssl::context::sslv23);
|
||||
auto const context = openssl::detail::get_context();
|
||||
// By default, allow anonymous DH.
|
||||
openssl::detail::initAnonymous(
|
||||
*context, "ALL:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
@@ -535,9 +522,7 @@ std::shared_ptr<boost::asio::ssl::context>
|
||||
make_SSLContextAuthed (std::string const& key_file,
|
||||
std::string const& cert_file, std::string const& chain_file)
|
||||
{
|
||||
std::shared_ptr<boost::asio::ssl::context> context =
|
||||
std::make_shared<boost::asio::ssl::context> (
|
||||
boost::asio::ssl::context::sslv23);
|
||||
auto const context = openssl::detail::get_context();
|
||||
openssl::detail::initAuthenticated(*context,
|
||||
key_file, cert_file, chain_file);
|
||||
return context;
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/core/FatalError.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
|
||||
namespace beast {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
[[noreturn]]
|
||||
void
|
||||
FatalError (
|
||||
char const* message,
|
||||
char const* file,
|
||||
int line) noexcept
|
||||
{
|
||||
static std::mutex gate;
|
||||
|
||||
// We only allow one thread to report a fatal error. Other threads that
|
||||
// encounter fatal errors while we are reporting get blocked here.
|
||||
std::lock_guard<std::mutex> lock(gate);
|
||||
|
||||
std::cerr << "An error has occurred. The application will terminate.\n";
|
||||
|
||||
if (message != nullptr && message [0] != 0)
|
||||
std::cerr << "Message: " << message << '\n';
|
||||
|
||||
if (file != nullptr && file [0] != 0)
|
||||
std::cerr << " File: " << file << ":" << line << '\n';
|
||||
|
||||
auto const backtrace = getStackBacktrace ();
|
||||
|
||||
if (!backtrace.empty ())
|
||||
{
|
||||
std::cerr << " Stack:" << std::endl;
|
||||
|
||||
for (auto const& frame : backtrace)
|
||||
std::cerr << " " << frame << '\n';
|
||||
}
|
||||
|
||||
std::abort ();
|
||||
}
|
||||
|
||||
} // beast
|
||||
@@ -1,45 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_MODULE_CORE_DIAGNOSTIC_FATALERROR_H_INCLUDED
|
||||
#define BEAST_MODULE_CORE_DIAGNOSTIC_FATALERROR_H_INCLUDED
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
/** Signal a fatal error.
|
||||
|
||||
A fatal error indicates that the program has encountered an unexpected
|
||||
situation and cannot continue safely. Reasons for raising a fatal error
|
||||
would be to protect data integrity, prevent valuable resources from being
|
||||
wasted, or to ensure that the user does not experience undefined behavior.
|
||||
|
||||
If multiple threads raise an error, only one will succeed while the others
|
||||
will be blocked before the process terminates.
|
||||
*/
|
||||
[[noreturn]]
|
||||
void
|
||||
FatalError (
|
||||
char const* message,
|
||||
char const* file = nullptr,
|
||||
int line = 0) noexcept;
|
||||
|
||||
} // beast
|
||||
|
||||
#endif
|
||||
@@ -51,7 +51,6 @@
|
||||
// Order matters, since headers don't have their own #include lines.
|
||||
// Add new includes to the bottom.
|
||||
|
||||
#include <ripple/beast/core/FatalError.h>
|
||||
#include <ripple/beast/core/LexicalCast.h>
|
||||
|
||||
#include <ripple/beast/core/SystemStats.h>
|
||||
@@ -193,7 +192,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include <ripple/beast/core/FatalError.cpp>
|
||||
#include <ripple/beast/core/SemanticVersion.cpp>
|
||||
#include <ripple/beast/core/SystemStats.cpp>
|
||||
#include <ripple/beast/core/RelativeTime.cpp>
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <ripple/protocol/SystemParameters.h> // VFALCO Breaks levelization
|
||||
#include <ripple/protocol/PublicKey.h> // NIKB Breaks levelization (TEMP)
|
||||
#include <ripple/protocol/SecretKey.h> // NIKB Breaks levelization (TEMP)
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <ripple/beast/net/IPEndpoint.h>
|
||||
#include <beast/core/detail/ci_char_traits.hpp>
|
||||
#include <ripple/beast/utility/Journal.h>
|
||||
@@ -148,9 +147,6 @@ public:
|
||||
|
||||
std::chrono::seconds WEBSOCKET_PING_FREQ = 5min;
|
||||
|
||||
// RPC parameters
|
||||
Json::Value RPC_STARTUP;
|
||||
|
||||
// Path searching
|
||||
int PATH_SEARCH_OLD = 7;
|
||||
int PATH_SEARCH = 7;
|
||||
|
||||
@@ -302,25 +302,6 @@ void Config::loadFromString (std::string const& fileContents)
|
||||
if (auto s = getIniFileSection (secConfig, SECTION_SNTP))
|
||||
SNTP_SERVERS = *s;
|
||||
|
||||
if (auto s = getIniFileSection (secConfig, SECTION_RPC_STARTUP))
|
||||
{
|
||||
RPC_STARTUP = Json::arrayValue;
|
||||
|
||||
for (auto const& strJson : *s)
|
||||
{
|
||||
Json::Reader jrReader;
|
||||
Json::Value jvCommand;
|
||||
|
||||
if (! jrReader.parse (strJson, jvCommand))
|
||||
Throw<std::runtime_error> (
|
||||
boost::str (boost::format (
|
||||
"Couldn't parse [" SECTION_RPC_STARTUP "] command: %s")
|
||||
% strJson));
|
||||
|
||||
RPC_STARTUP.append (jvCommand);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::string dbPath;
|
||||
if (getSingleSection (secConfig, "database_path", dbPath, j_))
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2011 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/crypto/impl/ECDSAKey.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
using openssl::ec_key;
|
||||
|
||||
static EC_KEY* new_initialized_EC_KEY()
|
||||
{
|
||||
EC_KEY* key = EC_KEY_new_by_curve_name (NID_secp256k1);
|
||||
|
||||
if (key == nullptr)
|
||||
Throw<std::runtime_error> (
|
||||
"new_initialized_EC_KEY() : EC_KEY_new_by_curve_name failed");
|
||||
|
||||
EC_KEY_set_conv_form (key, POINT_CONVERSION_COMPRESSED);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
ec_key ECDSAPrivateKey (uint256 const& serialized)
|
||||
{
|
||||
BIGNUM* bn = BN_bin2bn (serialized.begin(), serialized.size(), nullptr);
|
||||
|
||||
if (bn == nullptr)
|
||||
Throw<std::runtime_error> ("ec_key::ec_key: BN_bin2bn failed");
|
||||
|
||||
EC_KEY* key = new_initialized_EC_KEY();
|
||||
ec_key::pointer_t ptr = nullptr;
|
||||
|
||||
const bool ok = EC_KEY_set_private_key (key, bn);
|
||||
|
||||
BN_clear_free (bn);
|
||||
|
||||
if (ok)
|
||||
ptr = (ec_key::pointer_t) key;
|
||||
else
|
||||
EC_KEY_free (key);
|
||||
|
||||
return ec_key(ptr);
|
||||
}
|
||||
|
||||
ec_key ECDSAPublicKey (std::uint8_t const* data, std::size_t size)
|
||||
{
|
||||
EC_KEY* key = new_initialized_EC_KEY();
|
||||
ec_key::pointer_t ptr = nullptr;
|
||||
|
||||
if (o2i_ECPublicKey (&key, &data, size) != nullptr)
|
||||
{
|
||||
EC_KEY_set_conv_form (key, POINT_CONVERSION_COMPRESSED);
|
||||
ptr = (ec_key::pointer_t) key;
|
||||
}
|
||||
else
|
||||
EC_KEY_free (key);
|
||||
|
||||
return ec_key(ptr);
|
||||
}
|
||||
|
||||
ec_key ECDSAPublicKey (Blob const& serialized)
|
||||
{
|
||||
return ECDSAPublicKey (&serialized[0], serialized.size());
|
||||
}
|
||||
|
||||
} // ripple
|
||||
@@ -1,36 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2014 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_ECDSAKEY_H
|
||||
#define RIPPLE_ECDSAKEY_H
|
||||
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/Blob.h>
|
||||
#include <ripple/crypto/impl/ec_key.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
openssl::ec_key ECDSAPrivateKey (uint256 const& serialized);
|
||||
openssl::ec_key ECDSAPublicKey (Blob const& serialized);
|
||||
|
||||
openssl::ec_key ECDSAPublicKey (std::uint8_t const* data, std::size_t size);
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -18,11 +18,11 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/crypto/GenerateDeterministicKey.h>
|
||||
#include <ripple/crypto/impl/ec_key.h>
|
||||
#include <ripple/crypto/impl/openssl.h>
|
||||
#include <ripple/protocol/digest.h>
|
||||
#include <ripple/beast/core/FatalError.h>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <openssl/pem.h>
|
||||
@@ -42,7 +42,7 @@ struct secp256k1_data
|
||||
group = EC_GROUP_new_by_curve_name (NID_secp256k1);
|
||||
|
||||
if (!group)
|
||||
beast::FatalError ("The OpenSSL library on this system lacks elliptic curve support.");
|
||||
LogicError ("The OpenSSL library on this system lacks elliptic curve support.");
|
||||
|
||||
bn_ctx ctx;
|
||||
order = get_order (group, ctx);
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/crypto/GenerateDeterministicKey.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2011 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
class CKey_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
run ()
|
||||
{
|
||||
uint128 seed1, seed2;
|
||||
seed1.SetHex ("71ED064155FFADFA38782C5E0158CB26");
|
||||
seed2.SetHex ("CF0C3BE4485961858C4198515AE5B965");
|
||||
|
||||
uint256 const priv1 = generateRootDeterministicPrivateKey (seed1);
|
||||
uint256 const priv2 = generateRootDeterministicPrivateKey (seed2);
|
||||
|
||||
unexpected (to_string (priv1) != "7CFBA64F771E93E817E15039215430B53F74"
|
||||
"01C34931D111EAB3510B22DBB0D8",
|
||||
"Incorrect private key for generator");
|
||||
|
||||
unexpected (to_string (priv2) != "98BC2EACB26EB021D1A6293C044D88BA2F0B"
|
||||
"6729A2772DEEBF2E21A263C1740B",
|
||||
"Incorrect private key for generator");
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(CKey,ripple_data,ripple);
|
||||
|
||||
} // ripple
|
||||
@@ -18,10 +18,10 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/protocol/BuildInfo.h>
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/core/FatalError.h>
|
||||
#include <ripple/beast/core/SemanticVersion.h>
|
||||
#include <ripple/protocol/BuildInfo.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -107,40 +107,20 @@ getMinimumProtocol ()
|
||||
std::string const&
|
||||
getVersionString ()
|
||||
{
|
||||
struct SanityChecker
|
||||
{
|
||||
SanityChecker ()
|
||||
{
|
||||
beast::SemanticVersion v;
|
||||
|
||||
char const* const rawText = getRawVersionString ();
|
||||
|
||||
if (! v.parse (rawText) || v.print () != rawText)
|
||||
beast::FatalError ("Bad server version string", __FILE__, __LINE__);
|
||||
|
||||
versionString = rawText;
|
||||
}
|
||||
|
||||
std::string versionString;
|
||||
};
|
||||
|
||||
static SanityChecker const value;
|
||||
|
||||
return value.versionString;
|
||||
static std::string const value = [] {
|
||||
std::string const versionString = getRawVersionString ();
|
||||
beast::SemanticVersion v;
|
||||
if (!v.parse (versionString) || v.print () != versionString)
|
||||
LogicError (versionString + ": Bad server version string");
|
||||
return versionString;
|
||||
}();
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string const& getFullVersionString ()
|
||||
{
|
||||
struct PrettyPrinter
|
||||
{
|
||||
PrettyPrinter () : fullVersionString ("rippled-" + getVersionString ()){}
|
||||
|
||||
std::string fullVersionString;
|
||||
};
|
||||
|
||||
static PrettyPrinter const value;
|
||||
|
||||
return value.fullVersionString;
|
||||
static std::string const value = "rippled-" + getVersionString ();
|
||||
return value;
|
||||
}
|
||||
|
||||
ProtocolVersion
|
||||
|
||||
@@ -20,15 +20,12 @@
|
||||
#include <BeastConfig.h>
|
||||
|
||||
#include <ripple/crypto/impl/ec_key.cpp>
|
||||
#include <ripple/crypto/impl/ECDSAKey.cpp>
|
||||
#include <ripple/crypto/impl/GenerateDeterministicKey.cpp>
|
||||
#include <ripple/crypto/impl/KeyType.cpp>
|
||||
#include <ripple/crypto/impl/openssl.cpp>
|
||||
#include <ripple/crypto/impl/csprng.cpp>
|
||||
#include <ripple/crypto/impl/RFC1751.cpp>
|
||||
|
||||
#include <ripple/crypto/tests/CKey.test.cpp>
|
||||
|
||||
#if DOXYGEN
|
||||
#include <ripple/crypto/README.md>
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user