//
// sub_1020CDC from 0x1020cdc to 0x1020dcc (240 bytes)
//
// 6 xrefs:
// > ??> @ 0x1401398
// > ??> @ 0x14013f0
// > ??> @ 0x1401448
// > ??> @ 0x14014a0
// > ??> @ 0x14014f8
// > ??> @ 0x1401550
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:16:10 +0000
//
__int64 __fastcall sub_1020CDC(__int64 a1, __int64 a2, const void *a3)
{
__int64 cipher_data; // x23
int v8; // w0
void *v9; // x20
int v10; // w0
int v11; // w0
cipher_data = EVP_CIPHER_CTX_get_cipher_data(a1);
if ( !a3 && !a2 )
return 1;
if ( a2 )
{
if ( (unsigned int)EVP_CIPHER_CTX_encrypting(a1) )
{
v8 = EVP_CIPHER_CTX_key_length(a1);
AES_set_encrypt_key(a2, (unsigned int)(8 * v8), cipher_data);
}
else
{
v11 = EVP_CIPHER_CTX_key_length(a1);
AES_set_decrypt_key(a2, (unsigned int)(8 * v11), cipher_data);
}
if ( a3 )
goto LABEL_8;
*(_QWORD *)(cipher_data + 248) = 0;
return 1;
}
if ( !a3 )
return 1;
LABEL_8:
v9 = (void *)EVP_CIPHER_CTX_iv_noconst(a1);
v10 = EVP_CIPHER_CTX_iv_length(a1);
memcpy(v9, a3, v10);
*(_QWORD *)(cipher_data + 248) = EVP_CIPHER_CTX_iv_noconst(a1);
return 1;
}