mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Get rid of DH_der_gen_hex and DH_der_load_hex.
This commit is contained in:
@@ -53,13 +53,8 @@ bool Wallet::nodeIdentityLoad()
|
||||
mNodePublicKey.setNodePublic(strPublicKey);
|
||||
mNodePrivateKey.setNodePrivate(strPrivateKey);
|
||||
|
||||
std::string strDh512, strDh1024;
|
||||
|
||||
db->getStr("Dh512", strDh512);
|
||||
db->getStr("Dh1024", strDh1024);
|
||||
|
||||
mDh512 = DH_der_load_hex(strDh512);
|
||||
mDh1024 = DH_der_load_hex(strDh1024);
|
||||
mDh512 = DH_der_load(db->getStrBinary("Dh512"));
|
||||
mDh1024 = DH_der_load(db->getStrBinary("Dh1024"));
|
||||
|
||||
db->endIterRows();
|
||||
bSuccess = true;
|
||||
@@ -81,13 +76,11 @@ bool Wallet::nodeIdentityCreate() {
|
||||
|
||||
// Make new key.
|
||||
|
||||
std::string strDh512, strDh1024;
|
||||
|
||||
DH_der_gen_hex(strDh512, 512); // Using hex as db->escape in insufficient.
|
||||
std::string strDh512 = DH_der_gen(512);
|
||||
#if 1
|
||||
strDh1024 = strDh512; // For testing and most cases 512 is fine.
|
||||
std::string strDh1024 = strDh512; // For testing and most cases 512 is fine.
|
||||
#else
|
||||
DH_der_gen_hex(strDh1024, 1024);
|
||||
std::string strDh1024 = DH_der_gen(1024);
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -96,11 +89,11 @@ bool Wallet::nodeIdentityCreate() {
|
||||
Database* db = theApp->getWalletDB()->getDB();
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
db->executeSQL(str(boost::format("INSERT INTO NodeIdentity (PublicKey,PrivateKey,Dh512,Dh1024) VALUES (%s,%s,%s,%s);")
|
||||
% db->escape(naNodePublic.humanNodePublic())
|
||||
% db->escape(naNodePrivate.humanNodePrivate())
|
||||
% db->escape(strDh512)
|
||||
% db->escape(strDh1024)));
|
||||
db->executeSQL(str(boost::format("INSERT INTO NodeIdentity (PublicKey,PrivateKey,Dh512,Dh1024) VALUES ('%s','%s',%s,%s);")
|
||||
% naNodePublic.humanNodePublic()
|
||||
% naNodePrivate.humanNodePrivate()
|
||||
% sqlEscape(strDh512)
|
||||
% sqlEscape(strDh1024)));
|
||||
// XXX Check error result.
|
||||
|
||||
std::cerr << "NodeIdentity: Created." << std::endl;
|
||||
|
||||
@@ -95,10 +95,11 @@ std::string strCopy(const std::vector<unsigned char>& vucSrc)
|
||||
// DH support
|
||||
//
|
||||
|
||||
void DH_der_gen(std::string& strDer, int iKeyLength)
|
||||
std::string DH_der_gen(int iKeyLength)
|
||||
{
|
||||
DH* dh = 0;
|
||||
int iCodes;
|
||||
DH* dh = 0;
|
||||
int iCodes;
|
||||
std::string strDer;
|
||||
|
||||
do {
|
||||
dh = DH_generate_parameters(iKeyLength, DH_GENERATOR_5, NULL, NULL);
|
||||
@@ -111,15 +112,8 @@ void DH_der_gen(std::string& strDer, int iKeyLength)
|
||||
unsigned char* next = reinterpret_cast<unsigned char *>(&strDer[0]);
|
||||
|
||||
(void) i2d_DHparams(dh, &next);
|
||||
}
|
||||
|
||||
void DH_der_gen_hex(std::string& strDer, int iKeyLength)
|
||||
{
|
||||
std::string strBuf;
|
||||
|
||||
DH_der_gen(strBuf, iKeyLength);
|
||||
|
||||
strDer = strHex(strBuf);
|
||||
return strDer;
|
||||
}
|
||||
|
||||
DH* DH_der_load(const std::string& strDer)
|
||||
@@ -129,15 +123,6 @@ DH* DH_der_load(const std::string& strDer)
|
||||
return d2i_DHparams(NULL, &pbuf, strDer.size());
|
||||
}
|
||||
|
||||
DH* DH_der_load_hex(const std::string& strDer)
|
||||
{
|
||||
std::string strBuf;
|
||||
|
||||
strUnHex(strBuf, strDer);
|
||||
|
||||
return DH_der_load(strBuf);
|
||||
}
|
||||
|
||||
/*
|
||||
void intIPtoStr(int ip,std::string& retStr)
|
||||
{
|
||||
|
||||
@@ -105,9 +105,7 @@ std::vector<unsigned char> strCopy(const std::string& strSrc);
|
||||
std::string strCopy(const std::vector<unsigned char>& vucSrc);
|
||||
|
||||
DH* DH_der_load(const std::string& strDer);
|
||||
DH* DH_der_load_hex(const std::string& strDer);
|
||||
void DH_der_gen(std::string& strDer, int iKeyLength);
|
||||
void DH_der_gen_hex(std::string& strDer, int iKeyLength);
|
||||
std::string DH_der_gen(int iKeyLength);
|
||||
|
||||
inline std::string strGetEnv(const std::string& strKey)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user