//
// sub_DEDE84 from 0xdede84 to 0xdee240 (956 bytes)
//
// 4 xrefs:
// > X509_STORE_CTX_init @ 0xdedb18
// > X509_STORE_CTX_init @ 0xdedc14
// > X509_STORE_CTX_init @ 0xdedccc
// > X509_STORE_CTX_init @ 0xdedcd4
//
// 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
//
__int64 __fastcall sub_DEDE84(__int64 a1, __int64 a2)
{
int v4; // w22
int v5; // w0
__int64 v6; // x21
unsigned int v7; // w22
__int64 v8; // x1
time_t *v9; // x23
__int64 v10; // x0
int *Update; // x0
__int64 v12; // x0
unsigned int (__fastcall *v13)(_QWORD, __int64); // x2
int *v14; // x0
__int64 v15; // x0
unsigned int (__fastcall *v16)(__int64, __int64); // x2
unsigned int *v17; // x0
unsigned int *v18; // x21
int v19; // w1
unsigned int (__fastcall *v20)(_QWORD, __int64); // x2
unsigned int (__fastcall *v22)(__int64, __int64); // x2
unsigned int (__fastcall *v23)(_QWORD, __int64); // x2
unsigned int (__fastcall *v24)(_QWORD, __int64); // x2
int v25; // w1
int v26; // w1
__int64 v27; // x0
int v28; // w1
unsigned int (__fastcall *v29)(_QWORD, __int64); // x2
__int64 v30; // x0
unsigned int (__fastcall *v31)(__int64, __int64); // x2
int v32; // w1
unsigned int (__fastcall *v33)(_QWORD, __int64); // x2
unsigned int (__fastcall *v34)(_QWORD, __int64); // x2
unsigned int (*v35)(void); // x2
__int64 v36; // x1
unsigned int *v37; // x24
unsigned int *v38; // x23
int v39; // w0
__int64 v40; // x24
int v41; // w0
__int64 v42; // x0
_BYTE v43[24]; // [xsp+48h] [xbp+48h] BYREF
__int64 v44; // [xsp+60h] [xbp+60h]
__int64 v45; // [xsp+80h] [xbp+80h]
unsigned int *v46; // [xsp+E0h] [xbp+E0h]
__int64 v47; // [xsp+120h] [xbp+120h]
v4 = *(_DWORD *)(a1 + 172);
v5 = OPENSSL_sk_num(*(unsigned int **)(a1 + 152));
v6 = *(_QWORD *)(a1 + 192);
if ( v6 )
goto LABEL_2;
v26 = v5 - 1;
v27 = *(_QWORD *)(a1 + 152);
if ( v4 < v26 )
{
v6 = OPENSSL_sk_value(v27, v4 + 1);
goto LABEL_29;
}
v6 = OPENSSL_sk_value(v27, v26);
v30 = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(a1 + 72))(a1, v6, v6);
if ( (_DWORD)v30 )
{
LABEL_29:
if ( !v6 )
return 1;
goto LABEL_2;
}
v31 = *(unsigned int (__fastcall **)(__int64, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 33;
if ( !v31(v30, a1) )
return 0;
if ( !v6 )
return 1;
LABEL_2:
if ( *(_QWORD *)(a2 + 168) )
goto LABEL_3;
if ( (*(_QWORD *)(v6 + 208) & 0x200000002LL) == 2 )
{
v35 = *(unsigned int (**)(void))(a1 + 56);
*(_DWORD *)(a1 + 176) = 35;
if ( !v35() )
return 0;
}
v28 = *(_DWORD *)(a1 + 208);
if ( (v28 & 0x80) == 0 )
{
v34 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 44;
if ( !v34(v28 & 0x80, a1) )
return 0;
v28 = *(_DWORD *)(a1 + 208);
}
if ( (v28 & 8) == 0 )
{
if ( !*(_QWORD *)(a1 + 216)
&& (unsigned int)X509_STORE_CTX_init((__int64)v43, *(_QWORD **)a1, *(_QWORD *)(a1 + 192), *(_QWORD *)(a1 + 16)) )
{
v36 = *(_QWORD *)(a1 + 32);
v44 = *(_QWORD *)(a1 + 24);
X509_STORE_CTX_set0_param((__int64)v43, v36);
v47 = a1;
v45 = *(_QWORD *)(a1 + 56);
if ( (int)X509_verify_cert((__int64)v43) <= 0 )
{
X509_STORE_CTX_cleanup((__int64)v43);
}
else
{
v37 = *(unsigned int **)(a1 + 152);
v38 = v46;
v39 = OPENSSL_sk_num(v37);
v40 = OPENSSL_sk_value((__int64)v37, v39 - 1);
v41 = OPENSSL_sk_num(v38);
v42 = OPENSSL_sk_value((__int64)v38, v41 - 1);
LODWORD(v38) = X509_cmp(v40, v42);
X509_STORE_CTX_cleanup((__int64)v43);
if ( !(_DWORD)v38 )
goto LABEL_34;
}
}
v23 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 54;
if ( !v23(0, a1) )
return 0;
}
LABEL_34:
if ( (*(_DWORD *)(a2 + 152) & 2) != 0 )
{
v29 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 41;
if ( !v29(0, a1) )
return 0;
}
LABEL_3:
v7 = *(_DWORD *)(a1 + 208) & 0x40;
if ( v7 )
goto LABEL_14;
v8 = *(_QWORD *)(a1 + 32);
*(_QWORD *)(a1 + 200) = a2;
v9 = (time_t *)(v8 + 8);
v10 = *(_QWORD *)(v8 + 24);
if ( (v10 & 2) == 0 )
{
if ( (v10 & 0x200000) != 0 )
goto LABEL_14;
v9 = (time_t *)(v10 & 0x200000);
}
Update = (int *)X509_CRL_get0_lastUpdate(a2);
v12 = X509_cmp_time(Update, v9);
if ( (_DWORD)v12 )
{
if ( (int)v12 > 0 )
{
v13 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 11;
if ( !v13(0, a1) )
return v7;
}
}
else
{
v22 = *(unsigned int (__fastcall **)(__int64, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 15;
if ( !v22(v12, a1) )
return v7;
}
if ( !X509_CRL_get0_nextUpdate(a2) )
goto LABEL_13;
v14 = (int *)X509_CRL_get0_nextUpdate(a2);
v15 = X509_cmp_time(v14, v9);
if ( !(_DWORD)v15 )
{
v16 = *(unsigned int (__fastcall **)(__int64, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 16;
if ( !v16(v15, a1) )
return v7;
goto LABEL_13;
}
if ( (int)v15 >= 0 || (v32 = *(_DWORD *)(a1 + 208), (v32 & 2) != 0) )
{
LABEL_13:
*(_QWORD *)(a1 + 200) = 0;
goto LABEL_14;
}
v33 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56);
*(_DWORD *)(a1 + 176) = 12;
if ( !v33(v32 & 2, a1) )
return v7;
*(_QWORD *)(a1 + 200) = 0;
LABEL_14:
v17 = (unsigned int *)X509_get0_pubkey(v6);
v18 = v17;
if ( v17 )
{
v19 = X509_CRL_check_suiteb(a2, v17, *(_QWORD *)(*(_QWORD *)(a1 + 32) + 24LL));
if ( !v19
|| (v20 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56), *(_DWORD *)(a1 + 176) = v19, v20(0, a1)) )
{
if ( (int)X509_CRL_verify(a2, v18) > 0 )
return 1;
v24 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56);
v25 = 8;
goto LABEL_26;
}
return 0;
}
v24 = *(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 56);
v25 = 6;
LABEL_26:
*(_DWORD *)(a1 + 176) = v25;
return v24(0, a1) != 0;
}