//
// CMS_set1_signers_certs from 0x876c74 to 0x876e00 (396 bytes)
//
// 1 xrefs:
// > ??> @ 0x6a5dc
//
// 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 CMS_set1_signers_certs(int *a1, _DWORD *a2, char a3)
{
int v6; // r8
int v8; // r9
signed int v9; // r5
_DWORD *v10; // r10
int v11; // r0
signed int v12; // r4
int v13; // r6
int v14; // r11
int v15; // r0
unsigned int v16; // r1
bool v17; // cc
signed int v18; // r4
int v19; // r0
unsigned int v20; // r1
_DWORD *v21; // r0
int v22; // [sp+8h] [bp-Ch]
int v23; // [sp+Ch] [bp-8h]
if ( OBJ_obj2nid(*a1) == (_BYTE *)&dword_14 + 2 )
{
v6 = a1[1];
if ( v6 )
{
v8 = 0;
v22 = a3 & 0x10;
v9 = 0;
v10 = *(_DWORD **)(v6 + 12);
while ( v9 < OPENSSL_sk_num(*(_DWORD *)(v6 + 20)) )
{
v11 = OPENSSL_sk_value(*(_DWORD **)(v6 + 20), v9);
v12 = *(_DWORD *)(v11 + 28);
v13 = v11;
if ( !v12 )
{
do
{
v15 = OPENSSL_sk_num((int)a2);
v16 = v12;
v17 = v12++ < v15;
if ( !v17 )
{
if ( *(_DWORD *)(v13 + 28) )
goto LABEL_5;
goto LABEL_12;
}
v14 = OPENSSL_sk_value(a2, v16);
}
while ( CMS_SignerInfo_cert_cmp(v13, v14) );
CMS_SignerInfo_set1_signer_cert(v13, v14);
++v8;
if ( *(_DWORD *)(v13 + 28) )
goto LABEL_5;
LABEL_12:
if ( !v22 )
{
v18 = 0;
while ( 1 )
{
v19 = OPENSSL_sk_num((int)v10);
v20 = v18;
v17 = v18++ < v19;
if ( !v17 )
break;
v21 = (_DWORD *)OPENSSL_sk_value(v10, v20);
if ( !*v21 )
{
v23 = v21[1];
if ( !CMS_SignerInfo_cert_cmp(v13, v23) )
{
CMS_SignerInfo_set1_signer_cert(v13, v23);
++v8;
break;
}
}
}
}
}
LABEL_5:
++v9;
}
return v8;
}
else
{
return -1;
}
}
else
{
ERR_put_error(46, 133, 108, (int)"crypto/cms/cms_sd.c", 26);
return -1;
}
}