//
// tls1_shared_curve from 0x7ae314 to 0x7ae6bc (936 bytes)
//
// 4 xrefs:
// > ssl3_ctrl @ 0x78f8b8
// > tls_construct_server_key_exchange @ 0x7aaabc
// > tls1_check_ec_tmp_key @ 0x7ae998
// > ??> @ 0x5afcc
//
// 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
//
int __fastcall tls1_shared_curve(_DWORD *a1, int a2)
{
int v2; // r10
int v3; // r3
int v4; // r2
unsigned int v5; // r12
char *v6; // r11
int v7; // r12
int v8; // r2
unsigned int v9; // r2
unsigned __int8 *v10; // r5
int v11; // r2
int v13; // r2
unsigned int v14; // r12
int v15; // r1
int v16; // r1
int v17; // r2
int v18; // r7
unsigned int v19; // r8
char *v20; // r6
int v21; // r9
char *v22; // r12
unsigned int v23; // r11
char *v24; // r4
int v25; // r2
int v27; // r2
unsigned int v28; // r12
int v29; // r0
char *v30; // [sp+Ch] [bp-10h]
if ( !a1[7] )
return -1;
v2 = a2;
if ( a2 == -2 )
{
if ( (*(_DWORD *)(a1[50] + 16) & 0x30000) != 0 )
{
v11 = *(_DWORD *)(*(_DWORD *)(a1[26] + 528) + 8);
if ( v11 == 50380843 )
return 415;
if ( v11 == 50380844 )
return 715;
return 0;
}
v3 = a1[75];
v2 = v3 & 0x400000;
if ( (v3 & 0x400000) != 0 )
{
v27 = a1[60];
v28 = *(_DWORD *)(v27 + 208);
v6 = *(char **)(v27 + 212);
v2 = v28 & 1;
if ( (v28 & 1) != 0 )
goto LABEL_45;
v7 = v28 >> 1;
goto LABEL_41;
}
goto LABEL_18;
}
v3 = a1[75];
if ( (v3 & 0x400000) == 0 )
{
v13 = *(_DWORD *)(a1[50] + 16) & 0x30000;
switch ( v13 )
{
case 131072:
v14 = 2;
v6 = (char *)&unk_A0CB4A;
goto LABEL_47;
case 196608:
v14 = 4;
v6 = (char *)&unk_A0CB48;
goto LABEL_47;
case 65536:
v14 = 2;
v6 = (char *)&unk_A0CB48;
goto LABEL_47;
}
LABEL_18:
v6 = (char *)a1[105];
v14 = a1[104];
if ( !v6 )
{
v7 = 4;
v6 = (char *)&unk_A0CB40;
LABEL_20:
v15 = a1[60];
v9 = *(_DWORD *)(v15 + 208);
v10 = *(unsigned __int8 **)(v15 + 212);
v16 = v9 & 1;
goto LABEL_21;
}
if ( (v14 & 1) != 0 )
goto LABEL_45;
LABEL_47:
v7 = v14 >> 1;
goto LABEL_20;
}
v4 = a1[60];
v5 = *(_DWORD *)(v4 + 208);
v6 = *(char **)(v4 + 212);
if ( (v5 & 1) != 0 )
goto LABEL_45;
v7 = v5 >> 1;
v8 = *(_DWORD *)(a1[50] + 16) & 0x30000;
switch ( v8 )
{
case 131072:
v9 = 2;
v10 = (unsigned __int8 *)&unk_A0CB4A;
goto LABEL_22;
case 196608:
v9 = 4;
v10 = (unsigned __int8 *)&unk_A0CB48;
goto LABEL_22;
case 65536:
v9 = 2;
v10 = (unsigned __int8 *)&unk_A0CB48;
LABEL_22:
v17 = v9 >> 1;
if ( v7 || (v3 & 0x400000) == 0 )
{
if ( !v17 )
{
if ( (v3 & 0x400000) != 0 )
{
v18 = 0;
LABEL_52:
if ( v2 == -1 )
return v18;
else
return 0;
}
v17 = 29;
v10 = (unsigned __int8 *)&unk_A0CCA8;
}
}
else
{
if ( !v17 )
{
v18 = 0;
goto LABEL_52;
}
v7 = 29;
v6 = (char *)&unk_A0CCA8;
}
goto LABEL_27;
}
LABEL_41:
v10 = (unsigned __int8 *)a1[105];
v9 = a1[104];
if ( v10 )
{
v16 = a1[104] & 1;
LABEL_21:
if ( !v16 )
goto LABEL_22;
LABEL_45:
ERR_put_error(20, 338, 68, "ssl/t1_lib.c", 291);
return 0;
}
if ( v7 )
{
v17 = 4;
v10 = (unsigned __int8 *)&unk_A0CB40;
}
else
{
v10 = (unsigned __int8 *)&unk_A0CB40;
v7 = 29;
v6 = (char *)&unk_A0CCA8;
v17 = 4;
}
LABEL_27:
v19 = 0;
v20 = &v6[2 * v7 + 2];
v18 = 0;
v21 = v7;
v22 = v6;
v23 = v17;
while ( !v21 )
{
LABEL_55:
++v19;
v10 += 2;
if ( v19 >= v23 )
goto LABEL_52;
}
v24 = v22 + 2;
while ( 1 )
{
if ( (unsigned __int8)*(v24 - 2) == *v10 )
{
v25 = (unsigned __int8)*(v24 - 1);
if ( v25 == v10[1] )
{
if ( *(v24 - 2)
|| (unsigned __int8)(v25 - 1) <= 0x1Cu && (v30 = v22, v29 = ssl_security((int)a1, 131077), v22 = v30, v29) )
{
if ( v2 == v18++ )
return tls1_ec_curve_id2nid(v10[1] | (*v10 << 8), nullptr);
}
}
}
v24 += 2;
if ( v24 == v20 )
goto LABEL_55;
}
}