mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-17 01:05:28 +00:00
fix: session keys are 16 bytes sent as 32 hex characters
The key was a 32 bit number, sent to the client as the MD5 hash of its decimal text. The client only stores the key and sends it back, so it is now 16 bytes from the system entropy source written as 32 lowercase hex characters, which fills the same 33 character field of the login response. The auth, master and world servers pass the key itself between them as a 33 character string in place of the number: SET_SESSION_KEY, SESSION_KEY_RESPONSE and NEW_SESSION_ALERT keep their IDs and carry the string where the number was. The master server keeps one key for each username, and a world server compares the key a client sends with the one from the master server in constant time. A key stays valid until the next login of its account replaces it, as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -308,10 +308,9 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||
|
||||
// The user key
|
||||
uint32_t sessionKey = GeneralUtils::GenerateUnpredictableNumber<uint32_t>();
|
||||
std::string userHash = std::to_string(sessionKey);
|
||||
userHash = md5(userHash);
|
||||
loginResponse.userKey = LUWString(userHash);
|
||||
// 16 bytes as 32 hex characters, which fills the client's key field
|
||||
const std::string sessionKey = GeneralUtils::GenerateUnpredictableHexString(16);
|
||||
loginResponse.userKey = LUWString(sessionKey);
|
||||
|
||||
// World Server IP
|
||||
loginResponse.worldServerIP = LUString(wServerIP);
|
||||
@@ -325,7 +324,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
||||
if (responseCode == eLoginResponse::SUCCESS) {
|
||||
stamps.Add(eStamps::PASSPORT_AUTH_IM_COMMUNICATION_START);
|
||||
MasterPackets::SetSessionKey setSessionKey;
|
||||
setSessionKey.sessionKey = sessionKey;
|
||||
setSessionKey.sessionKey = LUString(sessionKey);
|
||||
setSessionKey.username = LUString(username);
|
||||
stamps.Add(eStamps::PASSPORT_AUTH_IM_LOGIN_START);
|
||||
MasterPackets::SendToMaster(setSessionKey, server);
|
||||
|
||||
Reference in New Issue
Block a user