//
// EVP_PKEY_set_type from 0xdac0c0 to 0xdac1b0 (240 bytes)
//
// 7 xrefs:
// > tls_process_key_exchange @ 0xd4bd94
// > d2i_PrivateKey @ 0xd6a34c
// > EVP_PKCS82PKEY @ 0xdaabac
// > EVP_PKEY_copy_parameters @ 0xdac288
// > EVP_PKEY_assign @ 0xdac40c
// > sub_DF1DE0 @ 0xdf1e18
// > ??> @ 0x3d698
//
// 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_set_type(__int64 a1, unsigned int a2)
{
__int64 v4; // x1
void (*v5)(void); // x1
_DWORD *v6; // x0
_DWORD *v7; // x1
int v8; // w2
__int64 result; // x0
__int64 v10; // x19
__int64 v11; // [xsp+28h] [xbp+28h] BYREF
v11 = 0;
if ( !a1 )
{
v10 = EVP_PKEY_asn1_find(&v11, a2);
ENGINE_finish(v11);
if ( v10 )
return 1;
goto LABEL_14;
}
if ( *(_QWORD *)(a1 + 32) )
{
v4 = *(_QWORD *)(a1 + 16);
if ( v4 )
{
v5 = *(void (**)(void))(v4 + 168);
if ( v5 )
{
v5();
*(_QWORD *)(a1 + 32) = 0;
}
}
ENGINE_finish(*(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 24) = 0;
}
if ( a2 == *(_DWORD *)(a1 + 4) && *(_QWORD *)(a1 + 16) )
return 1;
ENGINE_finish(*(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 24) = 0;
v6 = (_DWORD *)EVP_PKEY_asn1_find(&v11, a2);
v7 = v6;
if ( !v6 )
{
LABEL_14:
ERR_put_error(6, 158, 156, (__int64)"crypto/evp/p_lib.c", 204);
return 0;
}
v8 = *v6;
result = 1;
*(_QWORD *)(a1 + 16) = v7;
*(_QWORD *)(a1 + 24) = v11;
*(_DWORD *)a1 = v8;
*(_DWORD *)(a1 + 4) = a2;
return result;
}