//
// X509_print_ex from 0x83d754 to 0x83dd28 (1492 bytes)
//
// 3 xrefs:
// > X509_print_ex_fp @ 0x83ddf4
// > X509_print @ 0x83de54
// > ??> @ 0x66bbc
//
// 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 X509_print_ex(int a1, int a2, int a3, int a4)
{
int v8; // r10
int v9; // r9
_BOOL4 v10; // r4
int version; // r0
int *serialNumber; // r11
const char *v14; // r3
int v15; // r8
int v16; // r2
int v17; // r3
int *v18; // r0
int issuer_name; // r0
int v20; // r0
int v21; // r2
int v22; // r3
int v23; // r0
int v24; // r2
int v25; // r3
int subject_name; // r0
int X509_PUBKEY; // r0
int v28; // r2
int v29; // r3
_DWORD *v30; // r1
int v31; // r0
int v32; // r8
const char *v33; // r2
int *v34; // [sp+10h] [bp-Ch] BYREF
int *v35[2]; // [sp+14h] [bp-8h] BYREF
if ( (a3 & 0xF0000) == 0x40000 )
{
v8 = 12;
v9 = 10;
}
else
{
if ( a3 )
v8 = 0;
else
v8 = 16;
v9 = 32;
}
if ( (a4 & 1) == 0 && (BIO_write(a1, (int)"Certificate:\n", 13) <= 0 || BIO_write(a1, (int)" Data:\n", 10) <= 0) )
goto LABEL_23;
if ( (a4 & 2) != 0 )
{
if ( (a4 & 4) != 0 )
goto LABEL_9;
goto LABEL_28;
}
version = X509_get_version(a2);
if ( BIO_printf(a1, "%8sVersion: %lu (0x%lx)\n", &byte_9B1912, version + 1, version) <= 0 )
goto LABEL_23;
if ( (a4 & 4) == 0 )
{
LABEL_28:
if ( BIO_write(a1, (int)" Serial Number:", 22) <= 0 )
goto LABEL_23;
serialNumber = (int *)X509_get_serialNumber(a2);
if ( *serialNumber > 4 || (ERR_set_mark(), v32 = ASN1_INTEGER_get(serialNumber), ERR_pop_to_mark(), v32 == -1) )
{
if ( serialNumber[1] == 258 )
v14 = " (Negative)";
else
v14 = &byte_9B1912;
if ( BIO_printf(a1, "\n%12s%s", &byte_9B1912, v14) <= 0 )
goto LABEL_23;
v15 = 0;
while ( v15 < *serialNumber )
{
v16 = *(unsigned __int8 *)(serialNumber[2] + v15++);
if ( *serialNumber == v15 )
v17 = 10;
else
v17 = 58;
if ( BIO_printf(a1, "%02x%c", v16, v17) <= 0 )
goto LABEL_23;
}
}
else
{
if ( serialNumber[1] == 258 )
{
v32 = -v32;
v33 = "-";
}
else
{
v33 = &byte_9B1912;
}
if ( BIO_printf(a1, " %s%lu (%s0x%lx)\n", v33, v32, v33, v32) <= 0 )
goto LABEL_23;
}
}
LABEL_9:
if ( (a4 & 8) != 0 )
{
if ( (a4 & 0x10) != 0 )
goto LABEL_11;
goto LABEL_42;
}
v18 = (int *)X509_get0_tbs_sigalg(a2);
if ( X509_signature_print(a1, v18, (int *)(a4 & 8)) <= 0 )
goto LABEL_23;
if ( (a4 & 0x10) == 0 )
{
LABEL_42:
if ( BIO_printf(a1, " Issuer:%c", v9) <= 0 )
goto LABEL_23;
issuer_name = X509_get_issuer_name(a2);
if ( X509_NAME_print_ex(a1, issuer_name, v8, a3) < 0 || BIO_write(a1, (int)"\n", 1) <= 0 )
goto LABEL_23;
}
LABEL_11:
if ( (a4 & 0x20) == 0 )
{
if ( BIO_write(a1, (int)" Validity\n", 17) <= 0 )
goto LABEL_23;
if ( BIO_write(a1, (int)" Not Before: ", 24) <= 0 )
goto LABEL_23;
v20 = X509_get0_notBefore(a2);
if ( !ASN1_TIME_print(a1, v20, v21, v22) )
goto LABEL_23;
if ( BIO_write(a1, (int)"\n Not After : ", 25) <= 0 )
goto LABEL_23;
v23 = X509_get0_notAfter(a2);
if ( !ASN1_TIME_print(a1, v23, v24, v25) || BIO_write(a1, (int)"\n", 1) <= 0 )
goto LABEL_23;
}
if ( (a4 & 0x40) == 0 )
{
if ( BIO_printf(a1, " Subject:%c", v9) <= 0 )
goto LABEL_23;
subject_name = X509_get_subject_name(a2);
if ( X509_NAME_print_ex(a1, subject_name, v8, a3) < 0 || BIO_write(a1, (int)"\n", 1) <= 0 )
goto LABEL_23;
}
if ( (a4 & 0x80) == 0 )
{
X509_PUBKEY = X509_get_X509_PUBKEY(a2);
X509_PUBKEY_get0_param(v35, a4 & 0x80, a4 & 0x80, a4 & 0x80, X509_PUBKEY);
if ( BIO_write(a1, (int)" Subject Public Key Info:\n", 33) > 0
&& BIO_printf(a1, "%12sPublic Key Algorithm: ", &byte_9B1912) > 0
&& i2a_ASN1_OBJECT(a1, (int)v35[0], v28, v29) > 0
&& BIO_puts(a1, (int)"\n") > 0 )
{
v30 = (_DWORD *)X509_get0_pubkey(a2);
if ( v30 )
{
EVP_PKEY_print_public(a1, v30, 16);
}
else
{
BIO_printf(a1, "%12sUnable to load Public Key\n", &byte_9B1912);
ERR_print_errors(a1);
}
goto LABEL_14;
}
LABEL_23:
v10 = 0;
goto LABEL_24;
}
LABEL_14:
if ( (a4 & 0x1000) == 0 )
{
X509_get0_uids(a2, &v34, v35);
if ( v34 )
{
if ( BIO_printf(a1, "%8sIssuer Unique ID: ", &byte_9B1912) <= 0 || !X509_signature_dump(a1, v34, 12) )
goto LABEL_23;
}
if ( v35[0] && (BIO_printf(a1, "%8sSubject Unique ID: ", &byte_9B1912) <= 0 || !X509_signature_dump(a1, v35[0], 12)) )
goto LABEL_23;
}
if ( (a4 & 0x100) == 0 )
{
v31 = X509_get0_extensions(a2);
X509V3_extensions_print(a1, "X509v3 extensions", v31, a4, 8);
}
if ( (a4 & 0x200) == 0 )
{
X509_get0_signature(v35, &v34, a2);
if ( X509_signature_print(a1, v34, v35[0]) <= 0 )
goto LABEL_23;
}
v10 = (a4 & 0x400) != 0 || X509_aux_print(a1, a2, 0) != 0;
LABEL_24:
CRYPTO_free(nullptr, (int)"crypto/x509/t_x509.c", 206);
return v10;
}