//
// ssl3_enc from 0x78b0e8 to 0x78b278 (400 bytes)
//
// 2 xrefs:
// > ??> @ 0x5aa9c
// > ??> @ 0xab1884
//
// 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
//
int __fastcall ssl3_enc(_DWORD *a1, int a2, int a3, int a4)
{
int v8; // r7
int v9; // r0
int v10; // r9
int v11; // r0
bool v12; // r10
bool v13; // zf
int v14; // r8
int v15; // r2
int v16; // r0
int v17; // r3
size_t v18; // r11
int v19; // r3
if ( a3 != 1 )
return 0;
if ( a4 )
{
v8 = a1[48];
if ( v8 )
goto LABEL_5;
LABEL_7:
memmove(*(void **)(a2 + 20), *(const void **)(a2 + 24), *(_DWORD *)(a2 + 8));
*(_DWORD *)(a2 + 24) = *(_DWORD *)(a2 + 20);
return 1;
}
v8 = a1[44];
if ( !v8 )
goto LABEL_7;
LABEL_5:
v9 = EVP_CIPHER_CTX_cipher(v8);
if ( !a1[60] || !v9 )
goto LABEL_7;
v10 = *(_DWORD *)(a2 + 8);
v11 = EVP_CIPHER_CTX_block_size(v8);
v12 = v11 != 1;
v13 = a4 == 0;
if ( a4 )
v13 = v11 == 1;
v14 = v11;
if ( v13 )
{
if ( !a4 && (!v10 || v10 % (unsigned int)v11) )
return 0;
}
else
{
v18 = v11 - v10 % v11;
memset((void *)(*(_DWORD *)(a2 + 24) + *(_DWORD *)(a2 + 8)), 0, v18);
v10 += v18;
v19 = *(_DWORD *)(a2 + 24) + v10;
*(_DWORD *)(a2 + 8) += v18;
*(_BYTE *)(v19 - 1) = v18 - 1;
}
if ( EVP_Cipher(v8, *(_DWORD *)(a2 + 20), *(_DWORD *)(a2 + 24), v10) <= 0 )
return -1;
if ( EVP_MD_CTX_md(a1[45]) )
{
v16 = EVP_MD_CTX_md(a1[45]);
v15 = EVP_MD_size(v16);
}
else
{
v15 = 0;
}
if ( a4 )
v17 = 0;
else
v17 = v12;
if ( v17 )
return ssl3_cbc_remove_padding(a2, v14, v15);
else
return 1;
}