mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 01:15:53 +00:00
Remove RAND_bytes calls.
This commit is contained in:
@@ -45,8 +45,8 @@ Application::Application() :
|
||||
mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL), mWSPublicDoor(NULL), mWSPrivateDoor(NULL),
|
||||
mSweepTimer(mAuxService)
|
||||
{
|
||||
RAND_bytes(mNonce256.begin(), mNonce256.size());
|
||||
RAND_bytes(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST));
|
||||
getRand(mNonce256.begin(), mNonce256.size());
|
||||
getRand(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST));
|
||||
mJobQueue.setThreadCount();
|
||||
mSweepTimer.expires_from_now(boost::posix_time::seconds(60));
|
||||
mSweepTimer.async_wait(boost::bind(&Application::sweep, this));
|
||||
|
||||
@@ -116,8 +116,7 @@ std::vector<unsigned char> CKey::encryptECIES(CKey& otherKey, const std::vector<
|
||||
{
|
||||
|
||||
ECIES_ENC_IV_TYPE iv;
|
||||
if (RAND_bytes(static_cast<unsigned char *>(iv.begin()), ECIES_ENC_BLK_SIZE) != 1)
|
||||
throw std::runtime_error("insufficient entropy");
|
||||
getRand(static_cast<unsigned char *>(iv.begin()), ECIES_ENC_BLK_SIZE);
|
||||
|
||||
ECIES_ENC_KEY_TYPE secret;
|
||||
ECIES_HMAC_KEY_TYPE hmacKey;
|
||||
@@ -280,8 +279,7 @@ bool checkECIES(void)
|
||||
std::vector<unsigned char> message(4096);
|
||||
int msglen = i%3000;
|
||||
|
||||
if (RAND_bytes(static_cast<unsigned char *>(&message.front()), msglen) != 1)
|
||||
throw std::runtime_error("insufficient entropy");
|
||||
getRand(static_cast<unsigned char *>(&message.front()), msglen);
|
||||
message.resize(msglen);
|
||||
|
||||
// encrypt message with sender's private key and recipient's public key
|
||||
|
||||
@@ -1311,19 +1311,8 @@ bool NetworkOPs::subServer(InfoSub* ispListener, Json::Value& jvResult)
|
||||
|
||||
jvResult["stand_alone"] = theConfig.RUN_STANDALONE;
|
||||
|
||||
switch (RAND_bytes(uRandom.begin(), uRandom.size()))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
getRand(uRandom.begin(), uRandom.size());
|
||||
jvResult["random"] = uRandom.ToString();
|
||||
break;
|
||||
|
||||
case -1:
|
||||
default:
|
||||
// XXX Should probably stop running.
|
||||
cLog(lsFATAL) << "Internal error: unable to generate secure random.";
|
||||
break;
|
||||
}
|
||||
|
||||
return mSubServer.insert(ispListener).second;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ uint256 ProofOfWork::solve(int maxIterations) const
|
||||
throw std::runtime_error("invalid proof of work target/iteration");
|
||||
|
||||
uint256 nonce;
|
||||
RAND_bytes(nonce.begin(), nonce.size());
|
||||
getRand(nonce.begin(), nonce.size());
|
||||
|
||||
std::vector<uint256> buf2;
|
||||
buf2.resize(mIterations);
|
||||
@@ -112,7 +112,7 @@ bool ProofOfWork::checkSolution(const uint256& solution) const
|
||||
ProofOfWorkGenerator::ProofOfWorkGenerator() : mValidTime(180)
|
||||
{
|
||||
setDifficulty(1);
|
||||
RAND_bytes(mSecret.begin(), mSecret.size());
|
||||
getRand(mSecret.begin(), mSecret.size());
|
||||
}
|
||||
|
||||
ProofOfWork ProofOfWorkGenerator::getProof()
|
||||
@@ -123,7 +123,7 @@ ProofOfWork ProofOfWorkGenerator::getProof()
|
||||
int now = static_cast<int>(time(NULL) / 4);
|
||||
|
||||
uint256 challenge;
|
||||
RAND_bytes(challenge.begin(), challenge.size());
|
||||
getRand(challenge.begin(), challenge.size());
|
||||
|
||||
boost::mutex::scoped_lock sl(mLock);
|
||||
|
||||
|
||||
@@ -664,23 +664,15 @@ Json::Value RPCHandler::doRandom(Json::Value jvRequest)
|
||||
{
|
||||
uint256 uRandom;
|
||||
|
||||
switch (RAND_bytes(uRandom.begin(), uRandom.size()))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
try
|
||||
{
|
||||
getRand(uRandom.begin(), uRandom.size());
|
||||
Json::Value jvResult;
|
||||
|
||||
jvResult["random"] = uRandom.ToString();
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
break;
|
||||
|
||||
case -1:
|
||||
return rpcError(rpcNOT_SUPPORTED);
|
||||
|
||||
default:
|
||||
catch (...)
|
||||
{
|
||||
return rpcError(rpcINTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ void RippleAddress::setSeedRandom()
|
||||
// XXX Maybe we should call MakeNewKey
|
||||
uint128 key;
|
||||
|
||||
RAND_bytes(key.begin(), key.size());
|
||||
getRand(key.begin(), key.size());
|
||||
|
||||
RippleAddress::setSeed(key);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void SNTPClient::resolveComplete(const boost::system::error_code& error, boost::
|
||||
}
|
||||
query.mReceivedReply = false;
|
||||
query.mLocalTimeSent = now;
|
||||
RAND_bytes(reinterpret_cast<unsigned char *>(&query.mQueryNonce), sizeof(query.mQueryNonce));
|
||||
getRand(reinterpret_cast<unsigned char *>(&query.mQueryNonce), sizeof(query.mQueryNonce));
|
||||
reinterpret_cast<uint32*>(SNTPQueryData)[NTP_OFF_XMITTS_INT] = time(NULL) + NTP_UNIX_OFFSET;
|
||||
reinterpret_cast<uint32*>(SNTPQueryData)[NTP_OFF_XMITTS_FRAC] = query.mQueryNonce;
|
||||
mSocket.async_send_to(boost::asio::buffer(SNTPQueryData, 48), *sel,
|
||||
|
||||
Reference in New Issue
Block a user