//
// EC_GROUP_cmp from 0x7eb43c to 0x7eb6a8 (620 bytes)
//
// 2 xrefs:
// > sub_7E4790 @ 0x7e47c8
// > ??> @ 0x6115c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall EC_GROUP_cmp(int *a1, int a2, int a3)
{
int v6; // r0
int field_type; // r7
int v8; // r0
int v10; // r7
int *v11; // r8
int *v12; // r9
int *v13; // r10
int *v14; // r11
_BOOL4 v15; // r5
int curve_name; // r7
_DWORD *v17; // r8
_DWORD *v18; // r0
int *v19; // r8
int *v20; // r9
int *v21; // r6
int v22; // r0
bool v23; // zf
int *v24; // r5
int v25; // r0
int *v26; // [sp+8h] [bp-Ch]
int *v27; // [sp+Ch] [bp-8h]
v6 = EC_GROUP_method_of((int)a1);
field_type = EC_METHOD_get_field_type(v6);
v8 = EC_GROUP_method_of(a2);
if ( field_type != EC_METHOD_get_field_type(v8) )
return 1;
if ( EC_GROUP_get_curve_name((int)a1) )
{
if ( EC_GROUP_get_curve_name(a2) )
{
curve_name = EC_GROUP_get_curve_name((int)a1);
if ( curve_name != EC_GROUP_get_curve_name(a2) )
return 1;
}
}
v10 = *(_DWORD *)*a1 & 2;
if ( v10 )
return 0;
if ( !a3 )
{
v25 = BN_CTX_new();
a3 = v25;
if ( !v25 )
return -1;
v10 = v25;
}
BN_CTX_start(a3);
v11 = (int *)BN_CTX_get(a3);
v12 = (int *)BN_CTX_get(a3);
v13 = (int *)BN_CTX_get(a3);
v14 = (int *)BN_CTX_get(a3);
v26 = (int *)BN_CTX_get(a3);
v27 = (int *)BN_CTX_get(a3);
if ( v27 )
{
if ( !(*(int (__fastcall **)(int *, int *, int *, int *, int))(*a1 + 28))(a1, v11, v12, v13, a3) )
goto LABEL_8;
if ( !(*(int (__fastcall **)(int, int *, int *, int *, int))(*(_DWORD *)a2 + 28))(a2, v14, v26, v27, a3) )
goto LABEL_8;
if ( BN_cmp(v11, v14) )
goto LABEL_8;
if ( BN_cmp(v12, v26) )
goto LABEL_8;
if ( BN_cmp(v13, v27) )
goto LABEL_8;
v17 = (_DWORD *)EC_GROUP_get0_generator((int)a1);
v18 = (_DWORD *)EC_GROUP_get0_generator(a2);
if ( EC_POINT_cmp(a1, v17, v18) )
goto LABEL_8;
v19 = (int *)EC_GROUP_get0_order((int)a1);
v20 = (int *)EC_GROUP_get0_order(a2);
v21 = (int *)EC_GROUP_get0_cofactor((int)a1);
v22 = EC_GROUP_get0_cofactor(a2);
v23 = v19 == nullptr;
if ( v19 )
v23 = v20 == nullptr;
v24 = (int *)v22;
if ( !v23 )
{
if ( !BN_cmp(v19, v20) )
{
v15 = BN_cmp(v21, v24) != 0;
goto LABEL_9;
}
LABEL_8:
v15 = 1;
LABEL_9:
BN_CTX_end(a3);
BN_CTX_free(v10);
return v15;
}
}
BN_CTX_end(a3);
BN_CTX_free(v10);
return -1;
}