//
// sub_80B57C from 0x80b57c to 0x80b774 (504 bytes)
//
// 1 xrefs:
// > ??> @ 0xa323a8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void *__fastcall sub_80B57C(int a1, char *a2, unsigned int *a3)
{
int v3; // r8
int v4; // r5
int v5; // r3
unsigned int v6; // r11
void *result; // r0
unsigned int v8; // r7
unsigned int v9; // r9
int v10; // r0
_DWORD *v11; // r4
int v12; // r5
int v13; // r8
unsigned int v14; // r9
size_t v15; // r2
size_t v17; // [sp+18h] [bp-94h]
unsigned int v18; // [sp+1Ch] [bp-90h]
_BYTE v19[64]; // [sp+28h] [bp-84h] BYREF
_DWORD v20[16]; // [sp+68h] [bp-44h] BYREF
v3 = *(_DWORD *)(a1 + 20);
v4 = *(_DWORD *)v3;
if ( !*(_DWORD *)v3 )
return nullptr;
v5 = *(_DWORD *)(v3 + 12);
if ( !v5 )
return nullptr;
v6 = *a3;
result = HMAC(v4, *(const void **)(v3 + 4), *(_DWORD *)(v3 + 8), v5, *(_DWORD *)(v3 + 16), v19, v20);
if ( !result )
return result;
v17 = v20[0];
v8 = EVP_MD_size(v4);
v9 = v6 / v8;
if ( v6 % v8 )
++v9;
if ( v9 > 0xFF )
return nullptr;
v10 = HMAC_CTX_new();
v11 = (_DWORD *)v10;
if ( !v10 )
return nullptr;
if ( !HMAC_Init_ex(v10, v19, v17, v4, nullptr) )
{
LABEL_24:
HMAC_CTX_free((int)v11);
return nullptr;
}
if ( v9 )
{
v18 = v9 + 1;
v12 = 0;
v13 = 1;
while ( HMAC_Update(v11) && HMAC_Update(v11) && HMAC_Final((int)v11, (int)v20, nullptr) )
{
v14 = v12 + v8;
if ( v6 >= v12 + v8 )
v15 = v8;
else
v15 = v6 - v12;
if ( v6 < v12 + v8 )
v14 = v6;
memcpy(&a2[v12], v20, v15);
if ( ++v13 == v18 )
goto LABEL_27;
if ( v13 != 1 && (!HMAC_Init_ex((int)v11, nullptr, 0, 0, nullptr) || !HMAC_Update(v11)) )
goto LABEL_24;
v12 = v14;
}
goto LABEL_24;
}
LABEL_27:
HMAC_CTX_free((int)v11);
result = a2;
if ( a2 )
return &dword_0 + 1;
return result;
}