//
// sub_1021E8C from 0x1021e8c to 0x1021ff4 (360 bytes)
//
// 3 xrefs:
// > ??> @ 0x1401290
// > ??> @ 0x14012e8
// > ??> @ 0x1401340
//
// 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:11 +0000
//
__int64 __fastcall sub_1021E8C(__int64 a1, __int64 a2, const void *a3)
{
__int64 cipher_data; // x19
int v8; // w0
void *v9; // x0
int v10; // w0
int v11; // w0
cipher_data = EVP_CIPHER_CTX_get_cipher_data(a1);
if ( !a3 && !a2 )
return 1;
if ( a2 )
{
if ( (OPENSSL_armcap_P & 4) != 0 )
{
v11 = EVP_CIPHER_CTX_key_length(a1);
aes_v8_set_encrypt_key(a2, (unsigned int)(8 * v11), cipher_data);
CRYPTO_ccm128_init(
cipher_data + 280,
*(unsigned int *)(cipher_data + 268),
*(unsigned int *)(cipher_data + 264),
cipher_data,
aes_v8_encrypt);
*(_QWORD *)(cipher_data + 336) = 0;
*(_DWORD *)(cipher_data + 248) = 1;
if ( a3 )
goto LABEL_9;
}
else
{
if ( (OPENSSL_armcap_P & 1) != 0 )
{
v8 = EVP_CIPHER_CTX_key_length(a1);
vpaes_set_encrypt_key(a2, (unsigned int)(8 * v8), cipher_data);
CRYPTO_ccm128_init(
cipher_data + 280,
*(unsigned int *)(cipher_data + 268),
*(unsigned int *)(cipher_data + 264),
cipher_data,
vpaes_encrypt);
*(_QWORD *)(cipher_data + 336) = 0;
*(_DWORD *)(cipher_data + 248) = 1;
goto LABEL_8;
}
v10 = EVP_CIPHER_CTX_key_length(a1);
AES_set_encrypt_key(a2, (unsigned int)(8 * v10), cipher_data);
CRYPTO_ccm128_init(
cipher_data + 280,
*(unsigned int *)(cipher_data + 268),
*(unsigned int *)(cipher_data + 264),
cipher_data,
AES_encrypt);
*(_QWORD *)(cipher_data + 336) = 0;
*(_DWORD *)(cipher_data + 248) = 1;
if ( a3 )
goto LABEL_9;
}
return 1;
}
LABEL_8:
if ( !a3 )
return 1;
LABEL_9:
v9 = (void *)EVP_CIPHER_CTX_iv_noconst(a1);
memcpy(v9, a3, 15 - *(_DWORD *)(cipher_data + 264));
*(_DWORD *)(cipher_data + 252) = 1;
return 1;
}