//
// NAME_CONSTRAINTS_check from 0x858290 to 0x858388 (248 bytes)
//
// 2 xrefs:
// > sub_843DE0 @ 0x844d80
// > ??> @ 0x675cc
//
// 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 NAME_CONSTRAINTS_check(int a1, int *a2)
{
int *subject_name; // r7
int result; // r0
int index_by_NID; // r4
int entry; // r0
signed int v8; // r4
_DWORD *v9; // r0
int v10; // r0
unsigned int v11; // r1
int v13; // [sp+0h] [bp-8h] BYREF
int data; // [sp+4h] [bp-4h]
subject_name = (int *)X509_get_subject_name(a1);
if ( (int)X509_NAME_entry_count(subject_name) > 0 )
{
v13 = 4;
data = (int)subject_name;
result = sub_857F64(&v13, a2);
if ( result )
return result;
index_by_NID = -1;
v13 = 1;
while ( 1 )
{
index_by_NID = X509_NAME_get_index_by_NID(subject_name, 0x30u, index_by_NID);
if ( index_by_NID == -1 )
break;
entry = X509_NAME_get_entry(subject_name, index_by_NID);
data = X509_NAME_ENTRY_get_data(entry);
if ( *(_DWORD *)(data + 4) != 22 )
return 53;
result = sub_857F64(&v13, a2);
if ( result )
return result;
}
}
v8 = 0;
while ( 1 )
{
v10 = OPENSSL_sk_num(*(_DWORD *)(a1 + 144));
v11 = v8;
if ( v8++ >= v10 )
break;
v9 = (_DWORD *)OPENSSL_sk_value(*(_DWORD **)(a1 + 144), v11);
result = sub_857F64(v9, a2);
if ( result )
return result;
}
return 0;
}