//
// sub_A0AA14 from 0xa0aa14 to 0xa0aef4 (1248 bytes)
//
// 3 xrefs:
// > ENGINE_add_conf_module @ 0xa0af50
// > ENGINE_add_conf_module @ 0xa0af5c
// > ??> @ 0xa0af6c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:07:43 +0000
//
int __fastcall sub_A0AA14(int a1, int a2)
{
int value; // r0
int v4; // r0
const char *v5; // r9
char *v6; // r0
int v7; // r8
int v8; // r5
int v9; // r11
const char *v10; // r7
int v11; // r0
const char *v12; // r4
_DWORD *v13; // r6
char *v14; // r0
int v15; // r0
int v16; // r0
int v18; // r0
int v19; // r0
int v20; // r0
int v21; // r0
char v22; // [sp+18h] [bp-34h]
int i; // [sp+2Ch] [bp-20h]
int v24; // [sp+34h] [bp-18h]
int section; // [sp+3Ch] [bp-10h]
int v27; // [sp+44h] [bp-8h] BYREF
value = CONF_imodule_get_value(a1);
section = NCONF_get_section(a2, value);
if ( section )
{
for ( i = 0; ; ++i )
{
if ( i >= OPENSSL_sk_num(section) )
return 1;
v4 = OPENSSL_sk_value(section, i);
v27 = -1;
v5 = *(const char **)(v4 + 4);
v24 = *(_DWORD *)(v4 + 8);
v6 = strchr(v5, 46);
if ( v6 )
v5 = v6 + 1;
v7 = NCONF_get_section(a2, v24);
if ( !v7 )
{
ERR_put_error(38, 188, 149, "crypto/engine/eng_cnf.c", 61);
return 0;
}
v8 = 0;
v22 = 0;
v9 = 0;
while ( 1 )
{
if ( v8 >= OPENSSL_sk_num(v7) )
{
v18 = v9;
if ( !v9 || v27 != -1 )
goto LABEL_37;
if ( ENGINE_init(v9) )
{
v21 = dword_D340FC;
if ( dword_D340FC || (v21 = OPENSSL_sk_new_null(0), (dword_D340FC = v21) != 0) )
{
if ( OPENSSL_sk_push(v21, v9) )
{
v18 = v9;
LABEL_37:
ENGINE_free(v18);
goto LABEL_38;
}
}
ENGINE_finish(v9);
}
ERR_put_error(38, 188, 102, "crypto/engine/eng_cnf.c", 141);
goto LABEL_28;
}
v11 = OPENSSL_sk_value(v7, v8);
v12 = *(const char **)(v11 + 4);
v13 = (_DWORD *)v11;
v14 = strchr(v12, 46);
if ( v14 )
v12 = v14 + 1;
v15 = strcmp(v12, "engine_id");
v10 = (const char *)v13[2];
if ( !v15 )
{
v5 = (const char *)v13[2];
goto LABEL_16;
}
if ( !strcmp(v12, "soft_load") )
{
v22 = 1;
goto LABEL_16;
}
if ( !strcmp(v12, "dynamic_path") )
{
v16 = ENGINE_by_id("dynamic");
v9 = v16;
if ( !v16 )
goto LABEL_41;
if ( !ENGINE_ctrl_cmd_string(v16, "SO_PATH", v10, 0)
|| !ENGINE_ctrl_cmd_string(v9, "LIST_ADD", "2", 0)
|| !ENGINE_ctrl_cmd_string(v9, "LOAD", 0, 0) )
{
goto LABEL_27;
}
goto LABEL_16;
}
if ( !v9 )
break;
LABEL_11:
if ( !strcmp(v10, "EMPTY") )
v10 = nullptr;
if ( !strcmp(v12, "init") )
{
if ( !NCONF_get_number_e(a2, v24, "init", &v27) )
goto LABEL_27;
if ( v27 == 1 )
{
if ( !ENGINE_init(v9) )
goto LABEL_27;
v20 = dword_D340FC;
if ( !dword_D340FC && (v20 = OPENSSL_sk_new_null(0), (dword_D340FC = v20) == 0) || !OPENSSL_sk_push(v20, v9) )
{
ENGINE_finish(v9);
LABEL_27:
ERR_put_error(38, 188, 102, "crypto/engine/eng_cnf.c", 141);
ERR_add_error_data(6, "section=", *v13);
LABEL_28:
ENGINE_free(v9);
return 0;
}
}
else if ( v27 )
{
ERR_put_error(38, 188, 151, "crypto/engine/eng_cnf.c", 122);
goto LABEL_27;
}
}
else if ( !strcmp(v12, "default_algorithms") )
{
if ( !ENGINE_set_default_string(v9, (int)v10) )
goto LABEL_27;
}
else if ( !ENGINE_ctrl_cmd_string(v9, v12, v10, 0) )
{
goto LABEL_27;
}
LABEL_16:
++v8;
}
v19 = ENGINE_by_id(v5);
v9 = v19;
if ( ((v19 == 0) & (unsigned __int8)v22) == 0 )
break;
ERR_clear_error(v19);
LABEL_38:
;
}
if ( !v19 )
{
LABEL_41:
v9 = 0;
goto LABEL_27;
}
goto LABEL_11;
}
ERR_put_error(38, 187, 148, "crypto/engine/eng_cnf.c", 165);
return 0;
}