//
// EVP_PKEY_CTX_dup from 0xdae0fc to 0xdae1e8 (236 bytes)
//
// 3 xrefs:
// > EVP_MD_CTX_copy_ex @ 0xda1c28
// > EVP_DigestSignFinal @ 0xdab7b4
// > ??> @ 0x6d260
//
// 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
//
__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;
}