//
// EC_GROUP_copy from 0x7ea8c0 to 0x7eab10 (592 bytes)
//
// 3 xrefs:
// > EC_KEY_copy @ 0x7e8b64
// > EC_GROUP_dup @ 0x7eab44
// > ??> @ 0x6167c
//
// 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_copy(int *a1, int a2)
{
int *v5; // r0
int *v6; // r1
_DWORD *v7; // r0
_DWORD *v8; // r1
int v9; // r6
int v10; // r2
int v11; // r3
void *v12; // r0
if ( *(_DWORD *)(*a1 + 20) )
{
if ( *a1 != *(_DWORD *)a2 )
{
ERR_put_error(16, 106, 101, "crypto/ec/ec_lib.c", 137);
return 0;
}
if ( a1 != (int *)a2 )
{
a1[23] = *(_DWORD *)(a2 + 92);
if ( *(_DWORD *)(a2 + 92) == 5 )
a1[24] = EC_ec_pre_comp_dup(*(_DWORD *)(a2 + 96));
else
a1[24] = 0;
v5 = (int *)a1[22];
if ( *(_DWORD *)(a2 + 88) )
{
if ( v5 )
{
v6 = *(int **)(a2 + 88);
}
else
{
v5 = BN_MONT_CTX_new();
a1[22] = (int)v5;
if ( !v5 )
return 0;
v6 = *(int **)(a2 + 88);
}
if ( !BN_MONT_CTX_copy(v5, v6) )
return 0;
}
else
{
BN_MONT_CTX_free(v5);
a1[22] = 0;
}
v7 = (_DWORD *)a1[1];
if ( *(_DWORD *)(a2 + 4) )
{
if ( v7 )
{
v8 = *(_DWORD **)(a2 + 4);
}
else
{
v7 = EC_POINT_new(a1);
a1[1] = (int)v7;
if ( !v7 )
return 0;
v8 = *(_DWORD **)(a2 + 4);
}
if ( !EC_POINT_copy(v7, v8) )
return 0;
}
else
{
EC_POINT_clear_free((int)v7);
a1[1] = 0;
}
if ( (**(_DWORD **)a2 & 2) == 0 && (!BN_copy(a1[2], *(_DWORD *)(a2 + 8)) || !BN_copy(a1[3], *(_DWORD *)(a2 + 12))) )
return 0;
v9 = *(_DWORD *)(a2 + 28);
v10 = *(_DWORD *)(a2 + 20);
v11 = *(_DWORD *)(a2 + 24);
a1[4] = *(_DWORD *)(a2 + 16);
a1[5] = v10;
a1[6] = v11;
if ( !v9 )
{
CRYPTO_free(a1[7], "crypto/ec/ec_lib.c", 218);
a1[7] = 0;
a1[8] = 0;
return (*(int (__fastcall **)(int *, int))(*a1 + 20))(a1, a2);
}
CRYPTO_free(a1[7], "crypto/ec/ec_lib.c", 210);
v12 = (void *)CRYPTO_malloc(*(_DWORD *)(a2 + 32), "crypto/ec/ec_lib.c", 211);
a1[7] = (int)v12;
if ( v12 && memcpy(v12, *(const void **)(a2 + 28), *(_DWORD *)(a2 + 32)) )
{
a1[8] = *(_DWORD *)(a2 + 32);
return (*(int (__fastcall **)(int *, int))(*a1 + 20))(a1, a2);
}
return 0;
}
return 1;
}
else
{
ERR_put_error(16, 106, 66, "crypto/ec/ec_lib.c", 133);
return 0;
}
}