//
// sub_DB2844 from 0xdb2844 to 0xdb2974 (304 bytes)
//
// 1 xrefs:
// > ??> @ 0x1125640
//
// 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
//
__int64 __fastcall sub_DB2844(__int64 a1, int a2, int a3, void *a4)
{
__int64 v4; // x20
__int64 v6; // x19
__int64 result; // x0
__int64 v8; // x0
__int64 v9; // x0
__int64 v10; // x0
v4 = a3;
v6 = *(_QWORD *)(a1 + 40);
if ( a2 == 4097 )
{
if ( (a3 & 0x80000000) == 0 )
{
v9 = *(_QWORD *)(v6 + 8);
if ( v9 )
CRYPTO_clear_free(v9, *(_QWORD *)(v6 + 16), "crypto/kdf/tls1_prf.c", 68);
OPENSSL_cleanse((_BYTE *)(v6 + 24), *(_QWORD *)(v6 + 1048));
*(_QWORD *)(v6 + 1048) = 0;
v10 = CRYPTO_memdup(a4, v4, "crypto/kdf/tls1_prf.c", 71);
*(_QWORD *)(v6 + 8) = v10;
if ( v10 )
{
*(_QWORD *)(v6 + 16) = v4;
return 1;
}
}
return 0;
}
if ( a2 == 4098 )
{
if ( !a4 || !a3 )
return 1;
if ( (a3 & 0x80000000) == 0 )
{
v8 = *(_QWORD *)(v6 + 1048);
if ( a3 <= 1024 - (int)v8 )
{
memcpy((void *)(v6 + v8 + 24), a4, a3);
*(_QWORD *)(v6 + 1048) += v4;
return 1;
}
}
return 0;
}
result = 4294967294LL;
if ( a2 == 4096 )
{
*(_QWORD *)v6 = a4;
return 1;
}
return result;
}