//
// EVP_PKEY_CTX_new from 0x807070 to 0x8071ec (380 bytes)
//
// 20 xrefs:
// > ssl_generate_pkey @ 0x78f02c
// > ssl_derive @ 0x78f1a0
// > sub_79FC70 @ 0x79fcbc
// > tls_construct_client_key_exchange @ 0x7a24c0
// > tls_process_client_key_exchange @ 0x7ab064
// > EVP_DigestSignInit @ 0x804670
// > EVP_DigestVerifyInit @ 0x8047e0
// > EVP_SignFinal @ 0x805b90
// > EVP_VerifyFinal @ 0x805cfc
// > sub_8268D4 @ 0x8268f0
// > PKCS7_dataInit @ 0x826ea4
// > CMS_RecipientInfo_decrypt @ 0x87356c
// > CMS_RecipientInfo_encrypt @ 0x873b84
// > CMS_add1_recipient_cert @ 0x87413c
// > CMS_RecipientInfo_kari_set0_pkey @ 0x874814
// > cms_RecipientInfo_kari_init @ 0x874ad8
// > cms_RecipientInfo_kari_init @ 0x874b14
// > CMS_SignerInfo_verify_content @ 0x877a34
// > CMS_add1_signer @ 0x878178
// > ??> @ 0x5ae1c
//
// 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_PKEY_CTX_new(int result, _DWORD *a2)
{
int *v2; // r3
_DWORD *pkey_meth_engine; // r6
int v4; // r5
int v5; // r7
int pkey_meth; // r7
int *v7; // r0
int v8; // r4
int (__fastcall *v9)(int); // r2
bool v10; // cc
if ( !result )
return result;
v2 = *(int **)(result + 12);
if ( !v2 )
return 0;
pkey_meth_engine = *(_DWORD **)(result + 16);
v4 = result;
v5 = *v2;
if ( pkey_meth_engine )
goto LABEL_4;
if ( a2 )
{
pkey_meth_engine = a2;
LABEL_4:
if ( !ENGINE_init(pkey_meth_engine) )
{
ERR_put_error(6, 157, 38, (int)"crypto/evp/pmeth_lib.c", 97);
return 0;
}
goto LABEL_5;
}
pkey_meth_engine = (_DWORD *)ENGINE_get_pkey_meth_engine(*v2);
if ( pkey_meth_engine )
{
LABEL_5:
pkey_meth = ENGINE_get_pkey_meth((int)pkey_meth_engine, v5);
goto LABEL_6;
}
pkey_meth = EVP_PKEY_meth_find(v5);
LABEL_6:
if ( pkey_meth )
{
v7 = (int *)CRYPTO_zalloc(40, "crypto/evp/pmeth_lib.c", 119);
v8 = (int)v7;
if ( v7 )
{
v7[1] = (int)pkey_meth_engine;
*v7 = pkey_meth;
v7[2] = v4;
v7[4] = 0;
EVP_PKEY_up_ref(v4);
v9 = *(int (__fastcall **)(int))(pkey_meth + 8);
result = v8;
if ( v9 )
{
v10 = v9(v8) <= 0;
result = v8;
if ( v10 )
{
EVP_PKEY_CTX_free(v8);
return 0;
}
}
}
else
{
ENGINE_finish((int)pkey_meth_engine);
ERR_put_error(6, 157, 65, (int)"crypto/evp/pmeth_lib.c", 124);
return 0;
}
}
else
{
ERR_put_error(6, 157, 156, (int)"crypto/evp/pmeth_lib.c", 115);
return 0;
}
return result;
}