//
// sub_8422D8 from 0x8422d8 to 0x8424b0 (472 bytes)
//
// 12 xrefs:
// > X509_STORE_CTX_init @ 0x845e8c
// > X509_STORE_CTX_init @ 0x845e94
// > X509_STORE_CTX_init @ 0x845f4c
// > X509_STORE_CTX_init @ 0x845f68
// > X509_STORE_CTX_init @ 0x84604c
// > X509_STORE_CTX_init @ 0x846050
// > X509_STORE_CTX_init @ 0x8460a8
// > X509_STORE_CTX_init @ 0x8460ac
// > ??> @ 0x846124
// > ??> @ 0x84614c
// > ??> @ 0x84616c
// > ??> @ 0x84617c
//
// 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 sub_8422D8(int a1)
{
int v1; // r6
signed int i; // r5
int v5; // r0
if ( *(_DWORD *)(a1 + 120) )
return 1;
if ( *(_DWORD *)(a1 + 132) )
{
v1 = OPENSSL_sk_push(*(int **)(a1 + 80), 0);
if ( !v1 )
{
ERR_put_error(11, 145, 65, (int)"crypto/x509/x509_vfy.c", 1575);
*(_DWORD *)(a1 + 96) = 17;
return v1;
}
}
v1 = X509_policy_check(
a1 + 84,
a1 + 88,
*(_DWORD *)(a1 + 80),
*(_DWORD *)(*(_DWORD *)(a1 + 16) + 32),
*(_DWORD *)(*(_DWORD *)(a1 + 16) + 12));
if ( *(_DWORD *)(a1 + 132) )
OPENSSL_sk_pop(*(int **)(a1 + 80));
if ( !v1 )
{
ERR_put_error(11, 145, 65, (int)"crypto/x509/x509_vfy.c", 1585);
*(_DWORD *)(a1 + 96) = 17;
return v1;
}
if ( v1 == -1 )
{
for ( i = 1; i < OPENSSL_sk_num(*(_DWORD *)(a1 + 80)); ++i )
{
v5 = OPENSSL_sk_value(*(_DWORD **)(a1 + 80), i);
if ( (*(_DWORD *)(v5 + 112) & 0x800) != 0 )
{
*(_DWORD *)(a1 + 100) = v5;
*(_DWORD *)(a1 + 92) = i;
*(_DWORD *)(a1 + 96) = 42;
v1 = (*(int (__fastcall **)(_DWORD, int))(a1 + 28))(0, a1);
if ( !v1 )
return v1;
}
}
return 1;
}
if ( v1 != -2 )
{
if ( v1 != 1 )
{
ERR_put_error(11, 145, 68, (int)"crypto/x509/x509_vfy.c", 1611);
return 0;
}
if ( (*(_DWORD *)(*(_DWORD *)(a1 + 16) + 12) & 0x800) != 0 )
{
*(_DWORD *)(a1 + 100) = 0;
return (*(int (__fastcall **)(int, int))(a1 + 28))(2, a1) != 0;
}
return 1;
}
*(_DWORD *)(a1 + 96) = 43;
*(_DWORD *)(a1 + 100) = 0;
return (*(int (**)(void))(a1 + 28))();
}