CMS_FINAL(3ossl)

πŸ’– CMS_FINAL πŸ’– β€” it's giving finalise a CMS_ContentInfo structure, bestie

okay so this is the CMS_final / CMS_final_digest page from the OpenSSL manual (the whole 3ossl situation). Two lil functions that wrap up your CMS structure and send it off looking cute. Let's get into it πŸŽ€


✨ 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);

🌸 DESCRIPTION 🌸

So CMS_final() is the one that finalises the structure cms. Its whole job is to do all the operations that need doing on cms β€” digest computation, for example, no biggie β€” and then set the appropriate fields. ✨

  • the data parameter? that's holding the content you want processed.
  • the dcont parameter? that's a BIO you write content to after processing. ngl it's only used with detached data, and it'll usually just be set to NULL. πŸ’…

And then CMS_final_digest() finalises the structure cms too, but using a pre-computed digest instead of computing the digest from the original data. so like, you already did the math, she's just here to seal it πŸ¦‹


πŸ“ NOTES πŸ“

These functions will normally be called when the CMS_PARTIAL flag is used, okay? iconic behaviour.

🚨 but bestie listen β€” it should only be used when streaming is not performed, because the streaming I/O functions do their own finalisation operations internally. don't double up, it's not the vibe.

Now. To sign a pre-computed digest, you call CMS_sign(3) or CMS_sign_ex() with the data parameter set to NULL before the CMS structure gets finalised with the digest that was provided to CMS_final_digest() β€” and that digest has to be in binary form. 🫢

πŸ”₯ and this part is important, fr fr: when you're signing a pre-computed digest, the security relies on the digest and its computation from the original message being trusted. so like… trust is literally the whole security model here. no pressure.

🫢 RETURN VALUES 🫢

  • CMS_final() and CMS_final_digest() return 1 for success ✨
  • or 0 for failure 😭

πŸ‘€ SEE ALSO πŸ‘€


πŸ•°οΈ HISTORY πŸ•°οΈ

CMS_final_digest() was added in OpenSSL 3.2. she's the newer sister πŸ’œ


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 whole page, bestie 🌈 this was version 3.5.9, dated 2026-09-29, and it's CMS_FINAL(3ossl) β€” periodt. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from