Merge pull request #2067 from heinrich5991/pr_token_use_secure_rand

Use the secure RNG for network tokens
This commit is contained in:
oy 2019-03-18 16:41:45 +01:00 committed by GitHub
commit e59c927ec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -2534,6 +2534,12 @@ int main(int argc, const char **argv) // ignore_convention
}
}
if(secure_random_init() != 0)
{
dbg_msg("secure", "could not initialize secure RNG");
return -1;
}
CClient *pClient = CreateClient();
IKernel *pKernel = IKernel::Create();
pKernel->RegisterInterface(pClient);

View file

@ -1778,11 +1778,10 @@ int main(int argc, const char **argv) // ignore_convention
}
}
bool SkipPWGen = false;
if(secure_random_init() != 0)
{
dbg_msg("secure", "could not initialize secure RNG");
SkipPWGen = true; // skip automatic password generation
return -1;
}
CServer *pServer = CreateServer();
@ -1841,8 +1840,7 @@ int main(int argc, const char **argv) // ignore_convention
pEngine->InitLogfile();
if(!SkipPWGen)
pServer->InitRconPasswordIfUnset();
pServer->InitRconPasswordIfUnset();
// run the server
dbg_msg("server", "starting...");

View file

@ -77,11 +77,7 @@ void CNetTokenManager::GenerateSeed()
static const NETADDR NullAddr = { 0 };
m_PrevSeed = m_Seed;
for(int i = 0; i < 2; i++)
{
m_Seed <<= 32;
m_Seed ^= random_int();
}
secure_random_fill(&m_Seed, sizeof(m_Seed));
m_PrevGlobalToken = m_GlobalToken;
m_GlobalToken = GenerateToken(&NullAddr);