//
// DSA_generate_key from 0x8d0e8c to 0x8d0fcc (320 bytes)
//
// 2 xrefs:
// > sub_881C4C @ 0x881cac
// > ??> @ 0x6a81c
//
// 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 DSA_generate_key(int a1)
{
int (*v1)(void); // r3
int ***v4; // r7
int **v5; // r6
int **v6; // r5
int v7; // r8
_DWORD *v8; // r0
_DWORD *v9; // r8
int v10; // r0
v1 = *(int (**)(void))(*(_DWORD *)(a1 + 44) + 44);
if ( v1 )
return v1();
v4 = (int ***)BN_CTX_new();
if ( !v4 || (v5 = *(int ***)(a1 + 24)) == nullptr && (v10 = BN_secure_new(), (v5 = (int **)v10) == nullptr) )
{
v5 = nullptr;
v6 = nullptr;
goto LABEL_9;
}
do
{
if ( !BN_rand_range(v5, *(int **)(a1 + 12)) )
{
v6 = nullptr;
goto LABEL_9;
}
}
while ( BN_is_zero((int)v5) );
v6 = *(int ***)(a1 + 20);
if ( !v6 )
{
v6 = (int **)BN_new();
if ( !v6 )
goto LABEL_9;
}
v8 = (_DWORD *)BN_new();
v9 = v8;
if ( !v8 )
goto LABEL_9;
BN_with_flags(v8, (int *)v5, 4);
if ( !BN_mod_exp(v6, *(int **)(a1 + 16), v9, *(_DWORD *)(a1 + 8), v4) )
{
BN_free((int)v9);
LABEL_9:
if ( *(int ***)(a1 + 20) != v6 )
BN_free((int)v6);
if ( v5 != *(int ***)(a1 + 24) )
BN_free((int)v5);
v7 = 0;
goto LABEL_14;
}
BN_free((int)v9);
v7 = 1;
*(_DWORD *)(a1 + 24) = v5;
*(_DWORD *)(a1 + 20) = v6;
LABEL_14:
BN_CTX_free((void **)v4);
return v7;
}