//
// sub_A9F69C from 0xa9f69c to 0xa9fa08 (876 bytes)
//
// 1 xrefs:
// > ??> @ 0xc815c0
//
// 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:11 +0000
//
unsigned int __fastcall sub_A9F69C(int a1, int a2, int a3, _DWORD *a4)
{
int v5; // r5
int is_one; // r4
int *v8; // r7
int v9; // r3
_DWORD *v10; // r0
int v11; // r6
v5 = *(_DWORD *)(a1 + 20);
if ( a2 == 4098 )
{
is_one = *(_DWORD *)v5;
if ( *(_DWORD *)v5 )
{
EC_GROUP_set_asn1_flag(*(_DWORD *)v5, a3);
return 1;
}
else
{
ERR_put_error(16, 197, 139, (int)"crypto/ec/ec_pmeth.c", 234);
}
return is_one;
}
if ( a2 <= 4098 )
{
if ( a2 != 7 )
{
if ( a2 <= 7 )
{
if ( a2 != 2 && a2 != 5 )
{
if ( a2 != 1 )
return -2;
if ( EVP_MD_type((int)a4) == 64
|| EVP_MD_type((int)a4) == 416
|| EVP_MD_type((int)a4) == 675
|| EVP_MD_type((int)a4) == 672
|| EVP_MD_type((int)a4) == 673
|| EVP_MD_type((int)a4) == 674 )
{
*(_DWORD *)(v5 + 4) = a4;
return 1;
}
else
{
ERR_put_error(16, 197, 138, (int)"crypto/ec/ec_pmeth.c", 322);
return 0;
}
}
}
else
{
if ( a2 == 13 )
{
*a4 = *(_DWORD *)(v5 + 4);
return 1;
}
if ( a2 == 4097 )
{
v11 = EC_GROUP_new_by_curve_name(a3);
if ( v11 )
{
is_one = 1;
EC_GROUP_free(*(_DWORD *)v5);
*(_DWORD *)v5 = v11;
}
else
{
is_one = 0;
ERR_put_error(16, 197, 141, (int)"crypto/ec/ec_pmeth.c", 225);
}
return is_one;
}
if ( a2 != 11 )
return -2;
}
}
return 1;
}
if ( a2 == 4102 )
{
*a4 = *(_DWORD *)(v5 + 16);
return 1;
}
if ( a2 <= 4102 )
{
if ( a2 == 4100 )
{
if ( a3 == -2 )
return *(unsigned __int8 *)(v5 + 13);
if ( (unsigned int)(a3 - 1) <= 1 )
{
*(_BYTE *)(v5 + 13) = a3;
return 1;
}
return -2;
}
if ( a2 > 4100 )
{
*(_DWORD *)(v5 + 16) = a4;
return 1;
}
if ( a3 == -2 )
{
is_one = *(char *)(v5 + 12);
if ( is_one == -1 )
return ((unsigned int)EC_KEY_get_flags(*(_DWORD *)(*(_DWORD *)(a1 + 8) + 20)) >> 12) & 1;
return is_one;
}
if ( (unsigned int)(a3 + 1) > 2 )
return -2;
*(_BYTE *)(v5 + 12) = a3;
if ( a3 == -1 )
{
EC_KEY_free(*(_DWORD *)(v5 + 8));
*(_DWORD *)(v5 + 8) = 0;
return 1;
}
v8 = *(int **)(*(_DWORD *)(a1 + 8) + 20);
v9 = v8[3];
if ( !v9 )
return -2;
is_one = BN_is_one(*(_DWORD *)(v9 + 12));
if ( !is_one )
{
v10 = *(_DWORD **)(v5 + 8);
if ( v10 || (v10 = EC_KEY_dup(v8), (*(_DWORD *)(v5 + 8) = v10) != 0) )
{
if ( a3 )
EC_KEY_set_flags((int)v10, 4096);
else
EC_KEY_clear_flags((int)v10, 4096);
return 1;
}
return is_one;
}
return 1;
}
if ( a2 == 4104 )
{
*a4 = *(_DWORD *)(v5 + 28);
return 1;
}
if ( a2 < 4104 )
{
if ( a3 > 0 )
{
*(_DWORD *)(v5 + 28) = a3;
return 1;
}
return -2;
}
if ( a2 != 4105 )
{
if ( a2 == 4106 )
{
*a4 = *(_DWORD *)(v5 + 20);
return *(_DWORD *)(v5 + 24);
}
return -2;
}
CRYPTO_free(*(void **)(v5 + 20), (int)"crypto/ec/ec_pmeth.c", 303);
*(_DWORD *)(v5 + 20) = a4;
if ( a4 )
*(_DWORD *)(v5 + 24) = a3;
else
*(_DWORD *)(v5 + 24) = 0;
return 1;
}