//
// CMS_add0_cert from 0xe20198 to 0xe202c4 (300 bytes)
//
// 2 xrefs:
// > CMS_add1_cert @ 0xe202d4
// > ??> @ 0x94d58
//
// 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
//
__int64 __fastcall CMS_add0_cert(__int64 *a1, __int64 a2)
{
int v4; // w0
unsigned int **v5; // x20
int v6; // w19
bool v7; // cc
int v8; // w1
__int64 v9; // x0
__int64 v11; // x0
v4 = OBJ_obj2nid(*a1);
if ( v4 == 22 )
{
v5 = (unsigned int **)(a1[1] + 24);
if ( a1[1] != -24 )
goto LABEL_4;
return 0;
}
if ( v4 != 23 )
{
ERR_put_error(46, 128, 152, (__int64)"crypto/cms/cms_lib.c", 354);
return 0;
}
v5 = *(unsigned int ***)(a1[1] + 8);
if ( !v5 )
return 0;
LABEL_4:
v6 = 0;
while ( 1 )
{
v7 = v6 < (int)OPENSSL_sk_num(*v5);
v8 = v6++;
if ( !v7 )
break;
v9 = OPENSSL_sk_value((__int64)*v5, v8);
if ( !*(_DWORD *)v9 && !(unsigned int)X509_cmp(*(_QWORD *)(v9 + 8), a2) )
{
ERR_put_error(46, 164, 175, (__int64)"crypto/cms/cms_lib.c", 394);
return 0;
}
}
v11 = CMS_add0_CertificateChoices(a1);
if ( !v11 )
return 0;
*(_QWORD *)(v11 + 8) = a2;
*(_DWORD *)v11 = 0;
return 1;
}