//
// EVP_PKEY_set_type from 0x102a420 to 0x102a510 (240 bytes)
//
// 7 xrefs:
// > tls_process_key_exchange @ 0xfca0e8
// > d2i_PrivateKey @ 0xfe86ac
// > EVP_PKCS82PKEY @ 0x1028f0c
// > EVP_PKEY_copy_parameters @ 0x102a5e8
// > EVP_PKEY_assign @ 0x102a76c
// > sub_1070120 @ 0x1070158
// > ??> @ 0x58d08
//
// 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:16 +0000
//
__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;
}