//
// EC_KEY_new_method from 0xd90ae8 to 0xd90ca8 (448 bytes)
//
// 3 xrefs:
// > EC_KEY_new @ 0xd8f99c
// > EC_KEY_dup @ 0xd8fce0
// > ??> @ 0x62be0
//
// 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
//
__int64 __fastcall EC_KEY_new_method(__int64 a1)
{
__int64 v2; // x19
__int64 v3; // x0
__int64 v4; // x21
__int64 default_EC; // x0
__int64 EC; // x0
unsigned int (__fastcall *v7)(__int64); // x1
v2 = CRYPTO_zalloc(80, "crypto/ec/ec_kmeth.c", 75);
if ( !v2 )
{
v4 = 0;
ERR_put_error(16, 245, 65, "crypto/ec/ec_kmeth.c", 78);
return v4;
}
*(_DWORD *)(v2 + 56) = 1;
v3 = CRYPTO_THREAD_lock_new(1);
*(_QWORD *)(v2 + 72) = v3;
v4 = v3;
if ( !v3 )
{
ERR_put_error(16, 245, 65, "crypto/ec/ec_kmeth.c", 85);
CRYPTO_free(v2, "crypto/ec/ec_kmeth.c", 86);
return v4;
}
*(_QWORD *)v2 = EC_KEY_get_default_method();
if ( a1 )
{
if ( !(unsigned int)ENGINE_init(a1) )
{
ERR_put_error(16, 245, 38, "crypto/ec/ec_kmeth.c", 94);
goto LABEL_13;
}
*(_QWORD *)(v2 + 8) = a1;
default_EC = a1;
goto LABEL_6;
}
default_EC = ENGINE_get_default_EC();
*(_QWORD *)(v2 + 8) = default_EC;
if ( default_EC )
{
LABEL_6:
EC = ENGINE_get_EC(default_EC);
*(_QWORD *)v2 = EC;
if ( !EC )
{
ERR_put_error(16, 245, 38, "crypto/ec/ec_kmeth.c", 103);
goto LABEL_13;
}
}
*(_DWORD *)(v2 + 16) = 1;
*(_DWORD *)(v2 + 52) = 4;
if ( (unsigned int)CRYPTO_new_ex_data(8, v2, v2 + 64) )
{
v7 = *(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v2 + 16LL);
if ( !v7 )
return v2;
v4 = v2;
if ( v7(v2) )
return v4;
ERR_put_error(16, 245, 70, "crypto/ec/ec_kmeth.c", 117);
}
LABEL_13:
EC_KEY_free(v2);
return 0;
}