//
// sub_7E01E0 from 0x7e01e0 to 0x7e03c0 (480 bytes)
//
// 1 xrefs:
// > ??> @ 0xac0ab0
//
// 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_7E01E0(int a1)
{
int v2; // r8
int *v3; // r4
int v4; // r9
int v5; // r7
_BYTE *v6; // r6
int v7; // r1
int v8; // r1
int v9; // r6
_DWORD *v11; // r0
int v12; // r9
_BYTE *v13; // r0
int v14; // r0
v2 = BN_CTX_new();
if ( !v2 )
goto LABEL_33;
v3 = *(int **)(a1 + 24);
if ( v3 )
{
v4 = 0;
goto LABEL_5;
}
v14 = BN_secure_new();
v3 = (int *)v14;
if ( !v14 )
{
LABEL_33:
v3 = nullptr;
v5 = 0;
goto LABEL_14;
}
v4 = 1;
LABEL_5:
v5 = *(_DWORD *)(a1 + 20);
if ( !v5 )
{
v5 = BN_new();
if ( !v5 )
goto LABEL_14;
}
if ( (*(_DWORD *)(a1 + 28) & 1) != 0 )
{
v13 = BN_MONT_CTX_set_locked((_BYTE **)(a1 + 32), *(_DWORD *)(a1 + 72), *(int ***)(a1 + 8), v2);
v6 = v13;
if ( !v13 )
goto LABEL_14;
}
else
{
v6 = nullptr;
}
if ( !v4 )
goto LABEL_25;
v7 = *(_DWORD *)(a1 + 36);
if ( v7 )
{
while ( BN_rand_range(v3, v7) )
{
if ( !BN_is_zero((int)v3) && !BN_is_one((int)v3) )
goto LABEL_25;
v7 = *(_DWORD *)(a1 + 36);
}
goto LABEL_14;
}
v8 = *(_DWORD *)(a1 + 16);
if ( !v8 )
v8 = BN_num_bits(*(_DWORD **)(a1 + 8)) - 1;
if ( BN_rand(v3, v8, 0, 0) )
{
LABEL_25:
v11 = (_DWORD *)BN_new();
v12 = (int)v11;
if ( v11 )
{
BN_with_flags(v11, v3, 4);
if ( (*(int (__fastcall **)(int, int, _DWORD, int, _DWORD, int, _BYTE *))(*(_DWORD *)(a1 + 64) + 12))(
a1,
v5,
*(_DWORD *)(a1 + 12),
v12,
*(_DWORD *)(a1 + 8),
v2,
v6) )
{
BN_free(v12);
v9 = 1;
*(_DWORD *)(a1 + 20) = v5;
*(_DWORD *)(a1 + 24) = v3;
goto LABEL_19;
}
BN_free(v12);
}
}
LABEL_14:
ERR_put_error(5, 103, 3, "crypto/dh/dh_key.c", 134);
if ( *(_DWORD *)(a1 + 20) != v5 )
BN_free(v5);
if ( *(int **)(a1 + 24) != v3 )
BN_free((int)v3);
v9 = 0;
LABEL_19:
BN_CTX_free(v2);
return v9;
}