//
// tls1_check_curve from 0xd557a4 to 0xd5596c (456 bytes)
//
// 2 xrefs:
// > tls_process_key_exchange @ 0xd4b5b0
// > ??> @ 0x83100
//
// 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 tls1_check_curve(_QWORD *a1, _BYTE *a2, unsigned __int64 a3)
{
bool v3; // zf
int v6; // w1
int v7; // w3
unsigned __int64 v8; // x2
unsigned __int8 *v9; // x3
unsigned __int64 v10; // x1
int v11; // w5
int v12; // w5
v3 = a3 == 3;
LODWORD(a3) = 0;
if ( !v3 || *a2 != 3 )
return (unsigned int)a3;
v6 = *(_DWORD *)(a1[41] + 28LL) & 0x30000;
if ( v6 )
{
v7 = *(_DWORD *)(*(_QWORD *)(a1[18] + 552LL) + 16LL);
if ( a2[1] )
return (unsigned int)a3;
if ( v7 == 50380843 )
{
if ( a2[2] != 23 )
return (unsigned int)a3;
}
else if ( v7 != 50380844 || a2[2] != 24 )
{
return (unsigned int)a3;
}
switch ( v6 )
{
case 131072:
v8 = 2;
v9 = (unsigned __int8 *)&unk_F62ED2;
goto LABEL_13;
case 196608:
v8 = 4;
v9 = (unsigned __int8 *)&unk_F62ED0;
goto LABEL_13;
case 65536:
v8 = 2;
v9 = (unsigned __int8 *)&unk_F62ED0;
goto LABEL_13;
}
}
v9 = (unsigned __int8 *)a1[84];
v8 = a1[83];
if ( v9 )
{
if ( (v8 & 1) != 0 )
{
ERR_put_error(20, 338, 68, "ssl/t1_lib.c", 291);
LODWORD(a3) = 0;
return (unsigned int)a3;
}
LABEL_13:
a3 = v8 >> 1;
if ( !a3 )
return (unsigned int)a3;
goto LABEL_14;
}
a3 = 4;
v9 = (unsigned __int8 *)&unk_F62EC0;
LABEL_14:
v10 = 0;
while ( 1 )
{
++v10;
if ( *v9 == (unsigned __int8)a2[1] )
{
v11 = (unsigned __int8)a2[2];
if ( v11 == v9[1] )
break;
}
v9 += 2;
if ( v10 >= a3 )
{
LODWORD(a3) = 0;
return (unsigned int)a3;
}
}
LODWORD(a3) = 1;
if ( !a2[1] )
{
v12 = v11 - 1;
LODWORD(a3) = 0;
if ( (unsigned __int8)v12 <= 0x1Cu )
return ssl_security((__int64)a1, 0x20006u, dword_F62ED8[3 * v12 + 1], dword_F62ED8[3 * v12], (__int64)(a2 + 1));
}
return (unsigned int)a3;
}