//
// ssl_cert_dup from 0x9a5a7c to 0x9a5e14 (920 bytes)
//
// 4 xrefs:
// > SSL_set_SSL_CTX @ 0x9ae408
// > SSL_new @ 0x9af630
// > SSL_dup @ 0x9afd7c
// > ??> @ 0x74c5c
//
// 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:06:50 +0000
//
_DWORD *__fastcall ssl_cert_dup(int a1)
{
_DWORD *v2; // r0
_DWORD *v3; // r7
int v4; // r5
int v5; // r0
int v6; // r3
int v7; // r4
_DWORD *v8; // r5
int v9; // r0
int v10; // r3
int v11; // r0
void *v12; // r0
void *v13; // r0
int v14; // r3
void *v15; // r0
int v16; // r2
void *v17; // r0
int v18; // r0
int v19; // r2
int v20; // r3
int v21; // r2
int v22; // r3
int v23; // r0
int v24; // r0
v2 = (_DWORD *)CRYPTO_zalloc(248, "ssl/ssl_cert.c", 83);
v3 = v2;
if ( v2 )
{
*v2 = &v2[((*(_DWORD *)a1 - (a1 + 20)) >> 2) + 5];
v2[60] = 1;
v4 = CRYPTO_THREAD_lock_new();
v3[61] = v4;
if ( v4 )
{
v5 = *(_DWORD *)(a1 + 4);
if ( v5 )
{
v3[1] = v5;
((void (*)(void))EVP_PKEY_up_ref)();
}
v6 = *(_DWORD *)(a1 + 12);
v7 = a1;
v8 = v3;
v3[2] = *(_DWORD *)(a1 + 8);
v3[3] = v6;
while ( 1 )
{
v9 = *(_DWORD *)(v7 + 20);
if ( v9 )
{
v8[5] = *(_DWORD *)(v7 + 20);
X509_up_ref(v9);
}
v10 = *(_DWORD *)(v7 + 24);
if ( v10 )
{
v8[6] = v10;
EVP_PKEY_up_ref(*(_DWORD *)(v7 + 24));
}
if ( *(_DWORD *)(v7 + 28) )
{
v11 = X509_chain_up_ref(*(_DWORD *)(v7 + 28));
v8[7] = v11;
if ( !v11 )
{
ERR_put_error(20, 221, 65, "ssl/ssl_cert.c", 124);
goto LABEL_34;
}
}
if ( *(_DWORD *)(v7 + 32) )
{
v12 = (void *)CRYPTO_malloc(*(_DWORD *)(v7 + 36), "ssl/ssl_cert.c", 131);
v8[8] = v12;
if ( !v12 )
{
ERR_put_error(20, 221, 65, "ssl/ssl_cert.c", 133);
ssl_cert_free((int)v3);
return nullptr;
}
v8[9] = *(_DWORD *)(v7 + 36);
memcpy(v12, *(const void **)(v7 + 32), *(_DWORD *)(v7 + 36));
}
v7 += 20;
v8 += 5;
if ( v7 == a1 + 140 )
{
if ( *(_DWORD *)(a1 + 168) )
{
v13 = (void *)CRYPTO_malloc(*(_DWORD *)(a1 + 172), "ssl/ssl_cert.c", 144);
v3[42] = v13;
if ( v13 )
{
memcpy(v13, *(const void **)(a1 + 168), *(_DWORD *)(a1 + 172));
v3[43] = *(_DWORD *)(a1 + 172);
v14 = *(_DWORD *)(a1 + 176);
if ( v14 )
goto LABEL_19;
LABEL_36:
v3[44] = v14;
LABEL_21:
v16 = *(_DWORD *)(a1 + 160);
v3[46] = 0;
if ( v16 )
{
v17 = (void *)CRYPTO_malloc(*(_DWORD *)(a1 + 164), "ssl/ssl_cert.c", 165);
v3[40] = v17;
if ( v17 )
{
memcpy(v17, *(const void **)(a1 + 160), *(_DWORD *)(a1 + 164));
v3[41] = *(_DWORD *)(a1 + 164);
goto LABEL_24;
}
}
else
{
LABEL_24:
v18 = *(_DWORD *)(a1 + 204);
v19 = *(_DWORD *)(a1 + 192);
v20 = *(_DWORD *)(a1 + 196);
v3[4] = *(_DWORD *)(a1 + 16);
v3[48] = v19;
v3[49] = v20;
if ( v18 )
{
X509_STORE_up_ref();
v3[51] = *(_DWORD *)(a1 + 204);
}
if ( *(_DWORD *)(a1 + 200) )
{
X509_STORE_up_ref();
v3[50] = *(_DWORD *)(a1 + 200);
}
v21 = *(_DWORD *)(a1 + 228);
v22 = *(_DWORD *)(a1 + 232);
v3[56] = *(_DWORD *)(a1 + 224);
v3[57] = v21;
v3[58] = v22;
if ( custom_exts_copy(v3 + 52, a1 + 208) )
{
if ( custom_exts_copy(v3 + 54, a1 + 216) )
{
v23 = *(_DWORD *)(a1 + 236);
if ( !v23 )
return v3;
v24 = CRYPTO_strdup(v23, "ssl/ssl_cert.c", 197);
v3[59] = v24;
if ( v24 )
return v3;
}
}
}
}
}
else
{
v3[42] = 0;
v14 = *(_DWORD *)(a1 + 176);
if ( !v14 )
goto LABEL_36;
LABEL_19:
v15 = (void *)CRYPTO_malloc(*(_DWORD *)(a1 + 180), "ssl/ssl_cert.c", 153);
v3[44] = v15;
if ( v15 )
{
memcpy(v15, *(const void **)(a1 + 176), *(_DWORD *)(a1 + 180));
v3[45] = *(_DWORD *)(a1 + 180);
goto LABEL_21;
}
}
LABEL_34:
ssl_cert_free((int)v3);
return nullptr;
}
}
}
ERR_put_error(20, 221, 65, "ssl/ssl_cert.c", 95);
CRYPTO_free(v3, "ssl/ssl_cert.c", 96);
return nullptr;
}
else
{
ERR_put_error(20, 221, 65, "ssl/ssl_cert.c", 87);
return nullptr;
}
}