//
// sub_D39A90 from 0xd39a90 to 0xd39cc8 (568 bytes)
//
// 2 xrefs:
// > ssl_cert_new @ 0xd39e64
// > ssl_cert_new @ 0xd39e70
//
// 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 sub_D39A90(__int64 a1, __int64 a2, int a3, int a4, int a5, _DWORD *a6)
{
int security_level; // w1
int v8; // w2
int v9; // w3
int v10; // w4
_DWORD *v11; // x5
__int64 result; // x0
int v13; // w6
int v14; // w2
int v15; // w2
if ( a2 )
{
security_level = SSL_CTX_get_security_level(a2);
v8 = a3;
v9 = a4;
v10 = a5;
v11 = a6;
}
else
{
security_level = SSL_get_security_level();
v11 = a6;
v10 = a5;
v9 = a4;
v8 = a3;
}
if ( security_level <= 0 )
return v8 != 262151 || v9 > 79;
if ( security_level <= 5 )
{
v13 = *(_DWORD *)&aP_0[4 * security_level - 4];
if ( v8 == 15 )
return security_level == 1;
if ( v8 <= 15 )
{
if ( v8 != 9 )
{
if ( v8 == 10 )
return security_level <= 2;
return v9 >= v13;
}
LABEL_33:
v15 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 192LL) + 104LL);
result = v15 & 8;
if ( (v15 & 8) != 0 )
return security_level <= 3 || v10 <= 65277 && v10 != 256;
if ( security_level <= 1 || v10 > 768 )
{
if ( security_level <= 2 )
return security_level <= 3 || v10 > 770;
result = 0;
if ( v10 > 769 )
return security_level <= 3 || v10 > 770;
}
return result;
}
if ( (unsigned int)(v8 - 65537) > 2 )
return v9 >= v13;
}
else
{
if ( v8 == 15 )
return 0;
if ( v8 <= 15 )
{
if ( v8 != 9 )
{
if ( v8 == 10 )
return 0;
goto LABEL_29;
}
security_level = 5;
goto LABEL_33;
}
if ( (unsigned int)(v8 - 65537) > 2 )
{
LABEL_29:
v13 = 256;
return v9 >= v13;
}
v13 = 256;
security_level = 5;
}
result = 0;
if ( v9 >= v13 && (v11[6] & 4) == 0 )
{
v14 = v11[8];
if ( (v14 & 1) == 0 && (v13 <= 160 || (v14 & 2) == 0) )
{
if ( security_level == 1 )
{
return 1;
}
else
{
if ( v11[7] == 4 )
return 0;
result = 1;
if ( security_level != 2 )
return (v11[5] & 6) != 0;
}
}
}
return result;
}