//
// EC_GROUP_new_by_curve_name from 0x100d404 to 0x100d8dc (1240 bytes)
//
// 5 xrefs:
// > sub_100970C @ 0x1009748
// > EC_GROUP_new_from_ecpkparameters @ 0x100c794
// > EC_KEY_new_by_curve_name @ 0x100ddec
// > sub_10B2654 @ 0x10b2754
// > ??> @ 0x94e10
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:16:00 +0000
//
__int64 __fastcall EC_GROUP_new_by_curve_name(int a1, __int64 a2)
{
__int64 v3; // x2
__int64 v4; // x3
char *v5; // x3
_DWORD *v6; // x21
__int64 (*v7)(void); // x26
__int64 v8; // x23
int v9; // w22
int v10; // s11
_BYTE *v11; // d9
unsigned __int64 *v12; // x28
_BYTE *v13; // x20
unsigned __int64 *v14; // x27
_BYTE *v15; // x25
unsigned __int64 *v16; // x0
__int64 v17; // x24
__int64 v18; // x0
__int64 v19; // x0
__int64 v20; // x20
unsigned __int64 *v21; // x22
unsigned __int64 *v22; // x25
__int64 v23; // d8
__int64 v24; // x26
__int64 v25; // x0
__int64 v27; // x0
unsigned __int64 *v28; // x3
__int64 v29; // x4
_BYTE *v30; // [xsp+98h] [xbp+98h]
if ( a1 <= 0 )
return 0;
v3 = 0;
while ( 1 )
{
v4 = 32 * v3++;
if ( *(_DWORD *)((char *)&unk_15393E8 + v4) == a1 )
break;
if ( v3 == 81 )
goto LABEL_23;
}
v5 = (char *)&unk_15393E8 + v4;
v6 = *((_DWORD **)v5 + 1);
v7 = *((__int64 (**)(void))v5 + 2);
if ( !v6 )
{
if ( v7 )
v25 = ((__int64 (__fastcall *)(void *, __int64, __int64))v7)(&unk_1539000, a2, v3);
else
v25 = 0;
v20 = EC_GROUP_new(v25);
goto LABEL_17;
}
v8 = BN_CTX_new(&unk_1539000, a2, v3);
if ( !v8 )
{
v23 = 0;
v21 = nullptr;
v22 = nullptr;
v17 = 0;
ERR_put_error(16, 175, 65, "crypto/ec/ec_curve.c", 2998);
v14 = nullptr;
v12 = nullptr;
v24 = 0;
v20 = 0;
goto LABEL_21;
}
v9 = v6[2];
v10 = v6[1];
v11 = (char *)v6 + v10 + 16;
v12 = BN_bin2bn(v11, v9, 0);
if ( !v12 || (v13 = &v11[v9], (v14 = BN_bin2bn(v13, v9, 0)) == nullptr) )
{
v14 = nullptr;
goto LABEL_20;
}
v15 = &v13[v9];
v16 = BN_bin2bn(v15, v9, 0);
v17 = (__int64)v16;
if ( !v16 )
{
LABEL_20:
v21 = nullptr;
ERR_put_error(16, 175, 3, "crypto/ec/ec_curve.c", 3011);
v22 = nullptr;
v23 = 0;
v17 = 0;
v24 = 0;
v20 = 0;
goto LABEL_21;
}
if ( !v7 )
{
if ( *v6 == 406 )
{
v20 = EC_GROUP_new_curve_GFp(v12, v14, v16, v8);
if ( v20 )
goto LABEL_27;
v29 = 3024;
}
else
{
v20 = EC_GROUP_new_curve_GF2m(v12, v14, v16, v8);
if ( v20 )
goto LABEL_27;
v29 = 3033;
}
v23 = 0;
v21 = nullptr;
v22 = nullptr;
v24 = 0;
ERR_put_error(16, 175, 16, "crypto/ec/ec_curve.c", v29);
goto LABEL_21;
}
v18 = v7();
v19 = EC_GROUP_new(v18);
v20 = v19;
if ( !v19
|| !(*(unsigned int (__fastcall **)(__int64, unsigned __int64 *, unsigned __int64 *, __int64, __int64))(*(_QWORD *)v19 + 40LL))(
v19,
v12,
v14,
v17,
v8) )
{
v21 = nullptr;
ERR_put_error(16, 175, 16, "crypto/ec/ec_curve.c", 3019);
v22 = nullptr;
v23 = 0;
v24 = 0;
goto LABEL_21;
}
LABEL_27:
v24 = EC_POINT_new(v20);
if ( v24 )
{
v30 = &v15[v9];
v22 = BN_bin2bn(v30, v9, 0);
if ( v22 && (v28 = BN_bin2bn(&v30[v9], v9, 0), (v23 = (__int64)v28) != 0) )
{
if ( (unsigned int)EC_POINT_set_affine_coordinates_GFp(v20, v24, v22, v28, v8) )
{
v21 = BN_bin2bn(&v30[v9 + v9], v9, 0);
if ( v21 && (unsigned int)BN_set_word((__int64)v22, (unsigned int)v6[3]) )
{
if ( (unsigned int)EC_GROUP_set_generator(v20, v24, v21, v22) )
{
if ( !v10 || EC_GROUP_set_seed(v20, &v11[-v10]) )
goto LABEL_22;
ERR_put_error(16, 175, 16, "crypto/ec/ec_curve.c", 3064);
}
else
{
ERR_put_error(16, 175, 16, "crypto/ec/ec_curve.c", 3059);
}
}
else
{
ERR_put_error(16, 175, 3, "crypto/ec/ec_curve.c", 3055);
}
}
else
{
v21 = nullptr;
ERR_put_error(16, 175, 16, "crypto/ec/ec_curve.c", 3050);
}
}
else
{
v21 = nullptr;
ERR_put_error(16, 175, 3, "crypto/ec/ec_curve.c", 3046);
v23 = 0;
}
}
else
{
v23 = 0;
v21 = nullptr;
v22 = nullptr;
ERR_put_error(16, 175, 16, "crypto/ec/ec_curve.c", 3040);
}
LABEL_21:
v27 = v20;
v20 = 0;
EC_GROUP_free(v27);
LABEL_22:
EC_POINT_free(v24);
BN_CTX_free(v8);
BN_free((__int64)v12);
BN_free((__int64)v14);
BN_free(v17);
BN_free((__int64)v21);
BN_free((__int64)v22);
BN_free(v23);
LABEL_17:
if ( v20 )
{
EC_GROUP_set_curve_name(v20, (unsigned int)a1);
return v20;
}
LABEL_23:
ERR_put_error(16, 174, 129, "crypto/ec/ec_curve.c", 3100);
return 0;
}