//
// asn1_valid_host from 0xfe5934 to 0xfe5b18 (484 bytes)
//
// 2 xrefs:
// > NAME_CONSTRAINTS_check_CN @ 0x107d364
// > ??> @ 0x1042f0
//
// 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:39 +0000
//
__int64 __fastcall asn1_valid_host(__int64 a1)
{
int v1; // w3
int v2; // w5
unsigned __int8 *v3; // x1
__int64 result; // x0
int v5; // w6
unsigned __int16 v6; // w7
int v7; // w3
int v8; // w2
int v9; // w0
int v10; // w6
int v11; // w7
int v12; // w2
int v13; // w6
int v14; // w4
int v15; // w4
v1 = *(_DWORD *)(a1 + 4);
v2 = *(_DWORD *)a1;
v3 = *(unsigned __int8 **)(a1 + 8);
if ( (unsigned int)(v1 - 1) > 0x1D )
{
result = 0;
if ( !v2 )
return result;
v5 = 255;
if ( v2 <= 0 )
return 1;
goto LABEL_11;
}
result = 0;
LOBYTE(v5) = byte_11F81C0[v1];
if ( !v2 )
return result;
v5 = (unsigned __int8)v5;
if ( !(_BYTE)v5 )
{
v5 = 1;
if ( v2 <= 0 )
return 1;
LABEL_11:
v6 = 0;
v7 = 0;
while ( 1 )
{
v9 = *v3++;
if ( (v9 & 0x80) != 0 )
break;
v8 = *(unsigned __int16 *)&byte_11F81C0[2 * v9 + 64];
result = v8 & 0xFFFF9000;
if ( (v8 & 0xFFFF9000) == 0 )
{
if ( !v7 )
return 0;
if ( v2 - 1 == v7 )
return result;
if ( (v8 & 0x6000) == 0 )
return 0;
if ( (v6 & 0x6000) != 0 && (((unsigned __int16)v8 | v6) & 0x2000) != 0 )
return result;
}
v7 += v5;
v6 = v8;
if ( v2 <= v7 )
return 1;
}
return 0;
}
if ( v2 <= 0 )
return 1;
if ( (unsigned __int8)v5 != 4 )
{
if ( (unsigned __int8)v5 == 2 )
{
v13 = 0;
while ( !*v3 )
{
v14 = v3[1];
v3 += 2;
if ( (v14 & 0x80) != 0 )
return 0;
v15 = *(unsigned __int16 *)&byte_11F81C0[2 * v14 + 64];
if ( (v15 & 0xFFFF9000) == 0
&& (!v13
|| v2 - 1 == v13
|| (v15 & 0x6000) == 0
|| (result & 0x6000) != 0 && (((unsigned __int16)v15 | (unsigned __int16)result) & 0x2000) != 0) )
{
return 0;
}
v13 += 2;
LOWORD(result) = v15;
if ( v2 <= v13 )
return 1;
}
return 0;
}
goto LABEL_11;
}
v10 = 0;
while ( !*v3 )
{
if ( v3[1] )
return 0;
if ( v3[2] )
return 0;
v11 = v3[3];
if ( (v11 & 0x80) != 0 )
return 0;
v3 += 4;
v12 = *(unsigned __int16 *)&byte_11F81C0[2 * v11 + 64];
if ( (v12 & 0xFFFF9000) == 0
&& (!v10
|| v2 - 1 == v10
|| (v12 & 0x6000) == 0
|| (result & 0x6000) != 0 && ((v12 | (unsigned int)result) & 0x2000) != 0) )
{
return 0;
}
v10 += 4;
if ( v2 <= v10 )
return 1;
LODWORD(result) = *(unsigned __int16 *)&byte_11F81C0[2 * v11 + 64];
}
return 0;
}