//
// X509v3_asid_validate_path from 0xa67c6c to 0xa6811c (1200 bytes)
//
// 2 xrefs:
// > sub_A589E0 @ 0xa59794
// > ??> @ 0x8102c
//
// 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:08:37 +0000
//
int __fastcall X509v3_asid_validate_path(_DWORD *a1)
{
_DWORD *v1; // r7
int v3; // r0
int v4; // r5
int v5; // r4
_DWORD *v6; // r10
int v7; // r11
__int64 v8; // r8
_DWORD *v9; // r3
signed int i; // r4
int *v11; // r3
int v12; // r0
_DWORD *v13; // r0
int v14; // r0
int v15; // r0
int v16; // r0
_DWORD *v18; // r3
_DWORD *v19; // r3
int v20; // [sp+4h] [bp-8h]
v1 = (_DWORD *)a1[20];
if ( !v1 || OPENSSL_sk_num(a1[20]) <= 0 )
OPENSSL_die("assertion failed: chain != NULL && sk_X509_num(chain) > 0", "crypto/x509v3/v3_asid.c", 718);
if ( !a1[7] )
OPENSSL_die("assertion failed: ctx == NULL || ctx->verify_cb != NULL", "crypto/x509v3/v3_asid.c", 720);
v3 = OPENSSL_sk_value(v1, 0);
v4 = v3;
if ( !v3 )
OPENSSL_die("assertion failed: x != NULL", "crypto/x509v3/v3_asid.c", 733);
v5 = *(_DWORD *)(v3 + 156);
if ( !v5 )
return 1;
if ( !X509v3_asid_is_canonical(*(_DWORD *)(v3 + 156)) )
{
a1[23] = 0;
a1[25] = v4;
a1[24] = 41;
v7 = ((int (__fastcall *)(_DWORD, _DWORD *))a1[7])(0, a1);
if ( !v7 )
return 0;
v6 = *(_DWORD **)v5;
if ( *(_DWORD *)v5 )
goto LABEL_8;
LABEL_35:
HIDWORD(v8) = v6;
goto LABEL_36;
}
v6 = *(_DWORD **)v5;
v7 = 1;
if ( !*(_DWORD *)v5 )
goto LABEL_35;
LABEL_8:
HIDWORD(v8) = *v6;
if ( !*v6 )
{
v6 = &dword_0 + 1;
goto LABEL_12;
}
if ( HIDWORD(v8) == 1 )
{
HIDWORD(v8) = v6[1];
v6 = nullptr;
LABEL_12:
v9 = *(_DWORD **)(v5 + 4);
if ( v9 )
goto LABEL_13;
goto LABEL_37;
}
v6 = nullptr;
HIDWORD(v8) = 0;
LABEL_36:
v9 = *(_DWORD **)(v5 + 4);
if ( v9 )
{
LABEL_13:
LODWORD(v8) = *v9;
if ( *v9 )
{
if ( (_DWORD)v8 == 1 )
{
LODWORD(v8) = v9[1];
v20 = 0;
}
else
{
v20 = 0;
LODWORD(v8) = 0;
}
}
else
{
v20 = 1;
}
goto LABEL_16;
}
LABEL_37:
v20 = (int)v9;
LODWORD(v8) = v9;
LABEL_16:
for ( i = 1; i < OPENSSL_sk_num((int)v1); ++i )
{
v14 = OPENSSL_sk_value(v1, i);
v4 = v14;
if ( !v14 )
OPENSSL_die("assertion failed: x != NULL", "crypto/x509v3/v3_asid.c", 766);
v15 = *(_DWORD *)(v14 + 156);
if ( !v15 )
{
if ( v8 )
{
a1[24] = 46;
a1[23] = i;
a1[25] = v4;
v16 = ((int (*)(void))a1[7])();
v7 = v16;
if ( !v16 )
return 0;
}
else
{
v8 = 0;
}
continue;
}
if ( !X509v3_asid_is_canonical(v15) )
{
a1[24] = 41;
a1[23] = i;
a1[25] = v4;
v7 = ((int (__fastcall *)(_DWORD, _DWORD *))a1[7])(0, a1);
if ( !v7 )
return 0;
}
v11 = *(int **)(v4 + 156);
v12 = *v11;
if ( *v11 )
{
if ( *(_DWORD *)v12 != 1 )
goto LABEL_21;
if ( v6 )
goto LABEL_39;
}
else
{
if ( !HIDWORD(v8) )
goto LABEL_21;
a1[24] = 46;
a1[23] = i;
a1[25] = v4;
v7 = ((int (*)(void))a1[7])();
if ( !v7 )
return 0;
v11 = *(int **)(v4 + 156);
v12 = *v11;
if ( !*v11 || *(_DWORD *)v12 != 1 )
{
v6 = nullptr;
HIDWORD(v8) = 0;
goto LABEL_21;
}
HIDWORD(v8) = 0;
}
v6 = (_DWORD *)sub_A66B04(*(_DWORD **)(v12 + 4), (_DWORD *)HIDWORD(v8));
if ( !v6 )
{
a1[24] = 46;
a1[23] = i;
a1[25] = v4;
v7 = ((int (__fastcall *)(_DWORD, _DWORD *))a1[7])(0, a1);
if ( !v7 )
return 0;
v11 = *(int **)(v4 + 156);
LABEL_21:
v13 = (_DWORD *)v11[1];
if ( !v13 )
goto LABEL_40;
goto LABEL_22;
}
v11 = *(int **)(v4 + 156);
v12 = *v11;
LABEL_39:
HIDWORD(v8) = *(_DWORD *)(v12 + 4);
v13 = (_DWORD *)v11[1];
v6 = nullptr;
if ( !v13 )
{
LABEL_40:
if ( !(_DWORD)v8 )
continue;
a1[24] = 46;
a1[23] = i;
a1[25] = v4;
v7 = ((int (*)(void))a1[7])();
if ( !v7 )
return 0;
v13 = *(_DWORD **)(*(_DWORD *)(v4 + 156) + 4);
if ( !v13 )
{
v20 = 0;
LODWORD(v8) = 0;
continue;
}
if ( *v13 != 1 )
{
v20 = 0;
LODWORD(v8) = 0;
continue;
}
LODWORD(v8) = 0;
goto LABEL_56;
}
LABEL_22:
if ( *v13 != 1 )
continue;
if ( v20 )
goto LABEL_45;
LABEL_56:
if ( sub_A66B04((_DWORD *)v13[1], (_DWORD *)v8) )
{
v13 = *(_DWORD **)(*(_DWORD *)(v4 + 156) + 4);
LABEL_45:
LODWORD(v8) = v13[1];
v20 = 0;
continue;
}
v20 = 0;
a1[24] = 46;
a1[23] = i;
a1[25] = v4;
v7 = ((int (__fastcall *)(_DWORD, _DWORD *))a1[7])(0, a1);
if ( !v7 )
return 0;
}
v18 = *(_DWORD **)(v4 + 156);
if ( !v18 )
return v7;
if ( !*v18 || *(_DWORD *)*v18 )
{
LABEL_69:
v19 = (_DWORD *)v18[1];
if ( !v19 || *v19 )
return v7;
a1[24] = 46;
a1[23] = i;
a1[25] = v4;
return ((int (__fastcall *)(_DWORD, _DWORD *))a1[7])(0, a1);
}
else
{
a1[24] = 46;
a1[23] = i;
a1[25] = v4;
v7 = ((int (__fastcall *)(_DWORD, _DWORD *))a1[7])(0, a1);
if ( v7 )
{
v18 = *(_DWORD **)(v4 + 156);
goto LABEL_69;
}
return 0;
}
}