//
// EVP_EncodeUpdate from 0x8b6d04 to 0x8b6e90 (396 bytes)
//
// 3 xrefs:
// > PEM_write_bio @ 0x821eb0
// > sub_8D2508 @ 0x8d27dc
// > ??> @ 0x6538c
//
// 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_EncodeUpdate(signed int *a1, _BYTE *a2, int *a3, char *a4, int a5)
{
signed int v5; // r6
int v7; // r2
int v9; // r5
char *v10; // r11
signed int v11; // r8
int v13; // r4
int v14; // r0
_BYTE *v15; // r4
int v16; // r0
signed int v17; // r3
_BYTE *v18; // r4
v5 = a5;
*a3 = 0;
if ( a5 <= 0 )
return 0;
v7 = a1[1];
if ( v7 > 80 )
OPENSSL_die("assertion failed: ctx->length <= (int)sizeof(ctx->enc_data)", "crypto/evp/encode.c", 134);
v9 = *a1;
v10 = a4;
v11 = v7 - *a1;
if ( a5 < v11 )
{
memcpy((char *)a1 + v9 + 8, a4, a5);
*a1 += a5;
return 1;
}
if ( !v9 )
{
if ( a5 >= v7 )
goto LABEL_13;
v13 = *a1;
LABEL_8:
memcpy(a1 + 2, v10, v5);
LABEL_16:
*a1 = v5;
*a3 = v13;
return 1;
}
memcpy((char *)a1 + v9 + 8, a4, v7 - *a1);
v14 = EVP_EncodeBlock(a2, (int)(a1 + 2), a1[1]);
*a1 = 0;
v5 = a5 - v11;
v10 += v11;
v15 = &a2[v14];
v15[1] = 0;
*v15 = 10;
v7 = a1[1];
v9 = v14 + 1;
a2 = v15 + 1;
if ( a5 - v11 < v7 )
goto LABEL_14;
if ( v9 >= 0 )
{
LABEL_13:
while ( 1 )
{
v16 = EVP_EncodeBlock(a2, (int)v10, v7);
v17 = a1[1];
v5 -= v17;
v10 += v17;
v18 = &a2[v16];
*v18 = 10;
v18[1] = 0;
v7 = a1[1];
v9 += v16 + 1;
a2 = v18 + 1;
if ( v7 > v5 )
break;
if ( v9 < 0 )
goto LABEL_19;
}
LABEL_14:
v13 = v9;
if ( v9 >= 0 )
{
if ( !v5 )
goto LABEL_16;
goto LABEL_8;
}
}
LABEL_19:
*a3 = 0;
return 0;
}