//
// X509_STORE_CTX_purpose_inherit from 0x845944 to 0x845aac (360 bytes)
//
// 3 xrefs:
// > X509_STORE_CTX_set_purpose @ 0x845ad0
// > X509_STORE_CTX_set_trust @ 0x845ae0
// > ??> @ 0x6778c
//
// 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
//
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;
}