//
// ssl3_cbc_copy_mac from 0xd352e8 to 0xd35488 (416 bytes)
//
// 3 xrefs:
// > ssl3_get_record @ 0xd35c6c
// > dtls1_process_record @ 0xd360cc
// > ??> @ 0x4ddd8
//
// 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 ssl3_cbc_copy_mac(__int64 a1, __int64 a2, unsigned int a3)
{
unsigned int v3; // w26
int v4; // w24
int v8; // w25
unsigned int v9; // w19
_BYTE *v10; // x22
unsigned int v11; // w20
__int64 v12; // x8
unsigned int v13; // w1
int v14; // w3
__int64 v15; // x3
__int64 result; // x0
_BYTE v17[128]; // [xsp+60h] [xbp+60h] BYREF
v3 = *(_DWORD *)(a2 + 12);
v4 = *(_DWORD *)(a2 + 8);
v8 = v4 - a3;
if ( a3 > v3 )
OPENSSL_die((int)"assertion failed: rec->orig_len >= md_size");
if ( a3 > 0x40 )
OPENSSL_die((int)"assertion failed: md_size <= EVP_MAX_MD_SIZE");
v9 = 0;
v10 = &v17[-(__int64)v17 & 0x3F];
if ( v3 > a3 + 256 )
v9 = v3 - 256 - a3;
v11 = (v8 + (a3 >> 1 << 24) - v9) % a3;
memset(&v17[-(__int64)v17 & 0x3F], 0, a3);
if ( v9 < v3 )
{
v12 = *(_QWORD *)(a2 + 24);
v13 = 0;
do
{
v14 = *(unsigned __int8 *)(v12 + v9)
& ~((int)(((v9 - v8) ^ v8 | v9 ^ v8) ^ v9) >> 31)
& ((int)(((v9 - v4) ^ v4 | v9 ^ v4) ^ v9) >> 31);
++v9;
v10[v13] |= v14;
v13 = (v13 + 1) & ((int)(((v13 + 1 - a3) ^ a3 | (v13 + 1) ^ a3) ^ (v13 + 1)) >> 31);
}
while ( v9 != v3 );
}
v15 = 0;
do
{
*(_BYTE *)(a1 + v15++) = v10[v11];
result = (unsigned __int8)v10[v11 ^ 0x20];
v11 = (v11 + 1) & ((int)(((v11 + 1 - a3) ^ a3 | (v11 + 1) ^ a3) ^ (v11 + 1)) >> 31);
}
while ( a3 > (unsigned int)v15 );
return result;
}