CMS_ENCRYPTEDDATA_DECRYPT(3ossl)
π CMS_EncryptedData_decrypt β okay bestie, let's decrypt
So this page lives in 3ossl, the OpenSSL corner of the man-page universe, and it's all about two little functions that take your encrypted CMS blobs and hand you back the good stuff. Let's go π
β¨ NAME β¨
CMS_EncryptedData_decrypt, CMS_EnvelopedData_decrypt β literally just decrypting CMS EncryptedData or EnvelopedData. That's the whole vibe. π¦
πΈ SYNOPSIS πΈ
#include <openssl/cms.h>
int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,
const unsigned char *key, size_t keylen,
BIO *dcont, BIO *out, unsigned int flags);
BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data,
EVP_PKEY *pkey, X509 *cert,
ASN1_OCTET_STRING *secret, unsigned int flags,
OSSL_LIB_CTX *libctx, const char *propq);
π DESCRIPTION π
π§ CMS_EncryptedData_decrypt()
okay so this one decrypts a cms EncryptedData object using the symmetric key, and that key is keylen bytes long. You pass out, which is a BIO where the content gets written, and flags, which is your optional set of flags (we'll get to those, don't worry π).
Then there's dcont β you only ever reach for this in the rare case where the encrypted content is detached. Normally you just set it to NULL, no cap. π
The flags, bestie π
Here's what you can pass in that flags parameter:
- So if the
CMS_TEXTflag is set, the MIME headers for type"text/plain"get deleted from the content. Slay. But heads up: if the content is not of type"text/plain", you get an error back. It's giving "strict vibes only" π
π¦ CMS_EnvelopedData_decrypt()
This one decrypts a CMS EnvelopedData object env, and it works similarly to CMS_decrypt(3). Here's the deal on which key it uses:
- If the symmetric key
secretis notNULL, it uses that π - Otherwise it uses the private key of the recipient,
pkey
And if you're giving it pkey, it's recommended that you also provide the associated certificate in cert β go check CMS_decrypt(3) and the NOTES about cert over there, iykyk. π
The optional params flags and dcont work exactly as described above. And the optional library context libctx plus the property query propq are what get used when retrieving algorithms from providers. Provider energy β¨
π₯ RETURN VALUES π₯
CMS_EncryptedData_decrypt()returns0if something went wrong, otherwise it returns1. Binary queen πCMS_EnvelopedData_decrypt()returnsNULLon error, otherwise aBIOcontaining the decrypted content. (The manpage says "decypted" β we love a typo moment, but yeah, decrypted content π)
π SEE ALSO π
Go read them, they're iconic π«Ά
β HISTORY β
CMS_EnvelopedData_decrypt() was added in OpenSSL 3.2. Newer than the rest, main character energy fr fr π
π COPYRIGHT π
Copyright 2020 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>.
Not me reminding you to actually read the license β it's giving responsible bestie, but like, do it π
okay that's the whole page, mwah π β this was OpenSSL 3.5.0, dated 2026-09-25, and yes the header says CMS_ENCRYPTEDDATA_DECRYPT(3ossl) in case you need to cite your sources. go decrypt something cute today, ily π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms