[Cryptography] Generate secure challenges
This commit is contained in:
parent
724efa1050
commit
06bb09e1f0
@ -31,7 +31,7 @@ namespace Components
|
||||
|
||||
Logger::Print("Starting local server discovery...\n");
|
||||
|
||||
Discovery::Challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||
Discovery::Challenge = Utils::Cryptography::Rand::GenerateChallenge();
|
||||
|
||||
unsigned int minPort = Dvar::Var("net_discoveryPortRangeMin").get<unsigned int>();
|
||||
unsigned int maxPort = Dvar::Var("net_discoveryPortRangeMax").get<unsigned int>();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,7 @@ namespace Components
|
||||
Party::Container.awaitingPlaylist = false;
|
||||
Party::Container.joinTime = Game::Sys_Milliseconds();
|
||||
Party::Container.target = target;
|
||||
Party::Container.challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||
Party::Container.challenge = Utils::Cryptography::Rand::GenerateChallenge();
|
||||
|
||||
Network::SendCommand(Party::Container.target, "getinfo", Party::Container.challenge);
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace Components
|
||||
Network::Handle("rconRequest", [] (Network::Address address, std::string data)
|
||||
{
|
||||
RCon::BackdoorContainer.address = address;
|
||||
RCon::BackdoorContainer.challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||
RCon::BackdoorContainer.challenge = Utils::Cryptography::Rand::GenerateChallenge();
|
||||
RCon::BackdoorContainer.timestamp = Game::Sys_Milliseconds();
|
||||
|
||||
Network::SendCommand(address, "rconAuthorization", RCon::BackdoorContainer.challenge);
|
||||
|
@ -595,7 +595,7 @@ namespace Components
|
||||
SendServers--;
|
||||
|
||||
server->sendTime = Game::Sys_Milliseconds();
|
||||
server->challenge = Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt());
|
||||
server->challenge = Utils::Cryptography::Rand::GenerateChallenge();
|
||||
|
||||
++ServerList::RefreshContainer.sentCount;
|
||||
|
||||
|
@ -16,6 +16,16 @@ namespace Utils
|
||||
|
||||
prng_state Rand::State;
|
||||
|
||||
std::string Rand::GenerateChallenge()
|
||||
{
|
||||
std::string challenge;
|
||||
challenge.append(Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt()));
|
||||
challenge.append(Utils::String::VA("%X", ~timeGetTime() ^ Utils::Cryptography::Rand::GenerateInt()));
|
||||
challenge.append(Utils::String::VA("%X", Utils::Cryptography::Rand::GenerateInt()));
|
||||
|
||||
return challenge;
|
||||
}
|
||||
|
||||
uint32_t Rand::GenerateInt()
|
||||
{
|
||||
uint32_t number = 0;
|
||||
|
@ -134,6 +134,7 @@ namespace Utils
|
||||
class Rand
|
||||
{
|
||||
public:
|
||||
static std::string GenerateChallenge();
|
||||
static uint32_t GenerateInt();
|
||||
static void Initialize();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user