feat(net): handle realm server auth challenge

This commit is contained in:
fallenoak 2023-03-23 23:01:11 -05:00
parent 0b7970101a
commit 5d11881372
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
5 changed files with 141 additions and 5 deletions

View file

@ -1,5 +1,8 @@
#include "net/connection/RealmConnection.hpp"
#include "net/Types.hpp"
#include <common/DataStore.hpp>
#include <common/SHA1.hpp>
#include <storm/String.hpp>
SCritSect RealmConnection::s_AllRealmConnectionsCrit;
STORM_LIST(RealmConnection::REALMCONNECTIONNODE) RealmConnection::s_AllRealmConnections;
@ -46,6 +49,53 @@ RealmConnection::RealmConnection(RealmResponse* realmResponse) {
int32_t RealmConnection::HandleAuthChallenge(AuthenticationChallenge* challenge) {
// TODO
// TODO switch to WDataStore
CDataStore msg;
uint32_t localChallenge;
msg.Put(static_cast<uint32_t>(CMSG_AUTH_SESSION));
msg.Put(static_cast<uint32_t>(12340));
msg.Put(static_cast<uint32_t>(this->GetLoginData().m_loginServerID));
msg.PutString(this->GetLoginData().m_account);
msg.Put(static_cast<uint32_t>(this->GetLoginData().m_loginServerType));
// TODO
msg.Put(localChallenge);
// TODO
msg.Put(static_cast<uint32_t>(0));
msg.Put(static_cast<uint32_t>(0));
msg.Put(static_cast<uint32_t>(1));
// TODO
msg.Put(static_cast<uint64_t>(0));
uint32_t msgId = 0;
SHA1_CONTEXT ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx, reinterpret_cast<const uint8_t*>(this->GetLoginData().m_account), SStrLen(this->GetLoginData().m_account));
SHA1_Update(&ctx, reinterpret_cast<uint8_t*>(&msgId), sizeof(msgId));
SHA1_Update(&ctx, reinterpret_cast<uint8_t*>(&localChallenge), sizeof(localChallenge));
SHA1_Update(&ctx, reinterpret_cast<uint8_t*>(&challenge->uint0), sizeof(challenge->uint0));
SHA1_Update(&ctx, this->GetLoginData().m_sessionKey, sizeof(this->GetLoginData().m_sessionKey));
uint8_t clientProof[SHA1_DIGEST_SIZE];
SHA1_Final(clientProof, &ctx);
msg.PutData(clientProof, sizeof(clientProof));
// TODO addons
msg.Put(static_cast<uint32_t>(0));
msg.Finalize();
this->Send(&msg);
return 1;
}