//
// ASN1_item_print from 0x868e8c to 0x869664 (2008 bytes)
//
// 3 xrefs:
// > PKCS7_print_ctx @ 0x8268c4
// > CMS_ContentInfo_print_ctx @ 0x874f28
// > ??> @ 0x65d4c
//
// 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 ASN1_item_print(int a1, int a2, int a3, unsigned __int8 *a4, int *a5)
{
int *v5; // r4
int v9; // r3
int v10; // r8
const char *v11; // r9
int (__fastcall *v12)(int, int *, unsigned __int8 *, _DWORD *); // r7
int *v13; // r3
int v15; // r2
int (__fastcall *v16)(int, int *, unsigned __int8 *, int, int *); // r7
int v17; // r0
_DWORD *v18; // r8
int v19; // r9
int *v20; // r0
int *v21; // r0
int choice_selector; // r0
int v23; // r3
int (__fastcall *v24)(int, int *, int, char *, int *); // r12
int v25; // r0
unsigned int v26; // r7
int v27; // r8
int v28; // r3
int *v29; // r9
int v30; // r4
int v31; // r4
char *v32; // r0
char *v33; // r6
_BYTE *v34; // r0
void *v35; // r6
int *v36; // r8
int *field_ptr; // r0
_DWORD *v38; // r9
unsigned int v39; // t1
const char *v40; // r1
int v41; // r3
const char *v42; // r1
int *v43; // [sp+Ch] [bp-70h]
int v44[2]; // [sp+14h] [bp-68h] BYREF
_DWORD v45[3]; // [sp+1Ch] [bp-60h] BYREF
char v46[84]; // [sp+28h] [bp-54h] BYREF
v5 = a5;
v44[0] = a2;
if ( !a5 )
v5 = (int *)&unk_AC1244;
v9 = *v5;
v10 = *((_DWORD *)a4 + 4);
if ( (*v5 & 0x100) != 0 )
v11 = nullptr;
else
v11 = *((const char **)a4 + 6);
if ( v10 )
{
v12 = *(int (__fastcall **)(int, int *, unsigned __int8 *, _DWORD *))(v10 + 16);
if ( v12 )
{
v45[0] = a1;
v45[1] = a3;
v45[2] = v5;
}
}
else
{
v12 = nullptr;
}
if ( *a4 )
{
if ( v44[0] )
{
switch ( *a4 )
{
case 1u:
case 6u:
if ( !sub_867B28(a1, a3, 0, v11, v5) )
return 0;
if ( !v11 )
goto LABEL_25;
if ( (*v5 & 2) != 0 )
{
if ( BIO_puts(a1, (int)" {\n") <= 0 )
return 0;
}
else if ( BIO_puts(a1, (int)"\n") <= 0 )
{
return 0;
}
LABEL_25:
if ( v12 )
{
v17 = v12(8, v44, a4, v45);
if ( !v17 )
return 0;
if ( v17 == 2 )
return 1;
}
v18 = *((_DWORD **)a4 + 2);
if ( *((int *)a4 + 3) <= 0 )
goto LABEL_82;
v19 = 0;
break;
case 2u:
choice_selector = asn1_get_choice_selector(v44, (int)a4);
if ( choice_selector < 0 || choice_selector >= *((_DWORD *)a4 + 3) )
return BIO_printf(a1, "ERROR: selector [%d] invalid\n", choice_selector) > 0;
v36 = (int *)(*((_DWORD *)a4 + 2) + 20 * choice_selector);
field_ptr = (int *)asn1_get_field_ptr(v44, (int)v36);
return sub_867C80(a1, field_ptr, a3, v36, v5);
case 4u:
if ( !sub_867B28(a1, a3, 0, v11, v5) )
return 0;
v23 = *((_DWORD *)a4 + 4);
if ( v23 )
{
v24 = *(int (__fastcall **)(int, int *, int, char *, int *))(v23 + 24);
if ( v24 )
{
v25 = v24(a1, v44, a3, &byte_9B1912, v5);
if ( !v25 )
return 0;
if ( v25 == 2 )
return BIO_puts(a1, (int)"\n") > 0;
return 1;
}
}
if ( !v11 )
return 1;
return BIO_printf(a1, ":EXTERNAL TYPE %s\n", v11) > 0;
case 5u:
goto LABEL_17;
default:
BIO_printf(a1, "Unprocessed type %d\n", *a4);
return 0;
}
while ( 1 )
{
v21 = asn1_do_adb(v44, v18, 1);
++v19;
v18 += 5;
v43 = v21;
if ( !v21 )
break;
v20 = (int *)asn1_get_field_ptr(v44, (int)v21);
if ( !sub_867C80(a1, v20, a3 + 2, v43, v5) )
break;
if ( v19 >= *((_DWORD *)a4 + 3) )
{
LABEL_82:
if ( (*v5 & 2) != 0 && BIO_printf(a1, "%*s}\n", a3, &byte_9B1912) < 0 )
return 0;
if ( !v12 )
return 1;
return v12(9, v44, a4, v45) != 0;
}
}
return 0;
}
}
else if ( *((_DWORD *)a4 + 1) == 1 || v44[0] )
{
v13 = *((int **)a4 + 2);
if ( v13 )
return sub_867C80(a1, v44, a3, v13, v5);
LABEL_17:
if ( !sub_867B28(a1, a3, 0, v11, v5) )
return 0;
if ( v10 )
{
v16 = *(int (__fastcall **)(int, int *, unsigned __int8 *, int, int *))(v10 + 28);
if ( v16 )
return v16(a1, v44, a4, a3, v5) != 0;
}
if ( *a4 == 5 )
{
v27 = v44[0];
v26 = *(_DWORD *)(v44[0] + 4) & 0xFFFFFEFF;
goto LABEL_56;
}
v26 = *((_DWORD *)a4 + 1);
if ( v26 != 1 )
{
v27 = v44[0];
LABEL_56:
v28 = *v5;
if ( v26 == -4 )
{
v38 = (_DWORD *)v27;
v27 = *(_DWORD *)(v27 + 4);
v39 = *v38;
v29 = v38 + 1;
v26 = v39;
if ( (v28 & 0x10) != 0 )
{
LABEL_60:
if ( v26 != 5 )
{
LABEL_61:
switch ( v26 )
{
case 0xFFFFFFFD:
case 0x10u:
case 0x11u:
return BIO_puts(a1, (int)"\n") > 0
&& ASN1_parse_dump(a1, *(unsigned __int8 **)(v27 + 8), *(_DWORD *)v27, a3, 0) > 0;
case 1u:
goto LABEL_98;
case 2u:
case 0xAu:
v34 = i2s_ASN1_INTEGER(0, v27);
v35 = v34;
if ( !v34 )
return 0;
v30 = BIO_puts(a1, (int)v34) > 0;
CRYPTO_free(v35, (int)"crypto/asn1/tasn_prn.c", 401);
goto LABEL_64;
case 3u:
case 4u:
if ( *(_DWORD *)(v27 + 4) == 3 )
{
if ( BIO_printf(a1, " (%ld unused bits)\n", *(_DWORD *)(v27 + 12) & 7) <= 0 )
return 0;
}
else if ( BIO_puts(a1, (int)"\n") <= 0 )
{
return 0;
}
return *(int *)v27 <= 0
|| BIO_dump_indent(a1, *(unsigned __int8 **)(v27 + 8), *(_DWORD *)v27, a3 + 2) > 0;
case 6u:
v31 = *v29;
v32 = OBJ_obj2nid(*v29);
v33 = OBJ_nid2ln((unsigned int)v32);
if ( !v33 )
v33 = &byte_9B1912;
OBJ_obj2txt(v46, 80, v31, 1);
v30 = BIO_printf(a1, "%s (%s)", v33, v46) > 0;
goto LABEL_64;
case 0x17u:
v30 = ASN1_UTCTIME_print(a1, (int *)v27, v15, v28);
goto LABEL_64;
case 0x18u:
v30 = ASN1_GENERALIZEDTIME_print(a1, (int *)v27);
goto LABEL_64;
default:
v30 = ASN1_STRING_print_ex(a1, (_DWORD *)v27, v5[4]);
LABEL_64:
if ( v30 )
return BIO_puts(a1, (int)"\n") > 0;
return 0;
}
}
return BIO_puts(a1, (int)"NULL\n") > 0;
}
v40 = ASN1_tag2str(v26);
LABEL_87:
if ( v26 != 5 )
{
if ( !v40 || BIO_puts(a1, (int)v40) > 0 && BIO_puts(a1, (int)":") > 0 )
goto LABEL_61;
return 0;
}
return BIO_puts(a1, (int)"NULL\n") > 0;
}
if ( (v28 & 8) == 0 )
{
v29 = v44;
goto LABEL_60;
}
LABEL_94:
v29 = v44;
v40 = ASN1_tag2str(v26);
goto LABEL_87;
}
if ( (*v5 & 8) != 0 )
{
v27 = 0;
goto LABEL_94;
}
v29 = v44;
LABEL_98:
v41 = *v29;
if ( *v29 != -1 || (v41 = *((_DWORD *)a4 + 5), v42 = "BOOL ABSENT", v41 != -1) )
{
v42 = "FALSE";
if ( v41 )
v42 = "TRUE";
}
if ( BIO_puts(a1, (int)v42) <= 0 )
return 0;
return BIO_puts(a1, (int)"\n") > 0;
}
if ( (v9 & 1) != 0 )
{
if ( sub_867B28(a1, a3, 0, v11, v5) )
return BIO_puts(a1, (int)"
\n") > 0;
return 0;
}
return 1;
}