//
// ec_GF2m_simple_oct2point from 0xa9e054 to 0xa9e390 (828 bytes)
//
// 2 xrefs:
// > EC_POINT_oct2point @ 0xa020b4
// > ??> @ 0x7b69c
//
// 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 ec_GF2m_simple_oct2point(int **a1, _DWORD *a2, unsigned __int8 *a3, int a4, int ***a5)
{
int ***v6; // r5
int v8; // r2
int v9; // r8
unsigned int v10; // r4
int degree; // r0
int v15; // r7
int v16; // r7
int v17; // r2
int *v18; // r9
_BOOL4 v19; // r9
int ***v20; // r0
void **v21; // [sp+Ch] [bp-10h]
int *v22; // [sp+10h] [bp-Ch]
int **v23; // [sp+14h] [bp-8h]
v6 = a5;
if ( !a4 )
{
ERR_put_error(16, 160, 100, (int)"crypto/ec/ec2_oct.c", 261);
return 0;
}
v8 = *a3;
v9 = v8 & 1;
v10 = v8 & 0xFFFFFFFE;
if ( (v8 & 0xF8) != 0 )
{
ERR_put_error(16, 160, 102, (int)"crypto/ec/ec2_oct.c", 270);
return 0;
}
if ( (v8 & 0xFFFFFFFA) != 0 )
goto LABEL_10;
if ( (v8 & 1) != 0 )
{
ERR_put_error(16, 160, 102, (int)"crypto/ec/ec2_oct.c", 274);
return 0;
}
if ( v10 )
{
LABEL_10:
degree = EC_GROUP_get_degree((int)a1);
v15 = degree + 7;
if ( degree + 7 < 0 )
v15 = degree + 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, 160, 102, (int)"crypto/ec/ec2_oct.c", 293);
return 0;
}
if ( a5 )
{
v21 = nullptr;
}
else
{
v20 = (int ***)BN_CTX_new();
v6 = v20;
if ( !v20 )
return 0;
v21 = (void **)v20;
}
BN_CTX_start((int)v6);
v18 = (int *)BN_CTX_get(v6);
v22 = (int *)BN_CTX_get(v6);
v23 = BN_CTX_get(v6);
if ( !v23 || !BN_bin2bn(a3 + 1, v16, v18) )
goto LABEL_25;
if ( BN_ucmp(v18, a1[9]) >= 0 )
{
ERR_put_error(16, 160, 102, (int)"crypto/ec/ec2_oct.c", 313);
LABEL_25:
v19 = 0;
LABEL_26:
BN_CTX_end(v6);
BN_CTX_free(v21);
return v19;
}
if ( v10 == 2 )
{
v19 = EC_POINT_set_compressed_coordinates_GF2m((int)a1, a2) != 0;
goto LABEL_26;
}
if ( !BN_bin2bn(&a3[v16 + 1], v16, v22) )
goto LABEL_25;
if ( BN_ucmp(v22, a1[9]) >= 0 )
{
ERR_put_error(16, 160, 102, (int)"crypto/ec/ec2_oct.c", 325);
v19 = 0;
goto LABEL_26;
}
if ( v10 == 6 )
{
if ( !((int (__fastcall *)(int **, int **, int *, int *, int ***))(*a1)[36])(a1, v23, v22, v18, v6) )
goto LABEL_25;
if ( BN_is_odd((int)v23) != v9 )
{
ERR_put_error(16, 160, 102, (int)"crypto/ec/ec2_oct.c", 332);
v19 = 0;
goto LABEL_26;
}
}
v19 = EC_POINT_set_affine_coordinates_GF2m((int)a1, a2) != 0;
goto LABEL_26;
}
if ( a4 == 1 )
return EC_POINT_set_to_infinity((int)a1, a2);
ERR_put_error(16, 160, 102, (int)"crypto/ec/ec2_oct.c", 280);
return 0;
}