CMS_FINAL(3SSL)

πŸ“¦
version 4.0.3 Β· 2 versions
, in ubuntu stonking

✨ NAME ✨

okay bestie, so this whole page is about CMS_final, CMS_final_digest, CMS_dataFinal, and CMS_dataFinal_ex β€” the OpenSSL functions that finalise a CMS_ContentInfo structure. πŸ’– This is the CMS_FINAL(3SSL) page from the OpenSSL manual (the 3SSL series, iykyk), and we're gonna go through every lil bit of it together. grab a boba, let's go πŸ§‹


🌸 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);
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio);
int CMS_dataFinal_ex(CMS_ContentInfo *cms, BIO *cmsbio, BIO *data);

πŸ’– DESCRIPTION πŸ’–

okay so here's the lineup, function by function, no skips:

CMS_final()

This one finalises the structure cms. its whole purpose is to do any operations that need doing on cms β€” digest computation, for example β€” and set the appropriate fields. the parameter data holds the content that's gonna be processed. and dcont? that's a BIO to write content to after processing. lowkey important: dcont is only used with detached data, and it'll usually be set to NULL. 🫢

CMS_final_digest()

This one finalises the structure cms using a pre-computed digest, instead of computing the digest from the original data. like, the digest already ate, she's just showing up ready to go πŸ’…

CMS_dataFinal()

This one finalises the structure cms using the data provided by the cmsbio BIO, for hash-based signing schemes. that BIO can be set up using CMS_dataInit() and SMIME_ctrl_copy(). ✨

CMS_dataFinal_ex()

This one finalises the structure cms, and bestie, you must use this function if hash-less signing schemes are in play β€” think ML-DSA, SLH-DSA, or EdDSA β€” because those schemes need access to the raw (non-hashed) data. 🫣 the raw data has to be provided by the data BIO. and heads up: this BIO must support the seek() function so its data stream can be read multiple times, once for each signature created by a hash-less signing scheme. not optional. soak that in. πŸ’€


πŸŽ€ NOTES πŸŽ€

These functions will normally be called when the CMS_PARTIAL flag is used. 🫑

fr fr: they should only be used when streaming is not performed β€” because the streaming I/O functions do their own finalisation operations internally. do not double up, it's giving chaos.

And now, the pre-computed digest tea β˜•: to sign a pre-computed digest, CMS_sign(3) or CMS_sign_ex() gets called with the data parameter set to NULL before the CMS structure is finalised with the digest that gets provided to CMS_final_digest() β€” and that digest needs to be in binary form. πŸ“

⚠️ When signing a pre-computed digest, the security relies on the digest and its computation from the original message being trusted. like, this is the whole ballgame, so protect that trust. πŸ‘‘

πŸ”₯ RETURN VALUES πŸ”₯

CMS_final(), CMS_final_digest(), CMS_dataFinal(), and CMS_dataFinal_ex() all return 1 for success or 0 for failure. one or zero, that's it, that's the vibe check. βœ…βŒ


πŸ¦‹ SEE ALSO πŸ¦‹

go read these next, bestie, they're the supporting cast 🫢


πŸ’œ HISTORY πŸ’œ

CMS_final_digest() was added in OpenSSL 3.2. so if you're on something older, don't come for her, she wasn't born yet πŸ™ˆ


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, babes πŸ’… this was the CMS_FINAL(3SSL) manual page from OpenSSL, version 4.0.3, dated 2026-09-29. go finalise something iconic, and remember β€” hash-less schemes need that seekable raw data, no cap. πŸŒˆβœ¨πŸ’–

πŸ“¦ where this page comes from