//
// sub_A9FDF4 from 0xa9fdf4 to 0xaa0024 (560 bytes)
//
// 1 xrefs:
// > ??> @ 0xc815bc
//
// 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
//
int __fastcall sub_A9FDF4(_DWORD *a1, void *a2, int *a3)
{
int v3; // r4
int v8; // r3
int v9; // r0
int v10; // r0
int degree; // r0
int v12; // r8
int v13; // r8
_BYTE *v14; // r9
int v15; // r3
int v16; // r2
int v17; // r5
int v18; // r0
int v19; // r0
_BOOL4 v20; // r4
int v21; // r2
int v22; // r3
int v23; // r4
int v24; // r0
int v25; // r0
int v26; // r0
int v27; // r0
int v28; // r3
v3 = a1[5];
if ( *(_BYTE *)(v3 + 13) != 1 )
{
if ( !a2 )
{
*a3 = *(_DWORD *)(v3 + 28);
return 1;
}
if ( *a3 != *(_DWORD *)(v3 + 28) )
return 0;
v8 = a1[2];
if ( v8 && a1[3] )
{
v9 = *(_DWORD *)(v3 + 8);
if ( !v9 )
v9 = *(_DWORD *)(v8 + 20);
v10 = EC_KEY_get0_group(v9);
degree = EC_GROUP_get_degree(v10);
v12 = degree + 7;
if ( degree + 7 < 0 )
v12 = degree + 14;
v13 = v12 >> 3;
v14 = CRYPTO_malloc((void *)v13, (int)"crypto/ec/ec_pmeth.c", 200);
if ( !v14 )
return 0;
v15 = a1[2];
if ( v15 && (v16 = a1[3]) != 0 )
{
v17 = *(_DWORD *)(a1[5] + 8);
if ( !v17 )
v17 = *(_DWORD *)(v15 + 20);
v18 = EC_KEY_get0_public_key(*(_DWORD *)(v16 + 20));
v19 = ECDH_compute_key(v14, v13, v18, v17, nullptr);
if ( v19 > 0 )
{
v13 = v19;
v20 = ECDH_KDF_X9_62(a2, *a3, v14, v19, *(_DWORD *)(v3 + 20), *(_DWORD *)(v3 + 24), *(_DWORD *)(v3 + 16)) != 0;
LABEL_18:
CRYPTO_clear_free(v14, v13, (int)"crypto/ec/ec_pmeth.c", 212);
return v20;
}
}
else
{
ERR_put_error(16, 217, 140, (int)"crypto/ec/ec_pmeth.c", 155);
}
v20 = 0;
goto LABEL_18;
}
goto LABEL_30;
}
v21 = a1[2];
if ( !v21 || (v22 = a1[3]) == 0 )
{
LABEL_30:
ERR_put_error(16, 217, 140, (int)"crypto/ec/ec_pmeth.c", 155);
return 0;
}
v23 = *(_DWORD *)(v3 + 8);
if ( !v23 )
v23 = *(_DWORD *)(v21 + 20);
if ( a2 )
{
v24 = EC_KEY_get0_public_key(*(_DWORD *)(v22 + 20));
v25 = ECDH_compute_key(a2, *a3, v24, v23, nullptr);
if ( v25 <= 0 )
return 0;
*a3 = v25;
return 1;
}
else
{
v26 = EC_KEY_get0_group(v23);
v27 = EC_GROUP_get_degree(v26);
v28 = v27 + 7;
if ( v27 + 7 < 0 )
v28 = v27 + 14;
*a3 = v28 >> 3;
return 1;
}
}