//
// PEM_X509_INFO_write_bio from 0x8ba588 to 0x8ba7a0 (536 bytes)
//
// 1 xrefs:
// > ??> @ 0x6b26c
//
// 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
//
bool __fastcall PEM_X509_INFO_write_bio(int a1, int a2, int a3, int a4, int a5, int a6, int a7)
{
_BOOL4 v7; // r4
unsigned int v11; // r0
int v12; // r2
int v13; // r8
int v14; // r9
unsigned int v15; // r0
char *v16; // r0
const char *v17; // r10
size_t v18; // r6
int v19; // r0
int v21; // r0
char v22[1024]; // [sp+10h] [bp-404h] BYREF
v7 = a3;
if ( a3 )
{
v11 = EVP_CIPHER_nid(a3);
if ( !OBJ_nid2sn(v11) )
{
v7 = 0;
ERR_put_error(9, 117, 113, (int)"crypto/pem/pem_info.c", 260);
goto LABEL_13;
}
}
v12 = *(_DWORD *)(a2 + 8);
if ( !v12 )
goto LABEL_10;
v13 = *(_DWORD *)(a2 + 36);
if ( !v13 || (v14 = *(_DWORD *)(a2 + 32), v14 <= 0) )
{
v21 = EVP_PKEY_get0_RSA(*(_DWORD **)(v12 + 12));
if ( PEM_write_bio_RSAPrivateKey(a1, v21, v7, a4, a5, a6, a7) > 0 )
goto LABEL_10;
LABEL_17:
v7 = 0;
goto LABEL_13;
}
if ( !v7 )
{
ERR_put_error(9, 117, 127, (int)"crypto/pem/pem_info.c", 273);
goto LABEL_13;
}
v15 = EVP_CIPHER_nid(*(_DWORD *)(a2 + 12));
v16 = OBJ_nid2sn(v15);
v17 = v16;
if ( !v16 )
{
v7 = 0;
ERR_put_error(9, 117, 113, (int)"crypto/pem/pem_info.c", 290);
goto LABEL_13;
}
v18 = strlen(v16);
if ( v18 + 36 + 2 * EVP_CIPHER_iv_length(v7) > 0x400 )
OPENSSL_die(
"assertion failed: strlen(objstr) + 23 + 2 * EVP_CIPHER_iv_length(enc) + 13 <= sizeof buf",
"crypto/pem/pem_info.c",
297);
v22[0] = 0;
PEM_proc_type(v22, 10);
v19 = EVP_CIPHER_iv_length(v7);
PEM_dek_info(v22, v17, v19, (unsigned __int8 *)(a2 + 16));
if ( PEM_write_bio(a1, "RSA PRIVATE KEY", v22, v13, v14) <= 0 )
goto LABEL_17;
LABEL_10:
if ( *(_DWORD *)a2 )
v7 = PEM_write_bio_X509(a1, *(_DWORD *)a2) > 0;
else
v7 = 1;
LABEL_13:
OPENSSL_cleanse(v22, 0x400u);
return v7;
}