//
// DH_check_pub_key from 0xe299e4 to 0xe29b24 (320 bytes)
//
// 2 xrefs:
// > sub_D877EC @ 0xd8785c
// > ??> @ 0xaf920
//
// 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 DH_check_pub_key(__int64 a1, __int64 *a2, _DWORD *a3)
{
int32x2_t *v6; // x0
int32x2_t *v7; // x19
__int64 v8; // x0
__int64 *v9; // x21
unsigned int v10; // w21
__int64 v12; // x2
*a3 = 0;
v6 = (int32x2_t *)BN_CTX_new();
v7 = v6;
if ( v6 )
{
BN_CTX_start((unsigned __int64)v6);
v8 = BN_CTX_get(v7);
v9 = (__int64 *)v8;
if ( v8 && (unsigned int)BN_set_word(v8, 1) )
{
if ( (int)BN_cmp(a2, v9) <= 0 )
*a3 |= 1u;
if ( BN_copy((unsigned __int64 *)v9, *(_QWORD *)(a1 + 8)) && (unsigned int)BN_sub_word((__int64)v9, 1u) )
{
if ( (BN_cmp(a2, v9) & 0x80000000) == 0 )
*a3 |= 2u;
v12 = *(_QWORD *)(a1 + 64);
if ( !v12 )
goto LABEL_17;
if ( (unsigned int)BN_mod_exp((__int64)v9, (__int64)a2, v12, *(_QWORD *)(a1 + 8), v7) )
{
if ( !(unsigned int)BN_is_one((__int64)v9) )
{
v10 = 1;
*a3 |= 4u;
goto LABEL_5;
}
LABEL_17:
v10 = 1;
goto LABEL_5;
}
}
}
v10 = 0;
LABEL_5:
BN_CTX_end((__int64)v7);
BN_CTX_free((void **)v7);
return v10;
}
return 0;
}