CMS_DIGEST_CREATE(3SSL)

πŸ’– CMS_DIGEST_CREATE πŸ’–

bestie, we're in the 3SSL section of the manual β€” OpenSSL's own little corner β€” and today's main characters are CMS_digest_create_ex and CMS_digest_create. say hi πŸ‘‹


✨ NAME ✨

CMS_digest_create_ex, CMS_digest_create β€” creating a CMS DigestedData object. that's the whole job. that's the vibe. periodt. πŸ’…


🌸 SYNOPSIS 🌸

okay so first you gotta bring the header in, like always:

#include <openssl/cms.h>

and here are the two function besties themselves, exactly as they are, no edits, no notes:

CMS_ContentInfo *CMS_digest_create_ex(BIO *in, const EVP_MD *md,
                                      unsigned int flags, OSSL_LIB_CTX *ctx,
                                      const char *propq);

CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
                                   unsigned int flags);

iconic lineup honestly. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so CMS_digest_create_ex() builds you a CMS_ContentInfo structure with the type NID_pkcs7_digest. it takes the data you hand it through the in BIO and digests it using md. πŸ“

when it goes to pull algorithms out of providers, it uses the library context libctx and the property query propq to do that retrieval. ✨

the flags field? it supports the CMS_DETACHED and CMS_STREAM flags. and heads up β€” internally CMS_final() gets called unless CMS_STREAM is specified. so like, that's automatic, not you, don't stress. πŸ’…

once you're done with the whole CMS_ContentInfo structure, you can free it with CMS_ContentInfo_free(3). clean up after yourself, queen πŸ‘‘

and CMS_digest_create()? it's basically the same energy as CMS_digest_create_ex(), except it just uses the default values of NULL for the library context libctx and the property query propq. low effort, high reward. 😌


πŸŽ€ RETURN VALUES πŸŽ€

if the allocation flops, both CMS_digest_create_ex() and CMS_digest_create() return NULL and set an error code β€” and you can grab that code with ERR_get_error(3). 😭

otherwise? they hand you a pointer to the freshly allocated structure. slay. πŸ”₯


🌈 SEE ALSO 🌈

go read those too, you know you want to πŸ’œ


πŸ‘‘ HISTORY πŸ‘‘

the CMS_digest_create_ex() method was added in OpenSSL 3.0. new girl on the block, and she ate. ⭐


Copyright 2020-2021 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>.

like, legally bestie. read the license. it's giving "required reading" and it fr fr is. πŸ“š

and that's a wrap, gorgeous 🧚 β€” this was OpenSSL 4.0.3, dated 2026-09-29, from the CMS_DIGEST_CREATE(3SSL) page. go digest something. no cap. πŸ’–

πŸ“¦ where this page comes from