CMS_ADD1_SIGNER(3ossl)

πŸ’– CMS_ADD1_SIGNER(3ossl) πŸ’–

okay so bestie, welcome to the CMS_add1_signer(3ossl) page β€” it's part of the OpenSSL manual, and it's literally all about adding a signer to a CMS_ContentInfo signed data structure. the way this function is so main character fr fr 🫢


✨ 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 like, CMS_add1_signer() is the vibe where you add a signer β€” that's your certificate signcert and your private key pkey, using message digest md β€” to a CMS_ContentInfo SignedData structure called cms. iconic behavior tbh πŸ’…

the CMS_ContentInfo structure should come from an initial call to CMS_sign() with the flag CMS_PARTIAL set, OR from re-signing a valid CMS_ContentInfo SignedData structure. iykyk.

if the md parameter is NULL then the default digest for the public key algorithm gets used instead. no stress, it's handled πŸ’œ

and unless the CMS_REUSE_DIGEST flag is set, the returned CMS_ContentInfo structure is not complete and must be finalized β€” either by streaming (if that applies to you) or by a call to CMS_final(). don't leave it hanging bestie 😭

CMS_SignerInfo_sign() is the function that explicitly signs a CMS_SignerInfo structure. its main use? when both the CMS_REUSE_DIGEST and CMS_PARTIAL flags are set. that's the moment it shines ✨


πŸ“ NOTES πŸ“

the main purpose of CMS_add1_signer() is to give you finer control over a CMS signed data structure β€” like, for when the simpler CMS_sign() function defaults just aren't giving what you need. for example: multiple signers, or non-default digest algorithms. new attributes can also be added using the returned CMS_SignerInfo structure, plus the CMS attribute utility functions or the CMS signed receipt request functions. so many options, so much power πŸ‘‘

any of the following flags (ored together) can be passed in the flags parameter:

  • CMS_REUSE_DIGEST β€” when set, an attempt is made to copy the content digest value from the CMS_ContentInfo structure, so you can add a signer to an existing structure. an error occurs if a matching digest value can't be found to copy. when this flag is set, the returned CMS_ContentInfo structure will be valid and finalized. periodt πŸ’–
  • CMS_PARTIAL β€” if this is set in addition to CMS_REUSE_DIGEST, then the CMS_SignerInfo structure will not be finalized, so you can add additional attributes. in that case you need an explicit call to CMS_SignerInfo_sign() to finalize it. no skipping that step πŸ™ˆ
  • CMS_NOCERTS β€” if set, the signer's certificate will not be included in the CMS_ContentInfo structure. but the signer's certificate must still be supplied in the signcert parameter 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 CMS_NOATTR is set, then no signedAttributes will be used at all. none. zero. πŸ’€
  • CMS_NOSMIMECAP β€” if set, the SMIMECapabilities will be omitted. bye felicia πŸ‘‹
  • CMS_NO_SIGNING_TIME β€” if set, the signing time will be omitted. timestamps? not today πŸŽ€
  • CMS_USE_KEYID β€” OpenSSL by default identifies signing certificates using issuer name and serial number. 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. 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. and if any of these algorithms isn't available, then it won't be included β€” for example the GOST algorithms won't be included if the GOST ENGINE is not loaded. it's giving "only the available ones make the cut" 🌈

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. so handy 🫢


πŸ”₯ RETURN VALUES πŸ”₯

  • CMS_add1_signer() returns an internal pointer to the CMS_SignerInfo structure just added, or NULL if an error occurs. 😭
  • CMS_SignerInfo_sign() returns 1 on success, 0 on failure.

πŸ‘€ SEE ALSO πŸ‘€

ERR_get_error(3), CMS_sign(3), CMS_final(3),


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 whole page bestie!! this one's from OpenSSL 3.5.9, dated 2026-09-29, and it lives in the CMS_ADD1_SIGNER(3ossl) manual. slay, go sign something πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from