//
// EVP_PKEY_CTX_dup from 0x8071f8 to 0x807310 (280 bytes)
//
// 3 xrefs:
// > EVP_MD_CTX_copy_ex @ 0x7fbc5c
// > EVP_DigestSignFinal @ 0x8048e4
// > ??> @ 0x62a2c
//
// 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
//
_DWORD *__fastcall EVP_PKEY_CTX_dup(_DWORD *a1)
{
_DWORD *v2; // r0
_DWORD *v3; // r5
int v4; // r0
int v5; // r3
int v6; // r3
int v7; // r1
int v8; // r2
int (__fastcall *v9)(_DWORD *, _DWORD *); // r3
bool v10; // cc
_DWORD *result; // r0
if ( !*a1 || !*(_DWORD *)(*a1 + 12) )
return nullptr;
v2 = (_DWORD *)a1[1];
if ( v2 && !ENGINE_init(v2) )
{
ERR_put_error(6, 156, 38, (int)"crypto/evp/pmeth_lib.c", 231);
return nullptr;
}
else
{
v3 = (_DWORD *)CRYPTO_malloc(40, "crypto/evp/pmeth_lib.c", 235);
if ( v3 )
{
v4 = a1[2];
v5 = a1[1];
*v3 = *a1;
v3[1] = v5;
if ( v4 )
{
EVP_PKEY_up_ref(v4);
v4 = a1[2];
}
v6 = a1[3];
v3[2] = v4;
if ( v6 )
{
EVP_PKEY_up_ref(v6);
v6 = a1[3];
}
v7 = *a1;
v8 = a1[4];
v3[3] = v6;
v9 = *(int (__fastcall **)(_DWORD *, _DWORD *))(v7 + 12);
v3[5] = 0;
v3[6] = 0;
v3[4] = v8;
v10 = v9(v3, a1) <= 0;
result = v3;
if ( v10 )
{
EVP_PKEY_CTX_free((int)v3);
return nullptr;
}
}
else
{
return nullptr;
}
}
return result;
}