//
// sub_801C00 from 0x801c00 to 0x801dc8 (456 bytes)
//
// 1 xrefs:
// > ??> @ 0xac0dc8
//
// 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
//
int __fastcall sub_801C00(int a1, char *a2, char *a3, int a4)
{
int cipher_data; // r0
size_t v9; // r4
_DWORD *v10; // r5
size_t v11; // r8
char *v13; // r4
unsigned __int8 v14[16]; // [sp+0h] [bp-10h] BYREF
cipher_data = EVP_CIPHER_CTX_get_cipher_data(a1);
v9 = *(_DWORD *)(cipher_data + 536);
v10 = (_DWORD *)cipher_data;
if ( v9 == -1 )
{
if ( EVP_CIPHER_CTX_encrypting(a1) )
{
MD5_Update((int)(v10 + 111), a3);
RC4(v10, a4, a3, a2);
}
else
{
RC4(v10, a4, a3, a2);
MD5_Update((int)(v10 + 111), a2);
}
}
else
{
v11 = v9 + 16;
if ( v9 + 16 != a4 )
return 0;
if ( EVP_CIPHER_CTX_encrypting(a1) )
{
MD5_Update((int)(v10 + 111), a3);
if ( a3 != a2 )
memcpy(a2, a3, v9);
v13 = &a2[v9];
MD5_Final(v13, v10 + 111);
memcpy(v10 + 111, v10 + 88, 0x5Cu);
MD5_Update((int)(v10 + 111), v13);
MD5_Final(v13, v10 + 111);
RC4(v10, v11, a2, a2);
}
else
{
RC4(v10, v9 + 16, a3, a2);
MD5_Update((int)(v10 + 111), a2);
MD5_Final(v14, v10 + 111);
memcpy(v10 + 111, v10 + 88, 0x5Cu);
MD5_Update((int)(v10 + 111), v14);
MD5_Final(v14, v10 + 111);
if ( CRYPTO_memcmp((unsigned __int8 *)&a2[v9], v14, 16) )
return 0;
}
}
v10[134] = -1;
return 1;
}