//
// sub_A946D8 from 0xa946d8 to 0xa94878 (416 bytes)
//
// 2 xrefs:
// > ??> @ 0xc81478
// > ??> @ 0xc814e4
//
// 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:08:59 +0000
//
int __fastcall sub_A946D8(_DWORD *a1, int a2, int *a3)
{
int v3; // r3
int v4; // r5
int v5; // r12
int v6; // r4
int v9; // r9
int v10; // r8
int v12; // r0
void *v13; // r10
char *v14; // r0
char *v15; // r11
v3 = a1[2];
v4 = a1[5];
if ( v3 )
{
v5 = a1[3];
if ( v5 )
{
v6 = *(unsigned __int8 *)(v4 + 32);
v9 = *(_DWORD *)(*(_DWORD *)(v5 + 20) + 20);
v10 = *(_DWORD *)(v3 + 20);
if ( v6 == 1 )
{
if ( !a2 )
{
*a3 = DH_size(*(_DWORD *)(v3 + 20));
return v6;
}
v12 = DH_compute_key(a2, v9, *(_DWORD *)(v3 + 20));
if ( v12 >= 0 )
{
*a3 = v12;
return v6;
}
}
else
{
if ( v6 != 2 )
return 0;
v6 = *(_DWORD *)(v4 + 52);
if ( !v6 )
return v6;
v12 = *(_DWORD *)(v4 + 36);
if ( v12 )
{
if ( !a2 )
{
*a3 = v6;
return 1;
}
if ( v6 == *a3 )
{
v13 = (void *)DH_size(v10);
v14 = (char *)CRYPTO_malloc(v13, (int)"crypto/dh/dh_pmeth.c", 416);
v15 = v14;
if ( v14
&& DH_compute_key_padded(v14, v9, v10) > 0
&& DH_KDF_X9_42(
a2,
*a3,
v15,
v13,
*(_DWORD *)(v4 + 36),
*(_DWORD *)(v4 + 44),
*(_DWORD *)(v4 + 48),
*(_DWORD *)(v4 + 40)) )
{
v6 = 1;
*a3 = *(_DWORD *)(v4 + 52);
}
else
{
v6 = 0;
}
CRYPTO_clear_free(v15, (unsigned int)v13, (int)"crypto/dh/dh_pmeth.c", 428);
return v6;
}
return 0;
}
}
return v12;
}
}
ERR_put_error(5, 112, 108, (int)"crypto/dh/dh_pmeth.c", 385);
return 0;
}