//
// sub_DB2E3C from 0xdb2e3c to 0xdb33a4 (1384 bytes)
//
// 1 xrefs:
// > ??> @ 0x1125638
//
// 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 sub_DB2E3C(__int64 a1, char *a2, size_t *a3)
{
__int64 v3; // x3
unsigned int *v4; // x20
__int64 v6; // x21
__int64 v7; // x23
unsigned int v8; // w19
unsigned __int64 v10; // x24
__int64 v11; // x19
size_t v12; // x25
unsigned __int64 v13; // x26
void *v14; // x0
unsigned int v15; // w24
char *v16; // x20
void *v17; // x0
unsigned __int64 v18; // x0
__int64 v19; // x1
size_t v20; // x4
unsigned __int64 v21; // x2
__int64 v22; // x3
int8x16_t *v23; // x5
unsigned __int64 v24; // x6
int8x16_t *v25; // x0
int8x16_t *v26; // x7
int8x16_t v27; // t1
int8x16_t v28; // q0
int8x16_t v29; // t1
__int64 v30; // x0
size_t v31; // x1
__int64 i; // x0
v3 = *(_QWORD *)(a1 + 40);
v4 = *(unsigned int **)v3;
if ( !*(_QWORD *)v3 || (v6 = *(_QWORD *)(v3 + 8)) == 0 || (v7 = *(_QWORD *)(v3 + 1048)) == 0 )
{
v8 = 0;
ERR_put_error(52, 101, 101, (__int64)"crypto/kdf/tls1_prf.c", 126);
return v8;
}
v10 = *(_QWORD *)(v3 + 16);
v11 = v3 + 24;
v12 = *a3;
if ( (unsigned int)EVP_MD_type(*(unsigned int **)v3) == 114 )
{
v13 = v10 >> 1;
v14 = EVP_md5();
v15 = (v10 & 1) + (v10 >> 1);
if ( !(unsigned int)sub_DB2974((__int64)v14, v6, v15, v11, v7, a2, v12) )
return 0;
v16 = (char *)CRYPTO_malloc(v12, "crypto/kdf/tls1_prf.c", 248);
if ( !v16 )
return 0;
v17 = EVP_sha1();
v8 = sub_DB2974((__int64)v17, v6 + v13, v15, v11, v7, v16, v12);
if ( !v8 )
{
CRYPTO_clear_free(v16, v12, "crypto/kdf/tls1_prf.c", 253);
return v8;
}
if ( v12 )
{
if ( (a2 >= v16 + 16 || v16 >= a2 + 16) && v12 > 0x12 )
{
v18 = -(__int64)a2 & 0xF;
if ( v18 > v12 )
v18 = v12;
if ( !v18 )
goto LABEL_53;
*a2 ^= *v16;
if ( v18 == 1 )
goto LABEL_53;
a2[1] ^= v16[1];
if ( v18 == 2 )
goto LABEL_53;
a2[2] ^= v16[2];
if ( v18 == 3 )
goto LABEL_53;
a2[3] ^= v16[3];
if ( v18 == 4 )
goto LABEL_53;
a2[4] ^= v16[4];
if ( v18 == 5 )
goto LABEL_53;
a2[5] ^= v16[5];
if ( v18 == 6 )
goto LABEL_53;
a2[6] ^= v16[6];
if ( v18 == 7 )
goto LABEL_53;
a2[7] ^= v16[7];
if ( v18 == 8 )
goto LABEL_53;
a2[8] ^= v16[8];
if ( v18 == 9 )
{
v19 = 9;
goto LABEL_33;
}
a2[9] ^= v16[9];
if ( v18 == 10
|| (a2[10] ^= v16[10], v18 == 11)
|| (a2[11] ^= v16[11], v18 == 12)
|| (a2[12] ^= v16[12], v18 == 13) )
{
LABEL_53:
v19 = v18;
}
else
{
a2[13] ^= v16[13];
if ( v18 == 15 )
{
v19 = 15;
a2[14] ^= v16[14];
}
else
{
v19 = 14;
}
}
LABEL_33:
v20 = v12 - v18;
v21 = ((v12 - v18 - 16) >> 4) + 1;
v22 = 16 * v21;
if ( v12 - 1 - v18 <= 0xE )
goto LABEL_37;
v23 = (int8x16_t *)&a2[v18];
v24 = 0;
v25 = (int8x16_t *)&v16[v18];
v26 = v23;
do
{
v27 = *v25++;
v28 = v27;
++v24;
v29 = *v23++;
*v26++ = veorq_s8(v28, v29);
}
while ( v24 < v21 );
v19 += v22;
if ( v20 != v22 )
{
LABEL_37:
a2[v19] ^= v16[v19];
if ( v12 > v19 + 1 )
{
a2[v19 + 1] ^= v16[v19 + 1];
if ( v12 > v19 + 2 )
{
a2[v19 + 2] ^= v16[v19 + 2];
if ( v12 > v19 + 3 )
{
a2[v19 + 3] ^= v16[v19 + 3];
if ( v12 > v19 + 4 )
{
a2[v19 + 4] ^= v16[v19 + 4];
if ( v12 > v19 + 5 )
{
a2[v19 + 5] ^= v16[v19 + 5];
if ( v12 > v19 + 6 )
{
a2[v19 + 6] ^= v16[v19 + 6];
if ( v12 > v19 + 7 )
{
a2[v19 + 7] ^= v16[v19 + 7];
if ( v12 > v19 + 8 )
{
a2[v19 + 8] ^= v16[v19 + 8];
if ( v12 > v19 + 9 )
{
a2[v19 + 9] ^= v16[v19 + 9];
if ( v12 > v19 + 10 )
{
a2[v19 + 10] ^= v16[v19 + 10];
if ( v12 > v19 + 11 )
{
a2[v19 + 11] ^= v16[v19 + 11];
if ( v12 > v19 + 12 )
{
v30 = v19 + 13;
a2[v19 + 12] ^= v16[v19 + 12];
if ( v12 > v19 + 13 )
{
v31 = v19 + 14;
a2[v30] ^= v16[v30];
if ( v12 > v31 )
a2[v31] ^= v16[v31];
}
}
}
}
}
}
}
}
}
}
}
}
}
}
goto LABEL_52;
}
for ( i = 0; i != v12; ++i )
a2[i] ^= v16[i];
}
LABEL_52:
v8 = 1;
CRYPTO_clear_free(v16, v12, "crypto/kdf/tls1_prf.c", 258);
return v8;
}
return (unsigned int)sub_DB2974((__int64)v4, v6, v10, v11, v7, a2, v12) != 0;
}