//
// X509_print_ex from 0x1063918 to 0x1063ecc (1460 bytes)
//
// 3 xrefs:
// > X509_print_ex_fp @ 0x1063f20
// > X509_print @ 0x1063f90
// > ??> @ 0xa32a0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:16:52 +0000
//
__int64 __fastcall X509_print_ex(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int v8; // w23
unsigned int v9; // w26
unsigned int v10; // w21
__int64 version; // x0
__int64 serialNumber; // x25
const char *v14; // x3
__int64 v15; // x22
__int64 v16; // x3
__int64 v17; // x2
__int64 *v18; // x0
__int64 issuer_name; // x0
__int64 v20; // x0
__int64 v21; // x0
__int64 subject_name; // x0
__int64 X509_PUBKEY; // x0
unsigned int *v24; // x1
__int64 v25; // x0
__int64 v26; // x3
const char *v27; // x2
__int64 v28; // [xsp+68h] [xbp+68h]
__int64 *v29; // [xsp+70h] [xbp+70h] BYREF
__int64 v30; // [xsp+78h] [xbp+78h] BYREF
if ( (a3 & 0xF0000) == 0x40000 )
{
v8 = 12;
v9 = 10;
if ( (a4 & 1) != 0 )
goto LABEL_6;
}
else
{
if ( a3 )
v8 = 0;
else
v8 = 16;
v9 = 32;
if ( (a4 & 1) != 0 )
goto LABEL_6;
}
if ( (int)BIO_write(a1, (__int64)"Certificate:\n", 0xDu) <= 0 || (int)BIO_write(a1, (__int64)" Data:\n", 0xAu) <= 0 )
goto LABEL_21;
LABEL_6:
if ( (a4 & 2) != 0 )
{
if ( (a4 & 4) != 0 )
goto LABEL_8;
goto LABEL_25;
}
version = X509_get_version(a2);
if ( (int)BIO_printf(a1, "%8sVersion: %lu (0x%lx)\n", &byte_11B8890, version + 1, version) <= 0 )
goto LABEL_21;
if ( (a4 & 4) == 0 )
{
LABEL_25:
if ( (int)BIO_write(a1, (__int64)" Serial Number:", 0x16u) <= 0 )
goto LABEL_21;
serialNumber = X509_get_serialNumber(a2);
if ( *(int *)serialNumber > 8
|| (ERR_set_mark(), v28 = ASN1_INTEGER_get(serialNumber), ERR_pop_to_mark(), v26 = v28, v28 == -1) )
{
if ( *(_DWORD *)(serialNumber + 4) == 258 )
v14 = " (Negative)";
else
v14 = &byte_11B8890;
if ( (int)BIO_printf(a1, "\n%12s%s", &byte_11B8890, v14) <= 0 )
goto LABEL_21;
v15 = 0;
while ( *(_DWORD *)serialNumber > (int)v15 )
{
if ( (_DWORD)v15 + 1 == *(_DWORD *)serialNumber )
v16 = 10;
else
v16 = 58;
v17 = *(unsigned __int8 *)(*(_QWORD *)(serialNumber + 8) + v15++);
if ( (int)BIO_printf(a1, "%02x%c", v17, v16) <= 0 )
goto LABEL_21;
}
}
else
{
if ( *(_DWORD *)(serialNumber + 4) == 258 )
{
v26 = -v28;
v27 = &byte_1191DE0;
}
else
{
v27 = &byte_11B8890;
}
if ( (int)BIO_printf(a1, " %s%lu (%s0x%lx)\n", v27, v26, v27, v26) <= 0 )
goto LABEL_21;
}
}
LABEL_8:
if ( (a4 & 8) != 0 )
{
if ( (a4 & 0x10) != 0 )
goto LABEL_10;
}
else
{
v18 = (__int64 *)X509_get0_tbs_sigalg(a2);
if ( (int)X509_signature_print(a1, v18, a4 & 8) <= 0 )
goto LABEL_21;
if ( (a4 & 0x10) != 0 )
{
LABEL_10:
if ( (a4 & 0x20) != 0 )
goto LABEL_11;
LABEL_45:
if ( (int)BIO_write(a1, (__int64)" Validity\n", 0x11u) <= 0 )
goto LABEL_21;
if ( (int)BIO_write(a1, (__int64)" Not Before: ", 0x18u) <= 0 )
goto LABEL_21;
v20 = X509_get0_notBefore(a2);
if ( !(unsigned int)ASN1_TIME_print(a1, v20) )
goto LABEL_21;
if ( (int)BIO_write(a1, (__int64)"\n Not After : ", 0x19u) <= 0 )
goto LABEL_21;
v21 = X509_get0_notAfter(a2);
if ( !(unsigned int)ASN1_TIME_print(a1, v21) || (int)BIO_write(a1, (__int64)&byte_11AAA48, 1u) <= 0 )
goto LABEL_21;
if ( (a4 & 0x40) != 0 )
goto LABEL_12;
goto LABEL_52;
}
}
if ( (int)BIO_printf(a1, " Issuer:%c", v9) <= 0 )
goto LABEL_21;
issuer_name = X509_get_issuer_name(a2);
if ( (X509_NAME_print_ex(a1, issuer_name, v8, a3) & 0x80000000) != 0
|| (int)BIO_write(a1, (__int64)&byte_11AAA48, 1u) <= 0 )
{
goto LABEL_21;
}
if ( (a4 & 0x20) == 0 )
goto LABEL_45;
LABEL_11:
if ( (a4 & 0x40) != 0 )
goto LABEL_12;
LABEL_52:
if ( (int)BIO_printf(a1, " Subject:%c", v9) <= 0 )
goto LABEL_21;
subject_name = X509_get_subject_name(a2);
if ( (X509_NAME_print_ex(a1, subject_name, v8, a3) & 0x80000000) != 0
|| (int)BIO_write(a1, (__int64)&byte_11AAA48, 1u) <= 0 )
{
goto LABEL_21;
}
LABEL_12:
if ( (a4 & 0x80) == 0 )
{
X509_PUBKEY = X509_get_X509_PUBKEY(a2);
X509_PUBKEY_get0_param(
&v30,
(unsigned __int8)a4 & 0x80,
(unsigned __int8)a4 & 0x80,
(unsigned __int8)a4 & 0x80,
X509_PUBKEY);
if ( (int)BIO_write(a1, (__int64)" Subject Public Key Info:\n", 0x21u) <= 0
|| (int)BIO_printf(a1, "%12sPublic Key Algorithm: ", &byte_11B8890) <= 0
|| (int)i2a_ASN1_OBJECT(a1, v30) <= 0
|| (int)BIO_puts(a1, (__int64)&byte_11AAA48) <= 0 )
{
goto LABEL_21;
}
v24 = (unsigned int *)X509_get0_pubkey(a2);
if ( v24 )
{
EVP_PKEY_print_public(a1, v24, 16);
if ( (a4 & 0x1000) != 0 )
goto LABEL_14;
}
else
{
BIO_printf(a1, "%12sUnable to load Public Key\n", &byte_11B8890);
ERR_print_errors(a1);
if ( (a4 & 0x1000) != 0 )
goto LABEL_14;
}
goto LABEL_62;
}
if ( (a4 & 0x1000) == 0 )
{
LABEL_62:
X509_get0_uids(a2, &v29, &v30);
if ( (!v29
|| (int)BIO_printf(a1, "%8sIssuer Unique ID: ", &byte_11B8890) > 0 && X509_signature_dump(a1, (__int64)v29, 12))
&& (!v30 || (int)BIO_printf(a1, "%8sSubject Unique ID: ", &byte_11B8890) > 0 && X509_signature_dump(a1, v30, 12)) )
{
goto LABEL_14;
}
LABEL_21:
v10 = 0;
goto LABEL_22;
}
LABEL_14:
if ( (a4 & 0x100) == 0 )
{
v25 = X509_get0_extensions(a2);
X509V3_extensions_print(a1, "X509v3 extensions", v25, a4, 8);
}
v10 = a4 & 0x200;
if ( (a4 & 0x200) != 0 || (X509_get0_signature(&v30, &v29, a2), (int)X509_signature_print(a1, v29, v30) > 0) )
{
v10 = 1;
if ( (a4 & 0x400) == 0 )
v10 = X509_aux_print(a1, a2, 0) != 0;
}
LABEL_22:
CRYPTO_free(nullptr, (__int64)"crypto/x509/t_x509.c", 206);
return v10;
}