//
// sub_1078E7C from 0x1078e7c to 0x107920c (912 bytes)
//
// 2 xrefs:
// > X509V3_EXT_nconf @ 0x10792a8
// > X509V3_EXT_nconf_nid @ 0x1079444
//
// 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:17:05 +0000
//
__int64 *__fastcall sub_1078E7C(__int64 a1, __int64 a2, unsigned int a3, int a4, _BYTE *a5)
{
_QWORD *nid; // x0
_QWORD *v11; // x19
int *section; // x22
__int64 v13; // x23
__int64 v14; // x2
unsigned int v15; // w20
unsigned int *v16; // x22
unsigned int *v17; // x2
__int64 *v18; // x20
unsigned __int8 *v19; // x1
char *v21; // x0
__int64 (*v22)(void); // x5
__int64 (*v23)(void); // x3
void (__fastcall *v24)(__int64, unsigned int **); // x2
char *v25; // x0
unsigned int *v26; // [xsp+50h] [xbp+50h] BYREF
unsigned int *v27; // [xsp+58h] [xbp+58h] BYREF
if ( a3 )
{
nid = (_QWORD *)X509V3_EXT_get_nid(a3);
v11 = nid;
if ( nid )
{
if ( nid[9] )
{
if ( *a5 == 64 )
section = (int *)NCONF_get_section(a1, (__int64)(a5 + 1));
else
section = (int *)X509V3_parse_list(a5);
if ( section && (int)OPENSSL_sk_num((unsigned int *)section) > 0 )
{
v13 = ((__int64 (__fastcall *)(_QWORD *, __int64, int *))v11[9])(v11, a2, section);
if ( *a5 != 64 )
OPENSSL_sk_pop_free(section, (void (__fastcall *)(__int64))X509V3_conf_free);
LABEL_10:
if ( v13 )
goto LABEL_11;
return nullptr;
}
ERR_put_error(34, 151, 105, (__int64)"crypto/x509v3/v3_conf.c", 93);
v21 = OBJ_nid2sn(a3);
ERR_add_error_data(4, "name=", v21, ",section=", a5);
if ( *a5 == 64 )
return nullptr;
v18 = nullptr;
OPENSSL_sk_pop_free(section, (void (__fastcall *)(__int64))X509V3_conf_free);
}
else
{
v23 = (__int64 (*)(void))nid[7];
if ( v23 )
{
v13 = v23();
goto LABEL_10;
}
v22 = (__int64 (*)(void))nid[11];
if ( v22 )
{
if ( *(_QWORD *)(a2 + 48) && *(_QWORD *)(a2 + 40) )
{
v13 = v22();
if ( v13 )
{
LABEL_11:
v14 = v11[1];
v26 = nullptr;
if ( v14 )
{
v15 = ASN1_item_i2d(v13, (__int64 *)&v26, v14);
if ( (v15 & 0x80000000) != 0 )
goto LABEL_32;
}
else
{
v15 = ((__int64 (__fastcall *)(__int64, _QWORD))v11[5])(v13, 0);
v26 = (unsigned int *)CRYPTO_malloc((void *)(int)v15, (__int64)"crypto/x509v3/v3_conf.c", 149);
v16 = v26;
if ( !v26 )
goto LABEL_33;
v24 = (void (__fastcall *)(__int64, unsigned int **))v11[5];
v27 = v26;
v24(v13, &v27);
}
v16 = (unsigned int *)ASN1_OCTET_STRING_new();
if ( v16 )
{
v17 = v26;
v26 = nullptr;
*((_QWORD *)v16 + 1) = v17;
*v16 = v15;
v18 = X509_EXTENSION_create_by_NID(nullptr, a3, a4, v16);
if ( v18 )
{
LABEL_15:
ASN1_OCTET_STRING_free((__int64)v16);
v19 = (unsigned __int8 *)v11[1];
if ( v19 )
{
ASN1_item_free(v13, v19);
return v18;
}
((void (__fastcall *)(__int64))v11[3])(v13);
return v18;
}
LABEL_33:
v18 = nullptr;
ERR_put_error(34, 135, 65, (__int64)"crypto/x509v3/v3_conf.c", 168);
CRYPTO_free(v26, (__int64)"crypto/x509v3/v3_conf.c", 169);
goto LABEL_15;
}
LABEL_32:
v16 = nullptr;
goto LABEL_33;
}
return nullptr;
}
v18 = nullptr;
ERR_put_error(34, 151, 136, (__int64)"crypto/x509v3/v3_conf.c", 110);
}
else
{
v18 = nullptr;
ERR_put_error(34, 151, 103, (__int64)"crypto/x509v3/v3_conf.c", 117);
v25 = OBJ_nid2sn(a3);
ERR_add_error_data(2, "name=", v25);
}
}
}
else
{
v18 = nullptr;
ERR_put_error(34, 151, 129, (__int64)"crypto/x509v3/v3_conf.c", 82);
}
return v18;
}
ERR_put_error(34, 151, 130, (__int64)"crypto/x509v3/v3_conf.c", 78);
return nullptr;
}