Skip to content

Commit 58e894e

Browse files
committed
fixed compat of steamid generation with reunion2015 version, when authkey was shortest
1 parent 568b1a2 commit 58e894e

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

reunion/src/client_auth.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,10 @@ void SaltSteamId(authdata_t* authdata) {
6161
byte buf[MAX_HASHDATA_LEN];
6262
CSizeBuf szbuf(buf, sizeof buf);
6363

64-
// deprecated auth version reunion2015 has a truncated ticket buffer
65-
const uint32_t MAX_RAWAUTHDATA_TRUNC = 16;
66-
uint32_t authKeyMaxLen = (g_ReunionConfig->getAuthVersion() == av_reunion2015)
67-
? MAX_RAWAUTHDATA_TRUNC : authdata->authKeyLen;
68-
6964
if (g_ReunionConfig->getAuthVersion() < av_reunion2018)
7065
szbuf.WriteLong(authdata->steamId);
7166
if (g_ReunionConfig->getAuthVersion() > av_dproto)
72-
szbuf.Write(authdata->authKey, authKeyMaxLen);
67+
szbuf.Write(authdata->authKey, Reunion_AuthKeyMaxLen(authdata));
7368

7469
szbuf.Write(g_ReunionConfig->getSteamIdSalt(), g_ReunionConfig->getSteamIdSaltLen());
7570

reunion/src/reunion_authorizers.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,27 @@ int g_NumClientAuthorizers = 0;
3737
const char *g_RevEmuCryptKey = "_YOU_SERIOUSLY_NEED_TO_GET_LAID_";
3838
const uint32_t g_SteamEmuHashKey = 0xC9710266;
3939

40-
static uint32_t revHash(const char* str)
40+
static uint32_t revHash(const char* str, int n = -1)
4141
{
4242
uint32_t hash = 0x4E67C6A7;
4343

44-
for (int cc = *str; cc; cc = *++str) {
44+
for (int cc = *str; cc && n != 0; cc = *++str, --n) {
4545
hash ^= (hash >> 2) + cc + 32 * hash;
4646
}
4747

4848
return hash;
4949
}
5050

51+
// deprecated auth version reunion2015 has a truncated ticket buffer
52+
size_t Reunion_AuthKeyMaxLen(authdata_t* authdata)
53+
{
54+
const uint32_t MAX_RAWAUTHDATA_TRUNCATED = 16;
55+
uint32_t authKeyMaxLen = (g_ReunionConfig->getAuthVersion() == av_reunion2015)
56+
? min(authdata->authKeyLen, MAX_RAWAUTHDATA_TRUNCATED) : authdata->authKeyLen;
57+
58+
return authKeyMaxLen;
59+
}
60+
5161
void RevEmuFinishAuthorization(authdata_t* authdata, const char* authStr, size_t authKeyMaxLen, bool stripSpecialChars)
5262
{
5363
uint32_t volumeId;
@@ -86,7 +96,7 @@ void RevEmuFinishAuthorization(authdata_t* authdata, const char* authStr, size_t
8696
memcpy(authdata->authKey, authStr, authdata->authKeyLen);
8797
authdata->authKey[authdata->authKeyLen] = '\0';
8898

89-
authdata->steamId = revHash(authdata->authKey) << 1;
99+
authdata->steamId = revHash(authdata->authKey, Reunion_AuthKeyMaxLen(authdata)) << 1;
90100

91101
if (authStr == (char *)&volumeId)
92102
LCPrintf(false, "RevEmu auth key: '%u' steamid: %u\n", (uint32_t)authStr, authdata->steamId);

reunion/src/reunion_authorizers.h

+1
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ class CNoSteam48Authorizer : public IClientAuthorizer {
8585
extern void Reunion_Init_Authorizers();
8686
extern client_auth_kind Reunion_Authorize_Client(authdata_t* authdata);
8787
extern const char* Reunion_GetAuthorizerName(client_auth_kind authKind);
88+
extern size_t Reunion_AuthKeyMaxLen(authdata_t* authdata);

0 commit comments

Comments
 (0)