//
// ssl_get_auto_dh from 0xfd9c7c to 0xfd9d98 (284 bytes)
//
// 2 xrefs:
// > tls_construct_server_key_exchange @ 0xfd0180
// > ??> @ 0x4bda8
//
// 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:34 +0000
//
__int64 __fastcall ssl_get_auto_dh(__int64 a1)
{
__int64 v1; // x1
__int64 server_send_pkey; // x0
int v4; // w0
int v5; // w20
__int64 v6; // x19
__int64 v7; // x0
__int64 v8; // x21
__int64 v9; // x20
if ( *(_DWORD *)(*(_QWORD *)(a1 + 328) + 24LL) == 2 )
return DH_get_1024_160();
v1 = *(_QWORD *)(*(_QWORD *)(a1 + 144) + 552LL);
if ( (*(_DWORD *)(v1 + 24) & 0x14) != 0 )
{
if ( *(_DWORD *)(v1 + 60) != 256 )
return DH_get_1024_160();
v5 = 128;
goto LABEL_9;
}
server_send_pkey = ssl_get_server_send_pkey(a1);
v4 = EVP_PKEY_security_bits(*(_QWORD *)(server_send_pkey + 8));
v5 = v4;
if ( v4 > 127 )
{
LABEL_9:
v6 = DH_new();
if ( !v6 )
return v6;
v7 = BN_new();
v8 = v7;
if ( v7 )
BN_set_word(v7, 2);
v9 = v5 <= 191 ? BN_get_rfc3526_prime_3072(0) : BN_get_rfc3526_prime_8192(0);
if ( v9 && v8 && (unsigned int)DH_set0_pqg(v6, v9, 0, v8) )
return v6;
DH_free(v6);
BN_free(v9);
BN_free(v8);
return 0;
}
if ( v4 <= 111 )
return DH_get_1024_160();
return DH_get_2048_224();
}