//
// DH_new_method from 0x9f51c4 to 0x9f537c (440 bytes)
//
// 2 xrefs:
// > DH_new @ 0x9f538c
// > ??> @ 0x7a58c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:07:31 +0000
//
_DWORD *__fastcall DH_new_method(int a1)
{
int v2; // r0
_DWORD *v3; // r4
int v4; // r6
char **default_method; // r0
int default_DH; // r0
int DH; // r0
_DWORD *result; // r0
int (__fastcall *v9)(_DWORD *); // r3
v2 = CRYPTO_zalloc(76, "crypto/dh/dh_lib.c", 57);
v3 = (_DWORD *)v2;
if ( !v2 )
{
ERR_put_error(5, 105, 65, "crypto/dh/dh_lib.c", 60);
return nullptr;
}
*(_DWORD *)(v2 + 56) = 1;
v4 = CRYPTO_THREAD_lock_new(v2);
v3[18] = v4;
if ( !v4 )
{
ERR_put_error(5, 105, 65, "crypto/dh/dh_lib.c", 67);
CRYPTO_free(v3, "crypto/dh/dh_lib.c", 68);
return nullptr;
}
default_method = DH_get_default_method();
v3[7] = default_method[6];
v3[16] = default_method;
if ( a1 )
{
if ( !ENGINE_init(a1) )
{
ERR_put_error(5, 105, 38, "crypto/dh/dh_lib.c", 77);
LABEL_9:
DH_free((int)v3);
return nullptr;
}
v3[17] = a1;
default_DH = a1;
}
else
{
default_DH = ENGINE_get_default_DH();
v3[17] = default_DH;
if ( !default_DH )
{
DH = v3[16];
goto LABEL_8;
}
}
DH = ENGINE_get_DH(default_DH);
v3[16] = DH;
if ( !DH )
{
ERR_put_error(5, 105, 38, "crypto/dh/dh_lib.c", 86);
goto LABEL_9;
}
LABEL_8:
v3[7] = *(_DWORD *)(DH + 24);
if ( !CRYPTO_new_ex_data(6, v3, v3 + 15) )
goto LABEL_9;
result = v3;
v9 = *(int (__fastcall **)(_DWORD *))(v3[16] + 16);
if ( v9 )
{
if ( v9(v3) )
return v3;
ERR_put_error(5, 105, 70, "crypto/dh/dh_lib.c", 98);
goto LABEL_9;
}
return result;
}