CMS_GET0_RECIPIENTINFOS(3)
π CMS_GET0_RECIPIENTINFOS(3) π
okay so bestie, welcome to the Library Functions Manual page for CMS_GET0_RECIPIENTINFOS(3) β this is the whole CMS EnvelopedData RecipientInfo situation, and it's lowkey iconic because it lets your app do recipient-key detective work by hand instead of just calling the simpler CMS_decrypt(3). no cap, it's giving β¨plumbingβ¨. Let's go.
π NAME π
CMS_get0_RecipientInfos, CMS_RecipientInfo_type, CMS_RecipientInfo_ktri_get0_signer_id, CMS_RecipientInfo_ktri_cert_cmp, CMS_RecipientInfo_set0_pkey, CMS_RecipientInfo_kekri_get0_id, CMS_RecipientInfo_kekri_id_cmp, CMS_RecipientInfo_set0_key, CMS_RecipientInfo_decrypt, CMS_RecipientInfo_encrypt β CMS EnvelopedData RecipientInfo routines
β¨ SYNOPSIS β¨
library βlibcryptoβ #include <openssl/cms.h>
STACK_OF(CMS_RecipientInfo) *
CMS_get0_RecipientInfos(CMS_ContentInfo *cms);
int
CMS_RecipientInfo_type(CMS_RecipientInfo *ri);
int
CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
ASN1_OCTET_STRING **keyid, X509_NAME **issuer, ASN1_INTEGER **sno);
int
CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri,
X509 *certificate);
int
CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
int
CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,
X509_ALGOR **palg, ASN1_OCTET_STRING **pid,
ASN1_GENERALIZEDTIME **pdate, ASN1_OBJECT **potherid,
ASN1_TYPE **pothertype);
int
CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,
const unsigned char *id, size_t idlen);
int
CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, unsigned char *key,
size_t keylen);
int
CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
int
CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
π DESCRIPTION π
Okay so here's the rundown, function by function, and I'm not skipping a single crumb:
CMS_get0_RecipientInfos()β returns all theRecipientInfostructures associated with theEnvelopedDatastructurecms. It's giving "gimme the whole stack" π .CMS_RecipientInfo_type()β returns the type ofri:CMS_RECIPINFO_TRANSforKeyTransRecipientInfo,CMS_RECIPINFO_AGREEforKeyAgreeRecipientInfo,CMS_RECIPINFO_KEKforKEKRecipientInfo,CMS_RECIPINFO_PASSforPasswordRecipientinfo, orCMS_RECIPINFO_OTHERforOtherRecipientInfo.CMS_RecipientInfo_ktri_get0_signer_id()β retrieves the certificateRecipientIdentifierassociated with theKeyTransRecipientInfostructureri. Either theSubjectKeyIdentifierwill be set inkeyidor both issuer name and serial number inissuerandsno.CMS_RecipientInfo_ktri_cert_cmp()β compares the certificate against theKeyTransRecipientInfostructureri.CMS_RecipientInfo_set0_pkey()β associates the private keypkeywith theKeyTransRecipientInfostructureri.CMS_RecipientInfo_kekri_get0_id()β retrieves the key information from theKEKRecipientInfostructureri. Fields are copied out as follows:keyEncryptionAlgorithmto*palg,keyIdentifierto*pid,dateto*pdate(optional),other.keyAttrIdto*potherid(optional),other.keyAttrto*pothertype(optional). Where a field is optional and absent,NULLis written to the corresponding parameter. Parameters the application is not interested in can be set toNULL.CMS_RecipientInfo_kekri_id_cmp()β compares the identifier in theidandidlenparameters against thekeyIdentifierfield of theKEKRecipientInfostructureri.CMS_RecipientInfo_set0_key()β associates the symmetric key of lengthkeylenwith theKEKRecipientInfostructureri.CMS_RecipientInfo_decrypt()β attempts to decrypt theRecipientInfostructureriincms. A key must have been associated withrifirst. π«ΆCMS_RecipientInfo_encrypt()β attempts to encrypt theRecipientInfostructureriincms. A key must have been associated withrifirst and the content encryption key must be available, for example by a previous call toCMS_RecipientInfo_decrypt().
The main purpose of these functions is to enable an application to lookup recipient keys using any appropriate technique when the simpler method of CMS_decrypt(3) is not appropriate. Basically: when CMS_decrypt(3) isn't the vibe, you get to do the lookup yourself.
In typical usage, an application retrieves all CMS_RecipientInfo structures using CMS_get0_RecipientInfos() and checks the type of each using CMS_RecipientInfo_type(). Depending on the type, the CMS_RecipientInfo structure can be ignored or its key identifier data retrieved using an appropriate function. If the corresponding secret or private key can be obtained by any appropriate means, it can then be associated with the structure and CMS_RecipientInfo_decrypt() called. If successful, CMS_decrypt(3) can be called with a NULL key to decrypt the enveloped content.
The function CMS_RecipientInfo_encrypt() can be used to add a new recipient to an existing enveloped data structure. Typically an application will first decrypt an appropriate CMS_RecipientInfo structure to make the content encrypt key available. It will then add a new recipient using a function such as CMS_add1_recipient_cert(3) and finally encrypt the content encryption key using CMS_RecipientInfo_encrypt().
π₯ RETURN VALUES π₯
CMS_get0_RecipientInfos()β returns an internal pointer to all theCMS_RecipientInfostructures, orNULLif an error occurs.CMS_RecipientInfo_type()β returns an integer constant.CMS_RecipientInfo_ktri_get0_signer_id(),CMS_RecipientInfo_set0_pkey(),CMS_RecipientInfo_kekri_get0_id(),CMS_RecipientInfo_set0_key(),CMS_RecipientInfo_decrypt(), andCMS_RecipientInfo_encrypt()β return1for success or0if an error occurs.CMS_RecipientInfo_ktri_cert_cmp()andCMS_RecipientInfo_kekri_id_cmp()β return0whenrimatches or non-zero otherwise.- Any error can be obtained from
ERR_get_error(3).
π¦ SEE ALSO π¦
π STANDARDS π
RFC 5652 Cryptographic Message Syntax (CMS):
- section 6.1: EnvelopedData Type
- section 6.2: RecipientInfo Type
- section 6.2.1: KeyTransRecipientInfo Type
- section 6.2.3: KEKRecipientInfo Type
πΈ HISTORY πΈ
These functions first appeared in OpenSSL 0.9.8h, except that CMS_RecipientInfo_encrypt() first appeared in OpenSSL 1.0.2. They have been available since OpenBSD 6.7.
okay that's the whole page, bestie. this Debian version is dated June 8, 2025, and it's for CMS_GET0_RECIPIENTINFOS(3) β go decrypt something cute πβ¨ periodt.
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2008, 2013 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms