//
// DH_check_pub_key from 0x87f76c to 0x87f890 (292 bytes)
//
// 2 xrefs:
// > sub_7E0018 @ 0x7e0080
// > ??> @ 0x60a6c
//
// 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
//
int __fastcall DH_check_pub_key(int a1, int *a2, _DWORD *a3)
{
int ***v6; // r0
int ***v7; // r4
int v8; // r6
int **v9; // r0
int *v10; // r8
int v12; // r0
int v13; // r1
int v14; // r0
_DWORD *v15; // r2
*a3 = 0;
v6 = (int ***)BN_CTX_new();
v7 = v6;
if ( v6 )
{
BN_CTX_start((int)v6);
v9 = BN_CTX_get(v7);
v10 = (int *)v9;
if ( v9 && BN_set_word(v9, 1) )
{
v12 = BN_cmp(a2, v10);
v13 = *(_DWORD *)(a1 + 8);
if ( v12 <= 0 )
*a3 |= 1u;
if ( BN_copy((int)v10, v13) && BN_sub_word((int **)v10, 1u) )
{
v14 = BN_cmp(a2, v10);
v15 = *(_DWORD **)(a1 + 36);
if ( v14 >= 0 )
*a3 |= 2u;
if ( !v15 )
goto LABEL_18;
if ( BN_mod_exp((int **)v10, a2, v15, *(_DWORD *)(a1 + 8), v7) )
{
if ( !BN_is_one((int)v10) )
{
v8 = 1;
*a3 |= 4u;
goto LABEL_6;
}
LABEL_18:
v8 = 1;
goto LABEL_6;
}
}
}
v8 = 0;
LABEL_6:
BN_CTX_end(v7);
BN_CTX_free((void **)v7);
return v8;
}
return 0;
}