//
// EVP_EncryptUpdate from 0x802458 to 0x802744 (748 bytes)
//
// 8 xrefs:
// > tls_construct_new_session_ticket @ 0x7aca44
// > EVP_DecryptUpdate @ 0x802a18
// > EVP_DecryptUpdate @ 0x802a74
// > EVP_CipherUpdate @ 0x802afc
// > PEM_ASN1_write_bio @ 0x822364
// > cms_RecipientInfo_pwri_crypt @ 0x8765b0
// > cms_RecipientInfo_pwri_crypt @ 0x8765d0
// > ??> @ 0x5d71c
//
// 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_EncryptUpdate(_DWORD *a1, char *a2, int *a3, char *a4, int a5)
{
int v5; // lr
char *v8; // r7
char *v9; // r6
int v10; // r5
bool v11; // cc
int v12; // r6
_BOOL4 v13; // r3
int v14; // r0
int result; // r0
size_t v16; // r2
char v17; // r3
int v18; // r10
int v19; // r3
int v20; // r4
size_t v21; // r4
int v22; // r5
int v23; // r11
char *v24; // r0
_BOOL4 v25; // r3
bool v26; // cc
int v27; // r2
v5 = *a1;
v8 = a4;
v9 = a2;
v10 = a5;
if ( (*(_DWORD *)(*a1 + 16) & 0x100000) != 0 )
{
v11 = (int)a2 <= (int)a4;
if ( a2 != a4 )
v11 = a5 <= 0;
v12 = !v11;
v13 = a2 - a4 > (unsigned int)-a5 || a2 - a4 < (unsigned int)a5;
if ( (v12 & v13) != 0 )
{
ERR_put_error(6, 167, 162, (int)"crypto/evp/evp_enc.c", 301);
return 0;
}
v14 = (*(int (**)(void))(v5 + 24))();
if ( v14 >= 0 )
{
*a3 = v14;
return 1;
}
return 0;
}
if ( a5 <= 0 )
{
*a3 = 0;
return a5 == 0;
}
v16 = a2 - a4;
v17 = a2 - a4 < (unsigned int)a5;
if ( v16 > -a5 )
v17 |= 1u;
if ( v16 )
v18 = v17 & 1;
else
v18 = 0;
if ( v18 )
{
ERR_put_error(6, 167, 162, (int)"crypto/evp/evp_enc.c", 318);
return 0;
}
v19 = a1[3];
if ( !v19 )
{
if ( (a5 & a1[26]) == 0 )
{
result = (*(int (__fastcall **)(_DWORD *, char *, char *, int))(v5 + 24))(a1, a2, v8, a5);
if ( result )
{
*a3 = a5;
return 1;
}
else
{
*a3 = 0;
}
return result;
}
v20 = *(_DWORD *)(v5 + 4);
if ( v20 <= 32 )
{
*a3 = 0;
goto LABEL_26;
}
LABEL_54:
OPENSSL_die("assertion failed: bl <= (int)sizeof(ctx->buf)", "crypto/evp/evp_enc.c", 333);
}
v20 = *(_DWORD *)(v5 + 4);
if ( v20 > 32 )
goto LABEL_54;
v23 = v20 - v19;
v24 = (char *)a1 + v19 + 48;
if ( a5 < v20 - v19 )
{
memcpy(v24, v8, a5);
a1[3] += a5;
*a3 = 0;
return 1;
}
memcpy(v24, v8, v20 - v19);
v8 += v23;
v25 = v9 - v8 > (unsigned int)-v20 || v9 - v8 < (unsigned int)v20;
v26 = (int)v9 <= (int)v8;
if ( v9 != v8 )
v26 = v20 <= 0;
v27 = !v26;
if ( (v27 & v25) != 0 )
{
ERR_put_error(6, 167, 162, (int)"crypto/evp/evp_enc.c", 346);
return 0;
}
if ( !(*(int (__fastcall **)(_DWORD *, char *, _DWORD *, int))(*a1 + 24))(a1, v9, a1 + 12, v20) )
return 0;
v10 = a5 - v23;
v9 += v20;
*a3 = v20;
LABEL_26:
v21 = (v20 - 1) & v10;
v22 = v10 - v21;
if ( v22 > 0 )
{
if ( (*(int (__fastcall **)(_DWORD *, char *, char *, int))(*a1 + 24))(a1, v9, v8, v22) )
{
*a3 += v22;
goto LABEL_29;
}
return 0;
}
LABEL_29:
if ( v21 )
memcpy(a1 + 12, &v8[v22], v21);
a1[3] = v21;
return 1;
}