//
// sub_7E0018 from 0x7e0018 to 0x7e01cc (436 bytes)
//
// 1 xrefs:
// > ??> @ 0xac0ab4
//
// 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 sub_7E0018(_BYTE *a1, int a2, int a3)
{
int v6; // r0
int v7; // r6
_DWORD *v8; // r8
_BYTE *v9; // r5
int v10; // r4
int v12; // [sp+14h] [bp-8h] BYREF
if ( BN_num_bits(*(_DWORD **)(a3 + 8)) > 10000 )
{
ERR_put_error(5, 102, 103, "crypto/dh/dh_key.c", 153);
return -1;
}
v6 = BN_CTX_new();
v7 = v6;
if ( !v6 )
return -1;
BN_CTX_start(v6);
v8 = (_DWORD *)BN_CTX_get(v7);
if ( *(_DWORD *)(a3 + 24) )
{
v9 = (_BYTE *)(*(_DWORD *)(a3 + 28) & 1);
if ( !v9
|| (v9 = BN_MONT_CTX_set_locked((_BYTE **)(a3 + 32), *(_DWORD *)(a3 + 72), *(int ***)(a3 + 8), v7),
BN_set_flags(*(_DWORD *)(a3 + 24), 4),
v9) )
{
if ( !DH_check_pub_key(a3, a2, &v12) || v12 )
{
ERR_put_error(5, 102, 102, "crypto/dh/dh_key.c", 177);
v10 = -1;
}
else if ( (*(int (__fastcall **)(int, _DWORD *, int, _DWORD, _DWORD, int, _BYTE *))(*(_DWORD *)(a3 + 64) + 12))(
a3,
v8,
a2,
*(_DWORD *)(a3 + 24),
*(_DWORD *)(a3 + 8),
v7,
v9) )
{
v10 = BN_bn2bin(v8, a1);
}
else
{
ERR_put_error(5, 102, 3, "crypto/dh/dh_key.c", 183);
v10 = -1;
}
}
else
{
v10 = -1;
}
}
else
{
ERR_put_error(5, 102, 100, "crypto/dh/dh_key.c", 164);
v10 = -1;
}
BN_CTX_end(v7);
BN_CTX_free(v7);
return v10;
}