//
// EVP_DecryptUpdate from 0x802890 to 0x802abc (556 bytes)
//
// 8 xrefs:
// > tls_check_serverhello_tlsext_early @ 0x7b04f0
// > EVP_CipherUpdate @ 0x802af4
// > PEM_do_header @ 0x8218b8
// > cms_RecipientInfo_pwri_crypt @ 0x876780
// > cms_RecipientInfo_pwri_crypt @ 0x8767e8
// > cms_RecipientInfo_pwri_crypt @ 0x87680c
// > cms_RecipientInfo_pwri_crypt @ 0x87684c
// > ??> @ 0x5d8ac
//
// 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 EVP_DecryptUpdate(_DWORD *a1, char *a2, int *a3, char *a4, signed int a5)
{
int v5; // r9
char *v7; // r8
size_t v10; // r2
_BOOL4 v11; // r3
bool v12; // cc
int v13; // r12
int v14; // r4
int result; // r0
bool v16; // nf
size_t v17; // r9
unsigned int v18; // r3
bool v19; // cc
int v20; // r3
bool v21; // cc
_BOOL4 v22; // r2
int v23; // r10
v5 = *a1;
v7 = a2;
if ( (*(_DWORD *)(*a1 + 16) & 0x100000) != 0 )
{
v10 = a2 - a4;
v11 = a2 - a4 < (unsigned int)a5;
v12 = (int)a2 <= (int)a4;
if ( a2 != a4 )
v12 = a5 <= 0;
v13 = !v12;
if ( v10 > -a5 )
v14 = v11 | 1;
else
v14 = v11;
if ( (v13 & v14) != 0 )
{
ERR_put_error(6, 166, 162, (int)"crypto/evp/evp_enc.c", 427);
return 0;
}
else
{
result = (*(int (**)(void))(v5 + 24))();
v16 = result < 0;
if ( result < 0 )
result = 0;
else
*a3 = result;
if ( v16 )
*a3 = 0;
else
return 1;
}
}
else if ( a5 <= 0 )
{
*a3 = *(_DWORD *)(*a1 + 16) & 0x100000;
return a5 == 0;
}
else if ( (a1[23] & 0x100) != 0 )
{
return EVP_EncryptUpdate(a1, a2, a3, a4, a5);
}
else
{
v17 = *(_DWORD *)(v5 + 4);
if ( v17 > 0x20 )
OPENSSL_die("assertion failed: b <= sizeof ctx->final", "crypto/evp/evp_enc.c", 449);
if ( a1[25] )
{
if ( a2 == a4 )
goto LABEL_34;
v18 = a2 - a4;
v19 = v17 > a2 - a4;
if ( v17 <= a2 - a4 )
v19 = v18 > -v17;
v20 = v19;
v21 = (int)a2 <= (int)a4;
if ( a2 != a4 )
v21 = (int)v17 <= 0;
v22 = !v21;
if ( (v22 & v20) != 0 )
{
LABEL_34:
ERR_put_error(6, 166, 162, (int)"crypto/evp/evp_enc.c", 455);
return 0;
}
memcpy(a2, a1 + 27, v17);
v7 += v17;
v23 = 1;
}
else
{
v23 = 0;
}
result = EVP_EncryptUpdate(a1, v7, a3, a4, a5);
if ( result )
{
if ( v17 <= 1 || a1[3] )
{
a1[25] = 0;
}
else
{
*a3 -= v17;
a1[25] = 1;
memcpy(a1 + 27, &v7[*a3], v17);
}
result = 1;
if ( v23 )
*a3 += v17;
}
}
return result;
}