CMS_GET0_RECIPIENTINFOS(3ossl)
β¨ CMS_GET0_RECIPIENTINFOS(3ossl) β¨
okay so this is the OpenSSL manpage for the CMS envelopedData RecipientInfo routines β it's filed under CMS_GET0_RECIPIENTINFOS(3ossl) in case you were wondering, and bestie, it's literally all about how you find, poke at, and unlock the recipient info blobs inside a CMS EnvelopedData structure. no cap, it's giving "backstage pass to the encryption key" energy π
πΈ 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_kari_set0_pkey_and_peer, CMS_RecipientInfo_kari_set0_pkey, CMS_RecipientInfo_kekri_id_cmp, CMS_RecipientInfo_set0_key, CMS_RecipientInfo_decrypt, CMS_RecipientInfo_encrypt β CMS envelopedData RecipientInfo routines π
π¦ SYNOPSIS π¦
#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 *cert);
int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
int CMS_RecipientInfo_kari_set0_pkey_and_peer(CMS_RecipientInfo *ri,
EVP_PKEY *pk, X509 *peer);
int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);
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 whole cast, one by one π
CMS_get0_RecipientInfos()β hands you all theCMS_RecipientInfostructures chillin' inside a CMS EnvelopedData structure. the whole squad. π«ΆCMS_RecipientInfo_type()β tells you what kind ofCMS_RecipientInfostructureriactually is. right now it'll return one ofCMS_RECIPINFO_TRANS,CMS_RECIPINFO_AGREE,CMS_RECIPINFO_KEK,CMS_RECIPINFO_PASS, orCMS_RECIPINFO_OTHER. vibe check, basically. β¨CMS_RecipientInfo_ktri_get0_signer_id()β pulls out the certificate recipient identifier that goes with a specificCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_TRANS. either the key identifier gets set inkeyid, or both the issuer name and serial number get set inissuerandsno. it's one or the other, not both, iykyk.CMS_RecipientInfo_ktri_cert_cmp()β compares the certificatecertagainst theCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_TRANS. returns zero if the comparison is successful and non zero if not. yes bestie, zero = slay here, non zero = not it. πCMS_RecipientInfo_set0_pkey()β associates the private keypkeywith theCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_TRANS. matching them up like a group chat admin πCMS_RecipientInfo_kari_set0_pkey_and_peer()β associates the private keypkeyand the peer certificatepeerwith theCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_AGREE. two for one, we love to see it.CMS_RecipientInfo_kari_set0_pkey()β associates just the private keypkeywith theCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_AGREE. the solo version. still iconic.CMS_RecipientInfo_kekri_get0_id()β retrieves the key information from theCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_KEK. any of the remaining parameters can beNULLif the application isn't interested in that field's value β no pressure to take them all. where a field is optional and absent,NULLgets written to the corresponding parameter. so: thekeyEncryptionAlgorithmfield goes topalg, thekeyIdentifierfield goes topid, the date field (if present) goes topdate, and if theotherfield is present, itskeyAttrIdandkeyAttrcomponents get written to the parameterspotheridandpothertype. πCMS_RecipientInfo_kekri_id_cmp()β compares the ID in theidandidlenparameters against thekeyIdentifierof theCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_KEK. returns zero if the comparison is successful and non zero if not. (same deal as before: zero is the good one π)CMS_RecipientInfo_set0_key()β associates the symmetric keykeyof lengthkeylenwith theCMS_RecipientInfostructureri, which must be of typeCMS_RECIPINFO_KEK.CMS_RecipientInfo_decrypt()β attempts to decrypt theCMS_RecipientInfostructureriinside the structurecms. β οΈ a key must have been associated with the structure first β no key, no decrypt, periodt.CMS_RecipientInfo_encrypt()β attempts to encrypt theCMS_RecipientInfostructureriinside the structurecms. a key must have been associated with the structure first, and the content encryption key must be available β like, for example, from a previous call toCMS_RecipientInfo_decrypt(). both conditions, bestie, it's not optional. π
π§ NOTES π§
the main purpose of these functions is literally to let an application look up recipient keys using whatever technique fits, for when the simpler method of CMS_decrypt() just isn't appropriate. it's the "I'll handle this myself" route. π₯
in typical usage, an application will retrieve all the CMS_RecipientInfo structures using CMS_get0_RecipientInfos() and then check the type of each one using CMS_RecipientInfo_type(). depending on that type, the CMS_RecipientInfo structure can either be ignored, or its key identifier data can be retrieved using an appropriate function. then, if the corresponding secret or private key can be obtained by any appropriate means, it can be associated with the structure and CMS_RecipientInfo_decrypt() can be called. if that works out, CMS_decrypt() can be called with a NULL key to decrypt the enveloped content. π
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, then add a new recipient using a function such as CMS_add1_recipient_cert(), and finally encrypt the content encryption key using CMS_RecipientInfo_encrypt(). it's a whole three-step glow-up routine β¨
β RETURN VALUES β
CMS_get0_RecipientInfos()β returns all theCMS_RecipientInfostructures, orNULLif an error occurs. πCMS_RecipientInfo_ktri_get0_signer_id(),CMS_RecipientInfo_set0_pkey(),CMS_RecipientInfo_kekri_get0_id(),CMS_RecipientInfo_set0_key()andCMS_RecipientInfo_decrypt()β return1for success or0if an error occurs.CMS_RecipientInfo_encrypt()also returns1for success or0if an error occurs. (yes, it says that twice, and we're keeping it, that's the original's whole thing π«Ά)CMS_RecipientInfo_ktri_cert_cmp()andCMS_RecipientInfo_kekri_cmp()β return0for a successful comparison and non zero otherwise. remember: zero is the win here π- any error can be obtained from
ERR_get_error(3). go check there if something's acting up.
π SEE ALSO π
ERR_get_error(3), CMS_decrypt(3)
π HISTORY π
CMS_RecipientInfo_kari_set0_pkey_and_peer and CMS_RecipientInfo_kari_set0_pkey were added in OpenSSL 3.0. newer arrivals, but already main characters π
π COPYRIGHT π
Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page bestie π«Ά this was CMS_GET0_RECIPIENTINFOS(3ossl) from OpenSSL version 3.5.6, dated 2026-04-07 β go decrypt something iconic πβ¨π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms