chore(net): tidy up version challenge defines

This commit is contained in:
fallenoak 2025-09-25 22:26:17 -07:00
parent 4312158dfa
commit b7b257f43f
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
3 changed files with 16 additions and 8 deletions

View File

@ -2,6 +2,7 @@
#include "net/connection/WowConnection.hpp" #include "net/connection/WowConnection.hpp"
#include "net/grunt/ClientResponse.hpp" #include "net/grunt/ClientResponse.hpp"
#include "net/grunt/Command.hpp" #include "net/grunt/Command.hpp"
#include "net/grunt/Types.hpp"
#include "net/srp/SRP6_Random.hpp" #include "net/srp/SRP6_Random.hpp"
#include <common/MD5.hpp> #include <common/MD5.hpp>
#include <storm/Error.hpp> #include <storm/Error.hpp>
@ -12,7 +13,6 @@
#define SERVER_PUBLIC_KEY_LEN 32 #define SERVER_PUBLIC_KEY_LEN 32
#define SALT_LEN 32 #define SALT_LEN 32
#define VERSION_CHALLENGE_LEN 16
#define PIN_SALT_LEN 16 #define PIN_SALT_LEN 16
#define SERVER_PROOF_LEN 20 #define SERVER_PROOF_LEN 20
#define RECONNECT_KEY_LEN 16 #define RECONNECT_KEY_LEN 16
@ -115,13 +115,13 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
uint8_t* salt; uint8_t* salt;
uint8_t* versionChallenge; uint8_t* versionChallenge;
if (!CanRead(msg, largeSafePrimeLen + SALT_LEN + VERSION_CHALLENGE_LEN)) { if (!CanRead(msg, largeSafePrimeLen + SALT_LEN + GRUNT_VERSION_CHALLENGE_LEN)) {
return 0; return 0;
} }
msg.GetDataInSitu(reinterpret_cast<void*&>(largeSafePrime), largeSafePrimeLen); msg.GetDataInSitu(reinterpret_cast<void*&>(largeSafePrime), largeSafePrimeLen);
msg.GetDataInSitu(reinterpret_cast<void*&>(salt), SALT_LEN); msg.GetDataInSitu(reinterpret_cast<void*&>(salt), SALT_LEN);
msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), VERSION_CHALLENGE_LEN); msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), GRUNT_VERSION_CHALLENGE_LEN);
uint8_t logonFlags; uint8_t logonFlags;
@ -354,7 +354,7 @@ int32_t Grunt::ClientLink::CmdAuthReconnectChallenge(CDataStore& msg) {
// Reconnect challenge success (result == 0) // Reconnect challenge success (result == 0)
msg.GetDataInSitu(reinterpret_cast<void*&>(reconnectKey), RECONNECT_KEY_LEN); msg.GetDataInSitu(reinterpret_cast<void*&>(reconnectKey), RECONNECT_KEY_LEN);
msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), VERSION_CHALLENGE_LEN); msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), GRUNT_VERSION_CHALLENGE_LEN);
if (!msg.IsValid()) { if (!msg.IsValid()) {
return 1; return 1;
@ -636,7 +636,7 @@ void Grunt::ClientLink::ProveVersion(const uint8_t* versionChecksum) {
SHA1_CONTEXT ctx; SHA1_CONTEXT ctx;
SHA1_Init(&ctx); SHA1_Init(&ctx);
SHA1_Update(&ctx, this->m_srpClient.clientPublicKey, sizeof(this->m_srpClient.clientPublicKey)); SHA1_Update(&ctx, this->m_srpClient.clientPublicKey, sizeof(this->m_srpClient.clientPublicKey));
SHA1_Update(&ctx, versionChecksum, 20); SHA1_Update(&ctx, versionChecksum, GRUNT_VERSION_CHECKSUM_LEN);
SHA1_Final(versionProof, &ctx); SHA1_Final(versionProof, &ctx);
command.PutData(versionProof, sizeof(versionProof)); command.PutData(versionProof, sizeof(versionProof));
@ -685,7 +685,7 @@ void Grunt::ClientLink::ProveVersion(const uint8_t* versionChecksum) {
SHA1_Init(&sha1); SHA1_Init(&sha1);
SHA1_Update(&sha1, clientSalt, sizeof(clientSalt)); SHA1_Update(&sha1, clientSalt, sizeof(clientSalt));
SHA1_Update(&sha1, versionChecksum, 20); SHA1_Update(&sha1, versionChecksum, GRUNT_VERSION_CHECKSUM_LEN);
SHA1_Final(clientChecksum, &sha1); SHA1_Final(clientChecksum, &sha1);
command.PutData(clientChecksum, sizeof(clientChecksum)); command.PutData(clientChecksum, sizeof(clientChecksum));

7
src/net/grunt/Types.hpp Normal file
View File

@ -0,0 +1,7 @@
#ifndef NET_GRUNT_TYPES_HPP
#define NET_GRUNT_TYPES_HPP
#define GRUNT_VERSION_CHALLENGE_LEN 16
#define GRUNT_VERSION_CHECKSUM_LEN 20
#endif

View File

@ -1,14 +1,15 @@
#ifndef NET_LOGIN_GRUNT_LOGIN_HPP #ifndef NET_LOGIN_GRUNT_LOGIN_HPP
#define NET_LOGIN_GRUNT_LOGIN_HPP #define NET_LOGIN_GRUNT_LOGIN_HPP
#include "net/grunt/Grunt.hpp"
#include "net/grunt/ClientResponse.hpp" #include "net/grunt/ClientResponse.hpp"
#include "net/grunt/Grunt.hpp"
#include "net/grunt/Types.hpp"
#include "net/login/Login.hpp" #include "net/login/Login.hpp"
class GruntLogin : public Login { class GruntLogin : public Login {
public: public:
// Member variables // Member variables
uint8_t m_versionChallenge[16]; uint8_t m_versionChallenge[GRUNT_VERSION_CHALLENGE_LEN];
Grunt::ClientLink* m_clientLink = nullptr; Grunt::ClientLink* m_clientLink = nullptr;
// Virtual member functions // Virtual member functions