CMS_ADD1_SIGNER(3ossl)
π CMS_add1_signer, CMS_SignerInfo_sign β the OpenSSL 3ossl glow-up π
okay so bestie, this is the CMS_add1_signer(3ossl) page from OpenSSL, and it's literally about adding a signer to a CMS_ContentInfo SignedData structure. two functions, one page, both iconic. let's get into it β¨
πΈ 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);
like, that's the whole vibe. include the header, call the function, slay π
π¦ DESCRIPTION π¦
CMS_add1_signer() is the main character here fr fr β it adds a signer to the CMS_ContentInfo SignedData structure cms, using certificate signcert and private key pkey, with message digest md.
Now, the CMS_ContentInfo structure should come from an initial call to CMS_sign() with the flag CMS_PARTIAL set β or, alternatively, from re-signing a valid CMS_ContentInfo SignedData structure. (yes the original says "in the case or re-signing", that's a typo in the OG, we're leaving it alone, no cap π)
If the md parameter is NULL, then the default digest for the public key algorithm gets used. no thoughts, just defaults β¨
π¨ heads up bestie: unless theCMS_REUSE_DIGESTflag is set, the returnedCMS_ContentInfostructure is not complete and must be finalized β either by streaming (if that applies to you) or by callingCMS_final().
And CMS_SignerInfo_sign()? It explicitly signs a CMS_SignerInfo structure. its main use is when CMS_REUSE_DIGEST and CMS_PARTIAL are both set. periodt.
π NOTES π
The whole point of CMS_add1_signer() is giving you finer control over a CMS signed data structure, for when the simpler CMS_sign() function defaults just aren't it β like if you need multiple signers, or non-default digest algorithms. You can also add new attributes using the returned CMS_SignerInfo structure plus the CMS attribute utility functions, or the CMS signed receipt request functions. obsessed π«Ά
Any of these following flags can be passed in the flags parameter (ored together, obviously):
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. an error occurs if a matching digest value cannot be found to copy. when this flag is set, the returnedCMS_ContentInfostructure will be valid and finalized. done and dusted βCMS_PARTIALβ when set in addition toCMS_REUSE_DIGEST, theCMS_SignerInfostructure will not be finalized, so you can add more attributes. in this case you need an explicit call toCMS_SignerInfo_sign()to finalize it. you got this πCMS_NOCERTSβ the signer's certificate will not be included in theCMS_ContentInfostructure. but bestie, 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 π₯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 πCMS_NOSMIMECAPβ the SMIMECapabilities attribute will be omitted πCMS_NO_SIGNING_TIMEβ the signing time will be omitted πCMS_USE_KEYIDβ OpenSSL identifies signing certificates by issuer name and serial number by default. if this flag is set, it uses the subject key identifier value instead. an error occurs if the signing certificate does not have a subject key identifier extension. lowkey important π
If present, the SMIMECapabilities attribute indicates support for the following algorithms, in this exact 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 β for example, the GOST algorithms will not be included if the GOST ENGINE is not loaded. iykyk π
CMS_add1_signer() returns an internal pointer to the CMS_SignerInfo structure just added, and you can use that to set additional attributes before it's finalized. main character energy fr π§
β¨ 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-2016 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 page bestie, we ate and left no crumbs π this was OpenSSL version 3.5.0, dated 2026-09-25, manual section CMS_ADD1_SIGNER(3ossl) β now go forth and add your signers, mwah ππ¦π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms