//
// EVP_PKEY_derive_set_peer from 0xdad5c4 to 0xdad790 (460 bytes)
//
// 6 xrefs:
// > ssl_derive @ 0xd388c0
// > tls_process_client_key_exchange @ 0xd52948
// > sub_D869F4 @ 0xd8707c
// > sub_D8B4C0 @ 0xd8baec
// > cms_RecipientInfo_kari_encrypt @ 0xe1f650
// > ??> @ 0x56d30
//
// 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_derive_set_peer(__int64 a1, _DWORD *a2)
{
_QWORD *v4; // x0
__int64 (__fastcall *v5)(__int64, __int64, _QWORD, _DWORD *); // x4
int v6; // w0
__int64 result; // x0
_DWORD *v8; // x0
if ( a1
&& (v4 = *(_QWORD **)a1) != nullptr
&& (v4[23] || v4[19] || v4[21])
&& (v5 = (__int64 (__fastcall *)(__int64, __int64, _QWORD, _DWORD *))v4[24]) != nullptr )
{
v6 = *(_DWORD *)(a1 + 32);
if ( ((v6 - 256) & 0xFFFFFEFF) != 0 && v6 != 1024 )
{
ERR_put_error(6, 155, 151, (__int64)"crypto/evp/pmeth_fn.c", 233);
return 0xFFFFFFFFLL;
}
else
{
result = v5(a1, 2, 0, a2);
if ( (int)result > 0 )
{
if ( (_DWORD)result == 2 )
{
return 1;
}
else
{
v8 = *(_DWORD **)(a1 + 16);
if ( v8 )
{
if ( *v8 == *a2 )
{
if ( (unsigned int)EVP_PKEY_missing_parameters((__int64)a2)
|| (unsigned int)EVP_PKEY_cmp_parameters(*(_QWORD *)(a1 + 16), a2) )
{
EVP_PKEY_free(*(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 24) = a2;
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64, _DWORD *))(*(_QWORD *)a1 + 192LL))(
a1,
2,
1,
a2);
if ( (int)result <= 0 )
{
*(_QWORD *)(a1 + 24) = 0;
}
else
{
EVP_PKEY_up_ref((__int64)a2);
return 1;
}
}
else
{
ERR_put_error(6, 155, 153, (__int64)"crypto/evp/pmeth_fn.c", 264);
return 0xFFFFFFFFLL;
}
}
else
{
ERR_put_error(6, 155, 101, (__int64)"crypto/evp/pmeth_fn.c", 251);
return 0xFFFFFFFFLL;
}
}
else
{
ERR_put_error(6, 155, 154, (__int64)"crypto/evp/pmeth_fn.c", 246);
return 0xFFFFFFFFLL;
}
}
}
}
}
else
{
ERR_put_error(6, 155, 150, (__int64)"crypto/evp/pmeth_fn.c", 226);
return 4294967294LL;
}
return result;
}