//
// tls_construct_certificate_request from 0xfd08c4 to 0xfd0b48 (644 bytes)
//
// 2 xrefs:
// > ossl_statem_server_construct_message @ 0xfd282c
// > ??> @ 0x9e860
//
// 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:29 +0000
//
__int64 __fastcall tls_construct_certificate_request(_QWORD *a1)
{
__int64 v1; // x26
__int64 v2; // x20
__int64 v3; // x19
int req_cert_type; // w0
int v6; // w25
__int64 v7; // x19
_BYTE *v8; // x21
__int64 v9; // x0
_BYTE *v10; // x20
int v11; // w21
__int64 client_CA_list; // x24
__int16 v13; // w22
int v14; // w20
__int64 v15; // x28
int v16; // w19
int v17; // w19
bool v18; // cc
__int64 v19; // x1
__int64 v20; // x4
int psigalgs; // w0
int v23; // w0
_BYTE *v24; // [xsp+60h] [xbp+60h] BYREF
__int64 v25; // [xsp+68h] [xbp+68h] BYREF
v1 = a1[15];
v2 = *(_QWORD *)(v1 + 8);
v3 = *(unsigned int *)(*(_QWORD *)(a1[1] + 192LL) + 108LL);
v24 = (_BYTE *)(v2 + v3 + 1);
req_cert_type = ssl3_get_req_cert_type((__int64)a1, v24);
*(_BYTE *)(v2 + v3) = req_cert_type;
v6 = req_cert_type + 1;
v7 = req_cert_type;
v8 = v24;
v9 = *(_QWORD *)(a1[1] + 192LL);
v10 = &v24[v7];
v24 += v7;
if ( (*(_DWORD *)(v9 + 104) & 2) != 0 )
{
psigalgs = tls12_get_psigalgs(a1, &v25);
v24 += 2;
v23 = tls12_copy_sigalgs(a1, v24, v25, psigalgs);
v8[v7] = BYTE1(v23);
v10[1] = v23;
v6 += v23 + 2;
v10 = &v24[v23];
}
v11 = v6 + 2;
v24 = v10 + 2;
client_CA_list = SSL_get_client_CA_list((__int64)a1);
if ( client_CA_list )
{
v13 = 0;
v14 = 0;
while ( 1 )
{
v18 = v14 < (int)OPENSSL_sk_num(client_CA_list);
v19 = (unsigned int)v14++;
if ( !v18 )
{
LOBYTE(client_CA_list) = HIBYTE(v13);
goto LABEL_9;
}
v15 = OPENSSL_sk_value(client_CA_list, v19);
v16 = i2d_X509_NAME(v15, 0);
if ( !BUF_MEM_grow_clean(v1, (unsigned int)(*(_DWORD *)(*(_QWORD *)(a1[1] + 192LL) + 108LL) + 2 + v11 + v16)) )
break;
v24 = (_BYTE *)(*(_QWORD *)(a1[15] + 8LL) + *(unsigned int *)(*(_QWORD *)(a1[1] + 192LL) + 108LL) + (__int64)v11);
*v24 = BYTE1(v16);
v24[1] = v16;
v17 = v16 + 2;
v11 += v17;
v13 += v17;
v24 += 2;
i2d_X509_NAME(v15, &v24);
}
ERR_put_error(20, 372, 7, "ssl/statem/statem_srvr.c", 2026);
}
else
{
LOBYTE(v13) = 0;
LABEL_9:
v24 = (_BYTE *)(*(_QWORD *)(a1[15] + 8LL) + *(unsigned int *)(*(_QWORD *)(a1[1] + 192LL) + 108LL) + (__int64)v6);
*v24 = client_CA_list;
v24[1] = v13;
v20 = *(_QWORD *)(a1[1] + 192LL);
v24 += 2;
if ( (*(unsigned int (__fastcall **)(_QWORD *, __int64, _QWORD))(v20 + 112))(a1, 13, v11) )
{
*(_DWORD *)(a1[18] + 648LL) = 1;
return 1;
}
ERR_put_error(20, 372, 68, "ssl/statem/statem_srvr.c", 2041);
}
ossl_statem_set_error((__int64)a1);
return 0;
}