//
// DH_new_method from 0x1006168 to 0x1006318 (432 bytes)
//
// 2 xrefs:
// > DH_new @ 0x100631c
// > ??> @ 0xfe350
//
// 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:15:56 +0000
//
__int64 __fastcall DH_new_method(__int64 a1)
{
__int64 v2; // x19
__int64 v3; // x0
__int64 v4; // x21
char **default_method; // x0
__int64 default_DH; // x0
__int64 DH; // x0
unsigned int (__fastcall *v9)(__int64); // x1
v2 = CRYPTO_zalloc(144, "crypto/dh/dh_lib.c", 57);
if ( !v2 )
{
v4 = 0;
ERR_put_error(5, 105, 65, "crypto/dh/dh_lib.c", 60);
return v4;
}
*(_DWORD *)(v2 + 104) = 1;
v3 = CRYPTO_THREAD_lock_new(1);
*(_QWORD *)(v2 + 136) = v3;
v4 = v3;
if ( !v3 )
{
ERR_put_error(5, 105, 65, "crypto/dh/dh_lib.c", 67);
CRYPTO_free(v2, "crypto/dh/dh_lib.c", 68);
return v4;
}
default_method = DH_get_default_method();
*(_QWORD *)(v2 + 120) = default_method;
*(_DWORD *)(v2 + 48) = *((_DWORD *)default_method + 12);
if ( a1 )
{
if ( !(unsigned int)ENGINE_init(a1) )
{
ERR_put_error(5, 105, 38, "crypto/dh/dh_lib.c", 77);
goto LABEL_8;
}
*(_QWORD *)(v2 + 128) = a1;
default_DH = a1;
}
else
{
default_DH = ENGINE_get_default_DH();
*(_QWORD *)(v2 + 128) = default_DH;
if ( !default_DH )
{
DH = *(_QWORD *)(v2 + 120);
goto LABEL_7;
}
}
DH = ENGINE_get_DH(default_DH);
*(_QWORD *)(v2 + 120) = DH;
if ( !DH )
{
ERR_put_error(5, 105, 38, "crypto/dh/dh_lib.c", 86);
goto LABEL_8;
}
LABEL_7:
*(_DWORD *)(v2 + 48) = *(_DWORD *)(DH + 48);
if ( !(unsigned int)CRYPTO_new_ex_data(6, v2, v2 + 112) )
goto LABEL_8;
v9 = *(unsigned int (__fastcall **)(__int64))(*(_QWORD *)(v2 + 120) + 32LL);
if ( v9 )
{
v4 = v2;
if ( v9(v2) )
return v4;
ERR_put_error(5, 105, 70, "crypto/dh/dh_lib.c", 98);
LABEL_8:
v4 = 0;
DH_free(v2);
return v4;
}
return v2;
}