CMS_ADD1_SIGNER(3SSL)
π NAME π
CMS_add1_signer, CMS_SignerInfo_sign β bestie, this is how you add a signer to a CMS_ContentInfo signed data structure. Slay.
Oh and hiii, this is the manual page for the OpenSSL 3SSL library, so you know it's the real deal β¨
πΈ SYNOPSIS πΈ
#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 π
So CMS_add1_signer() adds a signer to a CMS_ContentInfo SignedData structure (cms), and that signer comes with a certificate signcert, a private key pkey, and a message digest md. It's giving "I'm official, I'm signed" energy π
The CMS_ContentInfo structure should come from an initial call to CMS_sign() with the flag CMS_PARTIAL set, or β plot twist β from re-signing a valid CMS_ContentInfo SignedData structure. Either way, we're working with something that already exists, okay?
If the md parameter is NULL, then the default digest for the public key algorithm gets used. No cap, it just picks for you π«Ά
Unless the CMS_REUSE_DIGEST flag is set, the returned CMS_ContentInfo structure is not complete and must be finalized, either by streaming (if applicable, iykyk) or by a call to CMS_final(). Don't skip this step bestie, it's literally the whole point.
The CMS_SignerInfo_sign() function explicitly signs a CMS_SignerInfo structure. Its main character moment is when the CMS_REUSE_DIGEST and CMS_PARTIAL flags are both set. β¨
π NOTES π
The main purpose of CMS_add1_signer() is to give you finer control over a CMS signed data structure in the cases where the simpler CMS_sign() function's defaults just aren't the vibe. Like β multiple signers? Non-default digest algorithms? Yeah, that's where this one eats. New attributes can also be added using the returned CMS_SignerInfo structure, along with the CMS attribute utility functions, or the CMS signed receipt request functions. Obsessed. π
Any of the following flags (ored together β think of it as mixing and matching) can be passed in the flags parameter:
CMS_REUSE_DIGESTβ an attempt is made to copy the content digest value from theCMS_ContentInfostructure, so you can add a signer to an existing structure. If a matching digest value can't be found to copy, that's an error, periodt. But when this flag is set, the returnedCMS_ContentInfostructure will be valid and finalized. πCMS_PARTIAL(in addition toCMS_REUSE_DIGEST) β theCMS_SignerInfostructure will not be finalized, so you can still add additional attributes. In this case you need an explicit call toCMS_SignerInfo_sign()to finalize it. Don't forget or it's giving incomplete.CMS_NOCERTSβ the signer's certificate will not be included in theCMS_ContentInfostructure. However, the signer's certificate must still be supplied in thesigncertparameter though. This can reduce the size of the signature if the signer's certificate can be obtained by other means β for example, a previously signed message. Sneaky but valid.CMS_NOATTRβ the SignedData structure includes several CMS signedAttributes, including the signing time, the CMS content type, and the supported list of ciphers in an SMIMECapabilities attribute. If this flag is set, then no signedAttributes will be used at all. None. Zero. πCMS_NOSMIMECAPβ the SMIMECapabilities will be omitted.CMS_NO_SIGNING_TIMEβ the signing time will be omitted.CMS_USE_KEYIDβ OpenSSL will by default identify signing certificates using issuer name and serial number. If this flag is set, it will use the subject key identifier value instead. An error occurs if the signing certificate does not have a subject key identifier extension. So make sure it has one, bestie π₯Ί
If present, the SMIMECapabilities attribute indicates support for the following algorithms, in preference order: 256 bit AES, Gost R3411-94, Gost 28147-89, 192 bit AES, 128 bit AES, triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any of these algorithms is not available, then it will not be included. Simple as that. β¨
β οΈ Note that, in the case signedAttributes are not used, for some hash-less signing schemes the given hashmdwill be ignored and a hash required by the signing scheme will be used. This is the case for EdDSA (RFC 8419). For SLH-DSA (RFC 9814) and ML-DSA (RFC 9882), the scheme-suggested hash will only be used ifmdisNULL. So like, heads up on that.
π Signing with Ed448 is currently not supported for the case of signed-data with signedAttributes, due to missing support for id-shake256-len (RFC 8419; sec 3.1). Tragic, I know.
CMS_add1_signer() returns an internal pointer to the CMS_SignerInfo structure it just added, and you can use that to set additional attributes before it's finalized. Main character pointer energy π«Ά
π¦ RETURN VALUES π¦
CMS_add1_signer()returns an internal pointer to theCMS_SignerInfostructure just added, orNULLif an error occurs. πCMS_SignerInfo_sign()returns1on success,0on failure.
π SEE ALSO π
ERR_get_error(3), CMS_sign(3), CMS_final(3),
π COPYRIGHT π
Copyright 2014-2026 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>.
okay bestie that's the whole page, you're officially educated π β¨ this was OpenSSL 4.0.3, dated 2026-09-29, and no cap, you ate that. go forth and sign things ππ¦π
π¦ 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