//
// EVP_CIPHER_CTX_copy from 0x8034f0 to 0x803660 (368 bytes)
//
// 3 xrefs:
// > CMAC_CTX_copy @ 0x7d90b0
// > sub_8B509C @ 0x8b5264
// > ??> @ 0x6006c
//
// 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 EVP_CIPHER_CTX_copy(int *a1, int *a2)
{
_DWORD *v4; // r0
int v5; // r2
int v6; // r0
void *v7; // r6
void *v9; // r0
if ( a2 && *a2 )
{
v4 = (_DWORD *)a2[1];
if ( v4 && !ENGINE_init(v4) )
{
ERR_put_error(6, 163, 38, (int)"crypto/evp/evp_enc.c", 610);
return 0;
}
else
{
EVP_CIPHER_CTX_reset(a1);
memcpy(a1, a2, 0x8Cu);
v5 = *a2;
if ( a2[24] && (v6 = *(_DWORD *)(v5 + 32)) != 0 )
{
v9 = (void *)CRYPTO_malloc(v6, "crypto/evp/evp_enc.c", 619);
v7 = v9;
a1[24] = (int)v9;
if ( !v9 )
{
ERR_put_error(6, 163, 65, (int)"crypto/evp/evp_enc.c", 621);
return (int)v7;
}
memcpy(v9, (const void *)a2[24], *(_DWORD *)(*a2 + 32));
v5 = *a2;
if ( (*(_DWORD *)(*a2 + 16) & 0x400) == 0 )
return 1;
}
else if ( (*(_DWORD *)(v5 + 16) & 0x400) == 0 )
{
return 1;
}
return (*(int (__fastcall **)(int *, int, _DWORD, int *))(v5 + 44))(a2, 8, 0, a1);
}
}
else
{
ERR_put_error(6, 163, 111, (int)"crypto/evp/evp_enc.c", 604);
return 0;
}
}