//
// ssl_parse_clienthello_use_srtp_ext from 0xfdc6bc to 0xfdc8c0 (516 bytes)
//
// 2 xrefs:
// > sub_FD7964 @ 0xfd8124
// > ??> @ 0xd8d30
//
// 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:35 +0000
//
__int64 __fastcall ssl_parse_clienthello_use_srtp_ext(__int64 a1, __int64 *a2, _DWORD *a3)
{
unsigned __int64 v3; // x3
unsigned __int8 *v7; // x1
unsigned __int64 v8; // x4
unsigned __int8 *v9; // x24
int v10; // w3
int v11; // w23
unsigned __int64 v12; // x23
__int64 srtp_profiles; // x0
__int64 v14; // x22
int v15; // w21
int v16; // w3
int v17; // w20
__int64 v18; // x20
unsigned int v19; // w19
__int64 v20; // x0
unsigned __int8 *v21; // x0
__int64 result; // x0
unsigned __int64 v23; // x0
__int64 v24; // x1
unsigned __int8 v25; // w2
v3 = a2[1];
if ( v3 <= 1 )
goto LABEL_14;
v7 = (unsigned __int8 *)*a2;
v8 = v3 - 2;
v9 = v7 + 2;
v10 = *v7;
v11 = v7[1];
*a2 = (__int64)(v7 + 2);
a2[1] = v8;
v12 = v11 | (unsigned int)(v10 << 8);
if ( (v12 & 1) != 0 || v12 > v8 )
{
LABEL_14:
ERR_put_error(20, 310, 353, "ssl/d1_srtp.c", 194);
*a3 = 50;
return 1;
}
else
{
a2[1] = v8 - v12;
*a2 = (__int64)&v9[v12];
srtp_profiles = SSL_get_srtp_profiles(a1);
*(_QWORD *)(a1 + 752) = 0;
v14 = srtp_profiles;
v15 = OPENSSL_sk_num(srtp_profiles);
LABEL_5:
if ( v12 )
{
while ( v12 != 1 )
{
v16 = *v9;
v17 = v9[1];
v12 -= 2LL;
v9 += 2;
v18 = v17 | (unsigned int)(v16 << 8);
if ( v15 <= 0 )
goto LABEL_5;
v19 = 0;
while ( 1 )
{
v20 = OPENSSL_sk_value(v14, v19);
if ( *(_QWORD *)(v20 + 8) == v18 )
break;
if ( ++v19 == v15 )
goto LABEL_5;
}
*(_QWORD *)(a1 + 752) = v20;
v15 = v19;
if ( !v12 )
goto LABEL_12;
}
ERR_put_error(20, 310, 353, "ssl/d1_srtp.c", 207);
*a3 = 50;
return 1;
}
else
{
LABEL_12:
v21 = (unsigned __int8 *)a2[1];
if ( v21 )
{
v23 = (unsigned __int64)(v21 - 1);
v24 = *a2 + 1;
v25 = *(_BYTE *)*a2;
*a2 = v24;
a2[1] = v23;
if ( v25 > v23 || (result = v23 - v25, *a2 = v24 + v25, (a2[1] = result) != 0) )
{
ERR_put_error(20, 310, 352, "ssl/d1_srtp.c", 241);
*a3 = 50;
return 1;
}
}
else
{
ERR_put_error(20, 310, 353, "ssl/d1_srtp.c", 233);
*a3 = 50;
return 1;
}
}
}
return result;
}