CMS_ADD1_SIGNER(3)
π CMS_ADD1_SIGNER(3) π
okay so bestie, you're reading the libcrypto manual page for CMS_add1_signer and CMS_SignerInfo_sign β yes, section 3, the library functions girlies. sit down, hydrate, and let's get into it π«Ά
β¨ NAME β¨
CMS_add1_signer, CMS_SignerInfo_sign β add a signer to a CMS SignedData structure. that's the whole vibe π
πΈ SYNOPSIS πΈ
library libcrypto
#include <openssl/cms.h>
CMS_SignerInfo *
CMS_add1_signer(CMS_ContentInfo *cms, X509 *signcert, EVP_PKEY *pkey,
const EVP_MD *md, unsigned int flags);
int
CMS_SignerInfo_sign(CMS_SignerInfo *si);
π¦ DESCRIPTION π¦
CMS_add1_signer() is literally the main character here π. it adds a signer β with certificate signcert and private key pkey, using message digest md β to the signerInfos field of the SignedData structure cms. and where does cms come from? it should have been obtained from an initial call to CMS_sign(3) with the flag CMS_PARTIAL set, OR it can be a valid SignedData structure in the case of re-signing. either way, she's ready π
if md is NULL, then the default digest for the public key algorithm of pkey is used. no thoughts, just defaults β¨
unless the CMS_REUSE_DIGEST flag is set, the cms structure remains incomplete and must be finalized either by streaming (if applicable) or by a call to CMS_final(3). don't leave her unfinished, that's not the vibe π
the main purpose of CMS_add1_signer() is to provide finer control over a CMS SignedData structure where the simpler CMS_sign(3) function defaults are not appropriate β for example if multiple signers or non default digest algorithms are needed. also, new attributes can be added using the returned CMS_SignerInfo structure and the CMS attribute utility functions or the CMS signed receipt request functions. so much range, honestly π
any of the following flags (OR'ed together) can be passed in the flags parameter:
CMS_REUSE_DIGESTβ attempt to copy the content digest value from one of the existingCMS_SignerInfostructures incmswhile adding another signer. an error occurs if a matching digest value cannot be found to copy. thecmsstructure will be valid and finalized when this flag is set. reuse, recycle, slay β»οΈCMS_PARTIALβ if this flag is set in addition toCMS_REUSE_DIGEST, the returnedCMS_SignerInfostructure will not be finalized so additional attributes can be added. in this case an explicit call toCMS_SignerInfo_sign()is needed to finalize it. yes, you have to actually finish the job πCMS_NOCERTSβ do not add the signer's certificate to thecertificatesfield ofcms. the signer's certificate must still be supplied in thesigncertparameter though. this flag can reduce the size of the signature if the signer's certificate can be obtained by other means, for example from a previously signed message. tiny signature, big brain energy π§ β¨CMS_NOATTRβ leave thesignedAttrsfield of the returnedCMS_SignedDatastructure empty. by default, several CMS SignedAttributes are added, including the signing time, the CMS content type, and the supported list of ciphers in an SMIMECapabilities attribute. sometimes empty is iconic, sometimes it's a choice πCMS_NOSMIMECAPβ omit just the SMIMECapabilities attribute. just that one. not the others. she's specific πCMS_USE_KEYIDβ use the subject key identifier value to identify signing certificates. an error occurs if the signing certificate does not have a subject key identifier extension. by default, issuer name and serial number are used instead. key id girlies rise π
if present, the SMIMECapabilities attribute indicates support for the following algorithms in preference order: 256-bit AES, 192-bit AES, 128-bit AES, triple DES, 128-bit RC2, 64-bit RC2, DES and 40-bit RC2. and if any of these algorithms is not available then it will not be included. no fake support, we don't do that here π
the CMS_SignerInfo_sign() function explicitly signs si. its main use is when the CMS_REUSE_DIGEST and CMS_PARTIAL flags were both set in the call to CMS_add1_signer() that created si. it's giving "finish what we started" and honestly? obsessed π₯
β RETURN VALUES β
CMS_add1_signer() returns an internal pointer to the new CMS_SignerInfo structure just added, or NULL if an error occurs. so if you get NULL, something went wrong β don't ignore her π
π SEE ALSO π
CMS_ContentInfo_new(3), CMS_final(3), CMS_sign(3), ERR_get_error(3)
go read the friends, they're all linked up π«Άβ¨
π STANDARDS π
RFC 5652: Cryptographic Message Syntax, section 5.1: SignedData TypeRFC 8419: Use of Edwards-Curve Digital Signature Algorithm (EdDSA) Signatures in the Cryptographic Message Syntax (CMS)RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 4.0 Message Specification- section 2.5: Attributes and the SignerInfo Type
- section 2.5.2: SMIMECapabilities Attribute
standards queen behavior, no cap π
π HISTORY π
CMS_add1_signer() and CMS_SignerInfo_sign() first appeared in OpenSSL 0.9.8h and have been available since OpenBSD 6.7. they've been iconic for a minute π
and that's the page bestie!! this one came from the Debian crew, dated June 8, 2025 β mwah, love that for us ππ¦β¨
π¦ 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) 2019 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2008 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