//
// DSA_generate_key from 0xe7caa0 to 0xe7cbf0 (336 bytes)
//
// 2 xrefs:
// > sub_E2BF20 @ 0xe2bf80
// > ??> @ 0x84570
//
// 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 DSA_generate_key(__int64 *a1)
{
__int64 (*v1)(void); // x1
int32x2_t *v4; // x23
__int64 *v5; // x19
__int64 v6; // x22
unsigned int v7; // w21
__int64 v8; // x0
__int64 v9; // x21
__int64 v10; // x0
__int64 v11; // x0
v1 = *(__int64 (**)(void))(a1[11] + 88);
if ( v1 )
return v1();
v4 = (int32x2_t *)BN_CTX_new();
if ( !v4 || (v5 = (__int64 *)a1[6]) == nullptr && (v10 = BN_secure_new(), (v5 = (__int64 *)v10) == nullptr) )
{
v5 = nullptr;
v6 = 0;
goto LABEL_9;
}
do
{
if ( !BN_rand_range(v5, a1[3]) )
{
v6 = 0;
goto LABEL_9;
}
}
while ( BN_is_zero((__int64)v5) );
v6 = a1[5];
if ( !v6 )
{
v6 = BN_new();
if ( !v6 )
goto LABEL_9;
}
v8 = BN_new();
v9 = v8;
if ( !v8 )
goto LABEL_9;
BN_with_flags(v8, v5, 4);
if ( !(unsigned int)BN_mod_exp(v6, a1[4], v9, a1[2], v4) )
{
BN_free(v9);
LABEL_9:
if ( a1[5] != v6 )
BN_free(v6);
v7 = 0;
if ( v5 != (__int64 *)a1[6] )
BN_free((__int64)v5);
goto LABEL_13;
}
v11 = v9;
v7 = 1;
BN_free(v11);
a1[6] = (__int64)v5;
a1[5] = v6;
LABEL_13:
BN_CTX_free((void **)v4);
return v7;
}