//
// sub_A124A8 from 0xa124a8 to 0xa12680 (472 bytes)
//
// 6 xrefs:
// > ??> @ 0xc78888
// > ??> @ 0xc788bc
// > ??> @ 0xc788f0
// > ??> @ 0xc78924
// > ??> @ 0xc78958
// > ??> @ 0xc7898c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:07:47 +0000
//
int __fastcall sub_A124A8(int a1, void *a2, void *a3, size_t a4)
{
int cipher_data; // r10
_BOOL4 v9; // r9
int result; // r0
cipher_data = EVP_CIPHER_CTX_get_cipher_data(a1);
v9 = EVP_CIPHER_CTX_iv_length(a1) == 4;
if ( !a3 )
return 0;
if ( !a4 )
return -1;
if ( EVP_CIPHER_CTX_encrypting(a1) )
{
if ( v9 )
{
if ( a2 )
goto LABEL_8;
if ( EVP_CIPHER_CTX_encrypting(a1) )
goto LABEL_27;
}
else
{
if ( (a4 & 7) != 0 )
return -1;
if ( a2 )
goto LABEL_15;
if ( EVP_CIPHER_CTX_encrypting(a1) )
return a4 + 8;
}
return a4 - 8;
}
if ( a4 <= 0xF || (a4 & 7) != 0 )
return -1;
if ( !a2 )
{
if ( EVP_CIPHER_CTX_encrypting(a1) )
{
if ( v9 )
LABEL_27:
a4 = (a4 + 7) & 0xFFFFFFF8;
return a4 + 8;
}
return a4 - 8;
}
if ( !v9 )
{
LABEL_15:
if ( EVP_CIPHER_CTX_encrypting(a1) )
result = CRYPTO_128_wrap(cipher_data, *(_DWORD *)(cipher_data + 248), (int)a2, a3, a4, (int)AES_encrypt);
else
result = CRYPTO_128_unwrap(cipher_data, *(_DWORD *)(cipher_data + 248), a2, a3, a4, AES_decrypt);
goto LABEL_17;
}
LABEL_8:
if ( EVP_CIPHER_CTX_encrypting(a1) )
{
result = CRYPTO_128_wrap_pad(cipher_data, *(_DWORD *)(cipher_data + 248), a2, a3, a4, AES_encrypt);
if ( result )
return result;
return -1;
}
result = CRYPTO_128_unwrap_pad(cipher_data, *(_DWORD *)(cipher_data + 248), a2, a3, a4, (int)AES_decrypt);
LABEL_17:
if ( !result )
return -1;
return result;
}