//
// SSL_CTX_use_serverinfo from 0xd4587c to 0xd45b18 (668 bytes)
//
// 2 xrefs:
// > SSL_CTX_use_serverinfo_file @ 0xd45cc8
// > ??> @ 0x55db8
//
// 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 SSL_CTX_use_serverinfo(__int64 a1, unsigned __int8 *a2, unsigned __int64 a3)
{
unsigned __int8 *v3; // x21
size_t v5; // x19
unsigned __int64 v6; // x3
unsigned __int64 v7; // x2
unsigned __int64 v8; // x3
unsigned __int8 *v9; // x2
unsigned __int64 v10; // x4
unsigned __int64 v11; // x3
__int64 v12; // x20
void *v13; // x0
_QWORD *v14; // x0
__int64 v15; // x9
unsigned __int16 *v16; // x4
__int64 v17; // x1
__int64 v18; // x6
size_t v19; // x19
size_t v20; // x4
v3 = a2;
v5 = a3;
if ( a2 == nullptr || a3 == 0 || !a1 )
{
ERR_put_error(20, 336, 67, "ssl/ssl_rsa.c", 847);
return 0;
}
if ( a3 <= 3 )
goto LABEL_24;
v6 = a3 - 4;
v7 = a2[3] + (a2[2] << 8);
if ( v6 < v7 )
goto LABEL_24;
v8 = v6 - v7;
v9 = &a2[v7 + 4];
if ( v8 )
{
while ( 1 )
{
v10 = v8 - 4;
if ( v8 <= 3 )
break;
v11 = v9[3] + (v9[2] << 8);
v9 += v11 + 4;
if ( v11 > v10 )
break;
v8 = v10 - v11;
if ( !v8 )
goto LABEL_9;
}
LABEL_24:
ERR_put_error(20, 336, 388, "ssl/ssl_rsa.c", 851);
return 0;
}
LABEL_9:
v12 = **(_QWORD **)(a1 + 288);
if ( !v12 )
{
ERR_put_error(20, 336, 68, "ssl/ssl_rsa.c", 855);
return 0;
}
v13 = (void *)CRYPTO_realloc(*(_QWORD *)(v12 + 24), v5, "ssl/ssl_rsa.c", 859);
if ( !v13 )
{
ERR_put_error(20, 336, 65, "ssl/ssl_rsa.c", 861);
return 0;
}
*(_QWORD *)(**(_QWORD **)(a1 + 288) + 24LL) = v13;
memcpy(v13, v3, v5);
v14 = *(_QWORD **)(a1 + 288);
*(_QWORD *)(*v14 + 32LL) = v5;
while ( 1 )
{
v15 = v14[54];
v16 = (unsigned __int16 *)v14[53];
v17 = v3[1] + (*v3 << 8);
if ( v15 )
{
v18 = 0;
if ( (_DWORD)v17 == *v16 )
goto LABEL_18;
while ( 1 )
{
++v18;
v16 += 24;
if ( v18 == v15 )
break;
if ( (_DWORD)v17 == *v16 )
goto LABEL_18;
}
}
if ( !(unsigned int)SSL_CTX_add_server_custom_ext(a1, v17, sub_D441E8, 0, 0, sub_D43EF8, 0) )
goto LABEL_25;
LABEL_18:
if ( v5 - 2 <= 1 || (v19 = v5 - 4, v20 = v3[3] + (v3[2] << 8), v20 > v19) )
{
LABEL_25:
ERR_put_error(20, 336, 388, "ssl/ssl_rsa.c", 873);
return 0;
}
v5 = v19 - v20;
if ( !v5 )
return 1;
if ( v5 == 1 )
goto LABEL_25;
v14 = *(_QWORD **)(a1 + 288);
v3 += v20 + 4;
}
}