CMS_ADD1_RECIPIENT_CERT(3SSL)
β¨ CMS_ADD1_RECIPIENT_CERT β¨
okay bestie, welcome to the OpenSSL section 3 ssl glow-up π
this one's all about slipping extra recipients into a CMS enveloped data structure, and honestly? it's giving main character energy. let's get into it.
π NAME π
CMS_add1_recipient, CMS_add1_recipient_cert, CMS_add0_recipient_key β add recipients to a CMS enveloped data structure π«Ά
πΈ SYNOPSIS πΈ
#include <openssl/cms.h>
CMS_RecipientInfo *CMS_add1_recipient(CMS_ContentInfo *cms, X509 *recip,
EVP_PKEY *originatorPrivKey,
X509 *originator, unsigned int flags);
CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,
X509 *recip, unsigned int flags);
CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,
unsigned char *key, size_t keylen,
unsigned char *id, size_t idlen,
ASN1_GENERALIZEDTIME *date,
ASN1_OBJECT *otherTypeId,
ASN1_TYPE *otherType);
(yes the third one got its return type cropped in the original, no we are not fixing it, we reproduce it exactly, periodt π)
π DESCRIPTION π
so like, three functions, three vibes:
CMS_add1_recipient()β adds recipient recip and hands over the originator pkey originatorPrivKey plus the originator certificate originator toCMS_ContentInfo. π the originator-related fields are only relevant when the keyAgreement method of providing of the shared key is in use β so if you're doing it any other way, those fields are just sitting there, decorative, iykyk πCMS_add1_recipient_cert()β adds recipient recip to theCMS_ContentInfoenveloped data structure cms, as a KeyTransRecipientInfo or KEMRecipientInfo structure, or as a KeyAgreeRecipientInfo structure with an ephemeral key. three possible fits, one function, she's versatile πCMS_add0_recipient_key()β adds symmetric key key of length keylen using wrapping algorithm nid, identifier id of length idlen, and the optional values date, otherTypeId and otherType, to theCMS_ContentInfoenveloped data structure cms, as a KEKRecipientInfo structure. π
and the big rule, bestie: the CMS_ContentInfo structure should be obtained from an initial call to CMS_encrypt() with the flag CMS_PARTIAL set. no CMS_PARTIAL, no party π no cap.
π¦ NOTES π¦
the main purpose of this function is to provide finer control over a CMS enveloped data structure β you know, for the situations where the simpler CMS_encrypt() function defaults just aren't the moment. π
for example, if one or more KEKRecipientInfo structures need to be added. new attributes can also be added using the returned CMS_RecipientInfo structure and the CMS attribute utility functions. obsessed.
OpenSSL will by default identify recipient certificates using issuer name and serial number. but if CMS_USE_KEYID is set, it will use the subject key identifier value instead. β‘ and heads up: an error occurs if all recipient certificates do not have a subject key identifier extension. so check your certs before you come for her, fr fr π
currently, only AES based key wrapping algorithms are supported for nid, specifically:
NID_id_aes128_wrapNID_id_aes192_wrapNID_id_aes256_wrap
and if nid is set to NID_undef then an AES wrap algorithm will be used consistent with keylen. auto-select, iconic behavior π
π RETURN VALUES π
CMS_add1_recipient_cert() and CMS_add0_recipient_key() return an internal pointer to the CMS_RecipientInfo structure just added, or NULL if an error occurs. π if you get NULL, that's your sign to go check things.
π₯ SEE ALSO π₯
π HISTORY π
CMS_add1_recipient_cert and CMS_add0_recipient_key were added in OpenSSL 3.0. glow-up era β¨
π COPYRIGHT π
Copyright 2008-2025 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 OpenSSL 4.0.3, dated 2026-09-29, living in the CMS_ADD1_RECIPIENT_CERT(3SSL) manual. slay, go add your recipients π
π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms