fixed compat of steamid generation with reunion2015 version, when authkey was shortest
Some checks failed
C/C++ CI / Windows (push) Has been cancelled
C/C++ CI / Linux (push) Has been cancelled
C/C++ CI / Publish (push) Has been cancelled

This commit is contained in:
s1lentq 2025-04-12 03:31:24 +07:00
parent 568b1a2b3b
commit 58e894ef25
3 changed files with 15 additions and 9 deletions

View File

@ -61,15 +61,10 @@ void SaltSteamId(authdata_t* authdata) {
byte buf[MAX_HASHDATA_LEN];
CSizeBuf szbuf(buf, sizeof buf);
// deprecated auth version reunion2015 has a truncated ticket buffer
const uint32_t MAX_RAWAUTHDATA_TRUNC = 16;
uint32_t authKeyMaxLen = (g_ReunionConfig->getAuthVersion() == av_reunion2015)
? MAX_RAWAUTHDATA_TRUNC : authdata->authKeyLen;
if (g_ReunionConfig->getAuthVersion() < av_reunion2018)
szbuf.WriteLong(authdata->steamId);
if (g_ReunionConfig->getAuthVersion() > av_dproto)
szbuf.Write(authdata->authKey, authKeyMaxLen);
szbuf.Write(authdata->authKey, Reunion_AuthKeyMaxLen(authdata));
szbuf.Write(g_ReunionConfig->getSteamIdSalt(), g_ReunionConfig->getSteamIdSaltLen());

View File

@ -37,17 +37,27 @@ int g_NumClientAuthorizers = 0;
const char *g_RevEmuCryptKey = "_YOU_SERIOUSLY_NEED_TO_GET_LAID_";
const uint32_t g_SteamEmuHashKey = 0xC9710266;
static uint32_t revHash(const char* str)
static uint32_t revHash(const char* str, int n = -1)
{
uint32_t hash = 0x4E67C6A7;
for (int cc = *str; cc; cc = *++str) {
for (int cc = *str; cc && n != 0; cc = *++str, --n) {
hash ^= (hash >> 2) + cc + 32 * hash;
}
return hash;
}
// deprecated auth version reunion2015 has a truncated ticket buffer
size_t Reunion_AuthKeyMaxLen(authdata_t* authdata)
{
const uint32_t MAX_RAWAUTHDATA_TRUNCATED = 16;
uint32_t authKeyMaxLen = (g_ReunionConfig->getAuthVersion() == av_reunion2015)
? min(authdata->authKeyLen, MAX_RAWAUTHDATA_TRUNCATED) : authdata->authKeyLen;
return authKeyMaxLen;
}
void RevEmuFinishAuthorization(authdata_t* authdata, const char* authStr, size_t authKeyMaxLen, bool stripSpecialChars)
{
uint32_t volumeId;
@ -86,7 +96,7 @@ void RevEmuFinishAuthorization(authdata_t* authdata, const char* authStr, size_t
memcpy(authdata->authKey, authStr, authdata->authKeyLen);
authdata->authKey[authdata->authKeyLen] = '\0';
authdata->steamId = revHash(authdata->authKey) << 1;
authdata->steamId = revHash(authdata->authKey, Reunion_AuthKeyMaxLen(authdata)) << 1;
if (authStr == (char *)&volumeId)
LCPrintf(false, "RevEmu auth key: '%u' steamid: %u\n", (uint32_t)authStr, authdata->steamId);

View File

@ -85,3 +85,4 @@ class CNoSteam48Authorizer : public IClientAuthorizer {
extern void Reunion_Init_Authorizers();
extern client_auth_kind Reunion_Authorize_Client(authdata_t* authdata);
extern const char* Reunion_GetAuthorizerName(client_auth_kind authKind);
extern size_t Reunion_AuthKeyMaxLen(authdata_t* authdata);