//
// ec_GFp_simple_oct2point from 0xa075e0 to 0xa078e8 (776 bytes)
//
// 2 xrefs:
// > EC_POINT_oct2point @ 0xa020c0
// > ??> @ 0x7b6ac
//
// 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:07:41 +0000
//
int __fastcall ec_GFp_simple_oct2point(int a1, _DWORD *a2, unsigned __int8 *a3, int a4, int a5)
{
int v6; // r6
int v8; // r2
int v9; // r10
unsigned int v10; // r4
int v14; // r0
int v15; // r8
int v16; // r8
int v17; // r2
int *v18; // r9
_BOOL4 v19; // r9
int v20; // r0
int v21; // [sp+8h] [bp-Ch]
int *v22; // [sp+Ch] [bp-8h]
v6 = a5;
if ( !a4 )
{
ERR_put_error(16, 103, 100, "crypto/ec/ecp_oct.c", 285);
return 0;
}
v8 = *a3;
v9 = v8 & 1;
v10 = v8 & 0xFFFFFFFE;
if ( (v8 & 0xF8) != 0 )
{
ERR_put_error(16, 103, 102, "crypto/ec/ecp_oct.c", 294);
return 0;
}
if ( (v8 & 0xFFFFFFFA) != 0 )
goto LABEL_10;
if ( (v8 & 1) != 0 )
{
ERR_put_error(16, 103, 102, "crypto/ec/ecp_oct.c", 298);
return 0;
}
if ( v10 )
{
LABEL_10:
v14 = BN_num_bits(*(_DWORD **)(a1 + 36));
v15 = v14 + 7;
if ( v14 + 7 < 0 )
v15 = v14 + 14;
v16 = v15 >> 3;
if ( v10 == 2 )
v17 = v16 + 1;
else
v17 = 2 * v16;
if ( v10 != 2 )
++v17;
if ( v17 != a4 )
{
ERR_put_error(16, 103, 102, "crypto/ec/ecp_oct.c", 317);
return 0;
}
if ( a5 )
{
v21 = 0;
}
else
{
v20 = BN_CTX_new(v14);
v6 = v20;
if ( !v20 )
return 0;
v21 = v20;
}
BN_CTX_start(v6);
v18 = (int *)BN_CTX_get(v6);
v22 = (int *)BN_CTX_get(v6);
if ( v22 && BN_bin2bn(a3 + 1, v16, v18) )
{
if ( BN_ucmp(v18, *(int **)(a1 + 36)) < 0 )
{
if ( v10 == 2 )
{
v19 = EC_POINT_set_compressed_coordinates_GFp(a1, a2) != 0;
goto LABEL_26;
}
if ( BN_bin2bn(&a3[v16 + 1], v16, v22) )
{
if ( BN_ucmp(v22, *(int **)(a1 + 36)) >= 0 )
{
ERR_put_error(16, 103, 102, "crypto/ec/ecp_oct.c", 348);
v19 = 0;
}
else if ( v10 != 6 || BN_is_odd((int)v22) == v9 )
{
v19 = EC_POINT_set_affine_coordinates_GFp(a1, a2) != 0;
}
else
{
ERR_put_error(16, 103, 102, "crypto/ec/ecp_oct.c", 353);
v19 = 0;
}
goto LABEL_26;
}
}
else
{
ERR_put_error(16, 103, 102, "crypto/ec/ecp_oct.c", 336);
}
}
v19 = 0;
LABEL_26:
BN_CTX_end(v6);
BN_CTX_free(v21);
return v19;
}
if ( a4 == 1 )
return EC_POINT_set_to_infinity(a1, a2);
ERR_put_error(16, 103, 102, "crypto/ec/ecp_oct.c", 304);
return 0;
}