//
// DSA_generate_key from 0xae5e8c to 0xae5fcc (320 bytes)
//
// 2 xrefs:
// > sub_A9684C @ 0xa968ac
// > ??> @ 0x8429c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:09:38 +0000
//
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;
}