//
// sub_7FDA8C from 0x7fda8c to 0x7fdc0c (384 bytes)
//
// 3 xrefs:
// > ??> @ 0xa31754
// > ??> @ 0xa31788
// > ??> @ 0xa317bc
//
// 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_7FDA8C(int a1, int a2, size_t a3, void *a4)
{
_DWORD *cipher_data; // r0
_DWORD *v9; // r5
int v12; // r0
int v13; // r0
cipher_data = (_DWORD *)EVP_CIPHER_CTX_get_cipher_data(a1);
v9 = cipher_data;
switch ( a2 )
{
case 0:
cipher_data[124] = 0;
cipher_data[125] = 0;
cipher_data[183] = EVP_CIPHER_CTX_iv_length(a1);
v12 = EVP_CIPHER_CTX_iv_noconst(a1);
v9[184] = 16;
v9[181] = 0;
v9[182] = 0;
v9[168] = v12;
return 1;
case 8:
v13 = EVP_CIPHER_CTX_get_cipher_data(a4);
return CRYPTO_ocb128_copy_ctx(v13 + 504, v9 + 126, v13, v13 + 248);
case 9:
if ( a3 - 1 > 0xE )
return 0;
cipher_data[183] = a3;
return 1;
case 16:
if ( cipher_data[184] != a3 || !EVP_CIPHER_CTX_encrypting(a1) )
return 0;
memcpy(a4, v9 + 169, a3);
return 1;
case 17:
if ( !a4 )
{
if ( a3 <= 0x10 )
{
cipher_data[184] = a3;
return 1;
}
return 0;
}
if ( cipher_data[184] != a3 || EVP_CIPHER_CTX_encrypting(a1) )
return 0;
memcpy(v9 + 169, a4, a3);
return 1;
default:
return -1;
}
}