//
// sub_7FDEF4 from 0x7fdef4 to 0x7fe03c (328 bytes)
//
// 3 xrefs:
// > ??> @ 0xa3173c
// > ??> @ 0xa31770
// > ??> @ 0xa317a4
//
// 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_7FDEF4(int a1, int a2, const void *a3)
{
_BOOL4 v3; // r4
_BOOL4 v4; // r7
const void *v5; // r8
int cipher_data; // r0
_DWORD *v10; // r5
int v11; // r0
int v12; // r0
v3 = a3 == nullptr;
if ( a2 )
v4 = 0;
else
v4 = a3 == nullptr;
v5 = a3;
cipher_data = EVP_CIPHER_CTX_get_cipher_data(a1);
if ( v4 )
return 1;
v10 = (_DWORD *)cipher_data;
if ( a2 )
{
v11 = EVP_CIPHER_CTX_key_length(a1);
AES_set_encrypt_key(a2, 8 * v11, v10);
v12 = EVP_CIPHER_CTX_key_length(a1);
AES_set_decrypt_key(a2, 8 * v12, v10 + 62);
if ( !CRYPTO_ocb128_init(v10 + 126, v10, v10 + 62, AES_encrypt, AES_decrypt, 0) )
return 0;
if ( !v3 || v10[125] && (v5 = (const void *)v10[168]) != nullptr )
{
if ( CRYPTO_ocb128_setiv(v10 + 126, v5, v10[183], v10[184]) != 1 )
return 0;
v10[125] = 1;
}
v10[124] = 1;
return 1;
}
else
{
if ( *(_DWORD *)(cipher_data + 496) )
CRYPTO_ocb128_setiv(cipher_data + 504, v5, *(_DWORD *)(cipher_data + 732), *(_DWORD *)(cipher_data + 736));
else
memcpy(*(void **)(cipher_data + 672), v5, *(_DWORD *)(cipher_data + 732));
v10[125] = 1;
return 1;
}
}