//
// X509_STORE_CTX_purpose_inherit from 0xa5a544 to 0xa5a6ac (360 bytes)
//
// 3 xrefs:
// > X509_STORE_CTX_set_purpose @ 0xa5a6d0
// > X509_STORE_CTX_set_trust @ 0xa5a6e0
// > ??> @ 0x8120c
//
// 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:28 +0000
//
int __fastcall X509_STORE_CTX_purpose_inherit(int a1, int a2, int a3, int a4)
{
int v4; // r8
int v7; // r4
int v8; // r0
int v9; // r5
int v10; // r3
v4 = a3;
v7 = a4;
if ( !a3 )
{
if ( !a2 )
{
if ( !a4 )
return 1;
if ( X509_TRUST_get_by_id(a4) != -1 )
{
v10 = *(_DWORD *)(a1 + 16);
goto LABEL_8;
}
LABEL_22:
ERR_put_error(11, 134, 120, (int)"crypto/x509/x509_vfy.c", 2188);
return 0;
}
v4 = a2;
}
if ( X509_PURPOSE_get_by_id(v4) == -1 )
{
ERR_put_error(11, 134, 121, (int)"crypto/x509/x509_vfy.c", 2162);
return 0;
}
v8 = X509_PURPOSE_get0();
v9 = *(_DWORD *)(v8 + 4);
if ( !v9 )
{
if ( X509_PURPOSE_get_by_id(a2) == -1 )
{
ERR_put_error(11, 134, 121, (int)"crypto/x509/x509_vfy.c", 2175);
return v9;
}
v8 = X509_PURPOSE_get0();
}
if ( !v7 )
{
v7 = *(_DWORD *)(v8 + 4);
if ( !v7 )
{
v10 = *(_DWORD *)(a1 + 16);
if ( *(_DWORD *)(v10 + 16) )
return 1;
goto LABEL_7;
}
}
if ( X509_TRUST_get_by_id(v7) == -1 )
goto LABEL_22;
v10 = *(_DWORD *)(a1 + 16);
if ( *(_DWORD *)(v10 + 16) )
{
LABEL_8:
if ( !*(_DWORD *)(v10 + 20) )
*(_DWORD *)(v10 + 20) = v7;
return 1;
}
LABEL_7:
*(_DWORD *)(v10 + 16) = v4;
if ( v7 )
goto LABEL_8;
return 1;
}