CMS_FINAL(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… CMS_FINAL(3ossl) β€” like, the whole finalise-a-CMS_ContentInfo-structure situation πŸŽ€

okay bestie, so this is a page from the 3ossl manual set, and it's literally about wrapping up a CMS_ContentInfo structure so it's all done and pretty. stay with me, it's gonna slay.


✨ SYNOPSIS ✨

#include <openssl/cms.h>

int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags);
int CMS_final_digest(CMS_ContentInfo *cms, const unsigned char *md,
                     unsigned int mdlen, BIO *dcont, unsigned int flags);

two functions, same energy, slightly different vibes. let's get into it 🫢


🌸 DESCRIPTION 🌸

CMS_final() 🧚

so this one finalises the structure cms. its whole purpose, its main character moment, is to do any operations necessary on cms β€” digest computation, for example β€” and then set the appropriate fields. periodt. πŸ’…

  • the data parameter contains the content to be processed
  • the dcont parameter contains a BIO to write content to after processing β€” but heads up, this is only used with detached data, and it will usually be set to NULL πŸ™ˆ

CMS_final_digest() πŸ”₯

this one finalises the structure cms using a pre-computed digest, rather than computing the digest from the original data. it's giving "i already did the work, bestie" ✨


⭐ NOTES ⭐

these functions will normally be called when the CMS_PARTIAL flag is used πŸ‘‘

they should only be used when streaming is not performed, because the streaming I/O functions perform finalisation operations internally. so like, don't double up, that's not the vibe πŸ’€

now, to sign a pre-computed digest: CMS_sign(3) or CMS_sign_ex() is called with the data parameter set to NULL before the CMS structure is finalised with the digest provided to CMS_final_digest() in binary form.

⚠️ ngl, real talk: when signing a pre-computed digest, the security relies on the digest and its computation from the original message being trusted. this is the important part, don't skip it fr fr 😭

πŸ¦‹ RETURN VALUES πŸ¦‹

  • CMS_final() and CMS_final_digest() return 1 for success
  • or 0 for failure πŸ’”

that's it, that's the whole vibe check.


🌈 SEE ALSO 🌈

go read those too, iykyk πŸ“


πŸ‘‘ HISTORY πŸ‘‘

CMS_final_digest() was added in OpenSSL 3.2. iconic behaviour tbh πŸŽ€


Copyright 2008-2022 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! πŸ’– this lil rewrite is from the OpenSSL 3.5.0 manual, dated 2026-09-25 β€” so go forth, finalise responsibly, and remember: CMS_final said what it said πŸŒΈπŸ’…βœ¨

πŸ“¦ where this page comes from