//
// EVP_PKEY_CTX_dup from 0x102c45c to 0x102c548 (236 bytes)
//
// 3 xrefs:
// > EVP_MD_CTX_copy_ex @ 0x101ff88
// > EVP_DigestSignFinal @ 0x1029b14
// > ??> @ 0x93508
//
// 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:17 +0000
//
__int64 __fastcall EVP_PKEY_CTX_dup(__int64 *a1)
{
__int64 v2; // x0
_OWORD *v3; // x0
__int64 v4; // x20
__int64 v5; // x0
__int64 v6; // x2
__int64 v7; // x4
int v8; // w3
int (__fastcall *v9)(__int64, __int64 *); // x2
bool v10; // cc
__int64 result; // x0
if ( !*a1 || !*(_QWORD *)(*a1 + 16) )
return 0;
v2 = a1[1];
if ( v2 && !(unsigned int)ENGINE_init(v2) )
{
ERR_put_error(6, 156, 38, (__int64)"crypto/evp/pmeth_lib.c", 231);
return 0;
}
v3 = (_OWORD *)CRYPTO_malloc(80, "crypto/evp/pmeth_lib.c", 235);
v4 = (__int64)v3;
if ( !v3 )
return 0;
*v3 = *(_OWORD *)a1;
v5 = a1[2];
if ( v5 )
{
EVP_PKEY_up_ref(v5);
v5 = a1[2];
}
v6 = a1[3];
*(_QWORD *)(v4 + 16) = v5;
if ( v6 )
{
EVP_PKEY_up_ref(v6);
v6 = a1[3];
}
v7 = *a1;
v8 = *((_DWORD *)a1 + 8);
*(_QWORD *)(v4 + 24) = v6;
v9 = *(int (__fastcall **)(__int64, __int64 *))(v7 + 16);
*(_QWORD *)(v4 + 40) = 0;
*(_QWORD *)(v4 + 48) = 0;
*(_DWORD *)(v4 + 32) = v8;
v10 = v9(v4, a1) <= 0;
result = v4;
if ( v10 )
{
EVP_PKEY_CTX_free(v4);
return 0;
}
return result;
}