//
// EVP_PKEY_CTX_new from 0xdadf94 to 0xdae0fc (360 bytes)
//
// 20 xrefs:
// > ssl_generate_pkey @ 0xd38744
// > ssl_derive @ 0xd388a4
// > sub_D4843C @ 0xd4849c
// > tls_construct_client_key_exchange @ 0xd4a8b8
// > tls_process_client_key_exchange @ 0xd52918
// > EVP_DigestSignInit @ 0xdab50c
// > EVP_DigestVerifyInit @ 0xdab698
// > EVP_SignFinal @ 0xdacb5c
// > EVP_VerifyFinal @ 0xdaccdc
// > sub_DCC148 @ 0xdcc174
// > PKCS7_dataInit @ 0xdcc7a8
// > CMS_RecipientInfo_decrypt @ 0xe1df8c
// > CMS_RecipientInfo_encrypt @ 0xe1e55c
// > CMS_add1_recipient_cert @ 0xe1eabc
// > CMS_RecipientInfo_kari_set0_pkey @ 0xe1f0c4
// > cms_RecipientInfo_kari_init @ 0xe1f3ac
// > cms_RecipientInfo_kari_init @ 0xe1f3e8
// > CMS_SignerInfo_verify_content @ 0xe22370
// > CMS_add1_signer @ 0xe229f8
// > ??> @ 0x96f48
//
// 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_new(__int64 result, __int64 a2)
{
unsigned int *v2; // x2
__int64 pkey_meth_engine; // x21
__int64 v4; // x20
unsigned int v5; // w19
__int64 pkey_meth; // x22
__int64 v7; // x0
__int64 v8; // x19
int (__fastcall *v9)(__int64); // x1
bool v10; // cc
if ( !result )
return result;
v2 = *(unsigned int **)(result + 16);
if ( !v2 )
return 0;
pkey_meth_engine = *(_QWORD *)(result + 24);
v4 = result;
v5 = *v2;
if ( pkey_meth_engine )
goto LABEL_4;
if ( a2 )
{
pkey_meth_engine = a2;
LABEL_4:
if ( !(unsigned int)ENGINE_init(pkey_meth_engine) )
{
ERR_put_error(6, 157, 38, (__int64)"crypto/evp/pmeth_lib.c", 97);
return 0;
}
goto LABEL_5;
}
pkey_meth_engine = ENGINE_get_pkey_meth_engine(v5);
if ( pkey_meth_engine )
{
LABEL_5:
pkey_meth = ENGINE_get_pkey_meth(pkey_meth_engine, v5);
goto LABEL_6;
}
pkey_meth = EVP_PKEY_meth_find(v5);
LABEL_6:
if ( pkey_meth )
{
v7 = CRYPTO_zalloc(80, "crypto/evp/pmeth_lib.c", 119);
v8 = v7;
if ( v7 )
{
*(_QWORD *)(v7 + 8) = pkey_meth_engine;
*(_QWORD *)v7 = pkey_meth;
*(_DWORD *)(v7 + 32) = 0;
*(_QWORD *)(v7 + 16) = v4;
EVP_PKEY_up_ref(v4);
v9 = *(int (__fastcall **)(__int64))(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(pkey_meth_engine);
ERR_put_error(6, 157, 65, (__int64)"crypto/evp/pmeth_lib.c", 124);
return 0;
}
}
else
{
ERR_put_error(6, 157, 156, (__int64)"crypto/evp/pmeth_lib.c", 115);
return 0;
}
return result;
}