//
// X509_PURPOSE_add from 0xa6f344 to 0xa6f590 (588 bytes)
//
// 1 xrefs:
// > ??> @ 0x8300c
//
// 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:41 +0000
//
int __fastcall X509_PURPOSE_add(int a1, int a2, int a3, int a4, const char *a5, const char *a6, int a7)
{
unsigned int v9; // r7
int v11; // r0
char *v12; // r0
char *v13; // r4
void *v14; // r0
int v15; // r3
bool v16; // zf
int v17; // r2
_DWORD *v19; // r0
int v20; // r4
int v21; // r2
void *v22; // r0
int v23; // r3
bool v24; // zf
int *v25; // r0
int v26; // r2
int v27; // r2
v9 = a3 & 0xFFFFFFFE;
v11 = X509_PURPOSE_get_by_id(a1);
if ( v11 != -1 )
{
v12 = X509_PURPOSE_get0(v11);
v13 = v12;
if ( (*((_DWORD *)v12 + 2) & 2) != 0 )
{
CRYPTO_free(*((void **)v12 + 4), (int)"crypto/x509v3/v3_purp.c", 175);
CRYPTO_free(*((void **)v13 + 5), (int)"crypto/x509v3/v3_purp.c", 176);
}
*((_DWORD *)v13 + 4) = CRYPTO_strdup(a5, (int)"crypto/x509v3/v3_purp.c", 179);
v14 = CRYPTO_strdup(a6, (int)"crypto/x509v3/v3_purp.c", 180);
v15 = *((_DWORD *)v13 + 4);
v16 = v15 == 0;
if ( v15 )
v16 = v14 == nullptr;
*((_DWORD *)v13 + 5) = v14;
if ( !v16 )
{
v17 = *((_DWORD *)v13 + 2) & 1 | 2 | v9;
*(_DWORD *)v13 = a1;
*((_DWORD *)v13 + 1) = a2;
*((_DWORD *)v13 + 3) = a4;
*((_DWORD *)v13 + 6) = a7;
*((_DWORD *)v13 + 2) = v17;
return 1;
}
v21 = 182;
goto LABEL_23;
}
v19 = CRYPTO_malloc(&dword_1C, (int)"crypto/x509v3/v3_purp.c", 165);
v20 = (int)v19;
if ( v19 )
{
v19[2] = 1;
v19[4] = CRYPTO_strdup(a5, (int)"crypto/x509v3/v3_purp.c", 179);
v22 = CRYPTO_strdup(a6, (int)"crypto/x509v3/v3_purp.c", 180);
v23 = *(_DWORD *)(v20 + 16);
v24 = v23 == 0;
if ( v23 )
v24 = v22 == nullptr;
*(_DWORD *)(v20 + 20) = v22;
if ( v24 )
{
v27 = 182;
}
else
{
v25 = (int *)dword_D35AE0;
v26 = *(_DWORD *)(v20 + 8) & 1 | 2 | v9;
v16 = dword_D35AE0 == 0;
*(_DWORD *)v20 = a1;
*(_DWORD *)(v20 + 4) = a2;
*(_DWORD *)(v20 + 12) = a4;
*(_DWORD *)(v20 + 24) = a7;
*(_DWORD *)(v20 + 8) = v26;
if ( !v16 || (v25 = OPENSSL_sk_new((int)sub_A6EAF8), (dword_D35AE0 = (int)v25) != 0) )
{
if ( OPENSSL_sk_push(v25, v20) )
return 1;
ERR_put_error(34, 137, 65, (int)"crypto/x509v3/v3_purp.c", 203);
goto LABEL_17;
}
v27 = 199;
}
ERR_put_error(34, 137, 65, (int)"crypto/x509v3/v3_purp.c", v27);
LABEL_17:
CRYPTO_free(*(void **)(v20 + 16), (int)"crypto/x509v3/v3_purp.c", 210);
CRYPTO_free(*(void **)(v20 + 20), (int)"crypto/x509v3/v3_purp.c", 211);
CRYPTO_free((void *)v20, (int)"crypto/x509v3/v3_purp.c", 212);
return 0;
}
v21 = 166;
LABEL_23:
ERR_put_error(34, 137, 65, (int)"crypto/x509v3/v3_purp.c", v21);
return 0;
}