//
// EVP_PKEY_CTX_new from 0x102c2f4 to 0x102c45c (360 bytes)
//
// 20 xrefs:
// > ssl_generate_pkey @ 0xfb6a98
// > ssl_derive @ 0xfb6bf8
// > sub_FC6790 @ 0xfc67f0
// > tls_construct_client_key_exchange @ 0xfc8c0c
// > tls_process_client_key_exchange @ 0xfd0c6c
// > EVP_DigestSignInit @ 0x102986c
// > EVP_DigestVerifyInit @ 0x10299f8
// > EVP_SignFinal @ 0x102aebc
// > EVP_VerifyFinal @ 0x102b03c
// > sub_104A4A8 @ 0x104a4d4
// > PKCS7_dataInit @ 0x104ab08
// > CMS_RecipientInfo_decrypt @ 0x109c28c
// > CMS_RecipientInfo_encrypt @ 0x109c85c
// > CMS_add1_recipient_cert @ 0x109cdbc
// > CMS_RecipientInfo_kari_set0_pkey @ 0x109d3c4
// > cms_RecipientInfo_kari_init @ 0x109d6ac
// > cms_RecipientInfo_kari_init @ 0x109d6e8
// > CMS_SignerInfo_verify_content @ 0x10a0670
// > CMS_add1_signer @ 0x10a0cf8
// > ??> @ 0xc7540
//
// 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_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;
}