//
// tls_construct_server_hello from 0xd51750 to 0xd51998 (584 bytes)
//
// 2 xrefs:
// > ossl_statem_server_construct_message @ 0xd544cc
// > ??> @ 0x525a8
//
// 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 tls_construct_server_hello(__int64 a1)
{
__int64 v1; // x1
int v3; // w0
__int64 v4; // x22
__int64 v5; // x1
__int64 v6; // x21
_QWORD *v7; // x0
_QWORD *v8; // x1
__int64 v9; // x3
__int64 v10; // x3
__int64 v11; // x0
size_t v12; // x2
char v14; // w0
_BYTE *v15; // x20
int v16; // w0
_BYTE *v17; // x2
__int64 v18; // x23
__int64 v19; // x0
unsigned int v20; // w20
unsigned int v21; // [xsp+4Ch] [xbp+4Ch] BYREF
v1 = *(_QWORD *)(a1 + 8);
v3 = *(int *)a1 >> 8;
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 120) + 8LL);
v5 = *(unsigned int *)(*(_QWORD *)(v1 + 192) + 108LL);
v21 = 0;
v6 = v4 + v5;
*(_BYTE *)(v4 + v5) = v3;
v7 = (_QWORD *)(v4 + v5 + 2);
*(_BYTE *)(v4 + v5 + 1) = *(_DWORD *)a1;
v8 = *(_QWORD **)(a1 + 144);
v9 = v8[19];
*v7 = v8[18];
v7[1] = v9;
v10 = v8[21];
v7[2] = v8[20];
v7[3] = v10;
v11 = *(_QWORD *)(a1 + 376);
if ( !*(_DWORD *)(v11 + 144) && ((*(_DWORD *)(*(_QWORD *)(a1 + 440) + 64LL) & 2) != 0 || *(_DWORD *)(a1 + 176)) )
{
LODWORD(v12) = *(_DWORD *)(v11 + 56);
if ( (int)v12 > 32 )
{
ERR_put_error(20, 376, 68, "ssl/statem/statem_srvr.c", 1548);
ossl_statem_set_error(a1);
return 0;
}
v14 = *(_DWORD *)(v11 + 56);
v12 = (int)v12;
}
else
{
v12 = 0;
*(_DWORD *)(v11 + 56) = 0;
v14 = 0;
}
*(_BYTE *)(v6 + 34) = v14;
v15 = (_BYTE *)(v6 + 35 + v12);
memcpy((void *)(v6 + 35), (const void *)(*(_QWORD *)(a1 + 376) + 60LL), v12);
v16 = ssl3_put_cipher_by_char(*(_QWORD *)(*(_QWORD *)(a1 + 144) + 552LL), v15);
v17 = *(_BYTE **)(*(_QWORD *)(a1 + 144) + 640LL);
if ( v17 )
LOBYTE(v17) = *v17;
v15[v16] = (_BYTE)v17;
v18 = (__int64)&v15[v16 + 1];
if ( (int)ssl_prepare_serverhello_tlsext(a1) <= 0 )
{
ERR_put_error(20, 376, 275, "ssl/statem/statem_srvr.c", 1571);
ossl_statem_set_error(a1);
return 0;
}
else
{
v19 = ssl_add_serverhello_tlsext(a1, v18, v4 + 0x4000, &v21);
v20 = v19;
if ( !v19 )
{
ssl3_send_alert(a1, 2, v21);
ERR_put_error(20, 376, 68, "ssl/statem/statem_srvr.c", 1579);
ossl_statem_set_error(a1);
return v20;
}
if ( (*(unsigned int (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 192LL) + 112LL))(
a1,
2,
v19 - v6) )
{
return 1;
}
ERR_put_error(20, 376, 68, "ssl/statem/statem_srvr.c", 1587);
ossl_statem_set_error(a1);
return 0;
}
}