//
// SSL_CTX_use_serverinfo from 0x79ce6c to 0x79d0f0 (644 bytes)
//
// 2 xrefs:
// > SSL_CTX_use_serverinfo_file @ 0x79d2d4
// > ??> @ 0x5c9ac
//
// 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 SSL_CTX_use_serverinfo(int a1, unsigned __int8 *a2, unsigned int a3)
{
bool v3; // zf
int v4; // r3
size_t v5; // r4
unsigned __int8 *v6; // r5
unsigned int v7; // r2
unsigned int v8; // r1
unsigned int v9; // r2
unsigned __int8 *v11; // r1
unsigned int v12; // r0
int v13; // r3
int v14; // r2
unsigned __int8 *v15; // r1
unsigned int v16; // r3
int v17; // r7
void *v18; // r0
_DWORD *v19; // r2
int v20; // r0
unsigned __int16 *v21; // r12
int v22; // r1
int v23; // r3
int v24; // t1
unsigned int v25; // r4
unsigned int v26; // r3
v3 = a3 == 0;
if ( a3 )
v3 = a2 == nullptr;
v4 = v3;
if ( !a1 )
v4 |= 1u;
if ( v4 )
{
ERR_put_error(20, 336, 67, "ssl/ssl_rsa.c", 847);
return 0;
}
v5 = a3;
if ( a3 <= 3 )
goto LABEL_30;
v6 = a2;
v7 = a3 - 4;
v8 = a2[3] + (a2[2] << 8);
if ( v7 < v8 )
goto LABEL_30;
v9 = v7 - v8;
v11 = &v6[v8 + 4];
if ( v9 )
{
while ( 1 )
{
v12 = v9 - 4;
if ( v9 <= 3 )
break;
v13 = v11[2];
v14 = v11[3];
v15 = v11 + 4;
v16 = v14 + (v13 << 8);
if ( v16 > v12 )
break;
v9 = v12 - v16;
v11 = &v15[v16];
if ( v12 == v16 )
goto LABEL_15;
}
LABEL_30:
ERR_put_error(20, 336, 388, "ssl/ssl_rsa.c", 851);
return 0;
}
LABEL_15:
v17 = **(_DWORD **)(a1 + 176);
if ( !v17 )
{
ERR_put_error(20, 336, 68, "ssl/ssl_rsa.c", 855);
return 0;
}
v18 = (void *)CRYPTO_realloc(*(_DWORD *)(v17 + 12), v5, "ssl/ssl_rsa.c", 859);
if ( !v18 )
{
ERR_put_error(20, 336, 65, "ssl/ssl_rsa.c", 861);
return 0;
}
*(_DWORD *)(**(_DWORD **)(a1 + 176) + 12) = v18;
memcpy(v18, v6, v5);
v19 = *(_DWORD **)(a1 + 176);
*(_DWORD *)(*v19 + 16) = v5;
while ( 1 )
{
v20 = v19[55];
v21 = (unsigned __int16 *)v19[54];
v22 = v6[1] + (*v6 << 8);
if ( v20 )
{
if ( v22 == *v21 )
goto LABEL_24;
v23 = 0;
while ( ++v23 != v20 )
{
v24 = v21[14];
v21 += 14;
if ( v22 == v24 )
goto LABEL_24;
}
}
if ( !SSL_CTX_add_server_custom_ext(a1, v22, sub_79B830, 0, 0, sub_79B53C, 0) )
goto LABEL_31;
LABEL_24:
if ( v5 - 2 <= 1 || (v25 = v5 - 4, v26 = v6[3] + (v6[2] << 8), v26 > v25) )
{
LABEL_31:
ERR_put_error(20, 336, 388, "ssl/ssl_rsa.c", 873);
return 0;
}
v5 = v25 - v26;
if ( !v5 )
return 1;
if ( v5 == 1 )
goto LABEL_31;
v19 = *(_DWORD **)(a1 + 176);
v6 += v26 + 4;
}
}