//
// CMS_add1_recipient_cert from 0xe1e96c to 0xe1eb40 (468 bytes)
//
// 1 xrefs:
// > ??> @ 0xc04b0
//
// 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_add1_recipient_cert(__int64 *a1, __int64 a2, unsigned int a3)
{
__int64 v5; // x22
__int64 v6; // x19
__int64 v7; // x0
__int64 v8; // x23
int ri_type; // w0
__int64 v11; // x0
_QWORD *v12; // x26
__int64 v13; // x3
__int64 v14; // x2
__int64 v15; // x0
__int64 *v16; // x0
v5 = cms_get0_enveloped(a1);
if ( !v5 )
{
v6 = 0;
goto LABEL_10;
}
v6 = ASN1_item_new((__int64)CMS_RecipientInfo_it);
if ( !v6 )
goto LABEL_20;
v7 = X509_get0_pubkey(a2);
v8 = v7;
if ( !v7 )
{
ERR_put_error(46, 101, 113, (__int64)"crypto/cms/cms_env.c", 195);
goto LABEL_10;
}
ri_type = cms_pkey_get_ri_type(v7);
if ( !ri_type )
{
v11 = ASN1_item_new((__int64)&CMS_KeyTransRecipientInfo_it);
*(_QWORD *)(v6 + 8) = v11;
v12 = (_QWORD *)v11;
if ( !v11 )
goto LABEL_10;
*(_DWORD *)v6 = 0;
if ( (a3 & 0x10000) != 0 )
{
v13 = 2;
v14 = 1;
}
else
{
v13 = 0;
v14 = 0;
}
v15 = *(_QWORD *)(v11 + 8);
*v12 = v13;
if ( !(unsigned int)cms_set1_SignerIdentifier(v15, a2, v14) )
goto LABEL_10;
X509_up_ref(a2);
EVP_PKEY_up_ref(v8);
v12[5] = v8;
v12[4] = a2;
if ( (a3 & 0x40000) != 0 )
{
v16 = (__int64 *)EVP_PKEY_CTX_new(v8, 0);
v12[6] = v16;
if ( !v16 || (int)EVP_PKEY_encrypt_init(v16) <= 0 )
goto LABEL_10;
}
else if ( !(unsigned int)cms_env_asn1_ctrl((int *)v6) )
{
goto LABEL_10;
}
goto LABEL_7;
}
if ( ri_type == 1 )
{
if ( (unsigned int)cms_RecipientInfo_kari_init(v6, a2, v8, a3) )
{
LABEL_7:
if ( (unsigned int)OPENSSL_sk_push(*(int **)(v5 + 16), v6) )
return v6;
LABEL_20:
ERR_put_error(46, 101, 65, (__int64)"crypto/cms/cms_env.c", 224);
}
}
else
{
ERR_put_error(46, 101, 125, (__int64)"crypto/cms/cms_env.c", 213);
}
LABEL_10:
ASN1_item_free(v6, CMS_RecipientInfo_it);
return 0;
}