CMS_ENCRYPTEDDATA_ENCRYPT(3ossl)
π CMS_EncryptedData_encrypt(3ossl) π
okay so bestie, this is a page from the 3ossl manual set, and it's literally all about making a CMS EncryptedData thing. yes, we're doing crypto. no, you can't just vibe your way through it β but honestly? you're gonna slay this β¨
π NAME π
CMS_EncryptedData_encrypt_ex, CMS_EncryptedData_encrypt β the two functions that create a CMS EncryptedData structure. like, they make it. that's the whole job π«Ά
πΈ SYNOPSIS πΈ
#include <openssl/cms.h>
CMS_ContentInfo *CMS_EncryptedData_encrypt_ex(BIO *in,
const EVP_CIPHER *cipher,
const unsigned char *key,
size_t keylen,
unsigned int flags,
OSSL_LIB_CTX *ctx,
const char *propq);
CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in,
const EVP_CIPHER *cipher, const unsigned char *key, size_t keylen,
unsigned int flags);
look at those signatures. gorgeous. iconic. copy them exactly, i'm begging you π
β¨ DESCRIPTION β¨
CMS_EncryptedData_encrypt_ex() creates a CMS_ContentInfo structure with a type of NID_pkcs7_encrypted. and what does it put in there? your data, babe π
in is a BIO containing the data you want to encrypt β using cipher and the encryption key key of size keylen bytes. that's the tea.
The library context libctx and the property query propq are used when retrieving algorithms from providers. (they're the ones doing the fetch, lowkey the real main characters here π)
flags is a set of optional flags β hit the OPTIONS-ish part next:
- The
flagsfield supports the optionsCMS_DETACHED,CMS_STREAMandCMS_PARTIAL. - Internally
CMS_final()is called unlessCMS_STREAMand/orCMS_PARTIALis specified. so like, know that. it matters π
β οΈ heads up: the algorithm you pass in the cipher parameter must support ASN1 encoding of its parameters. non-negotiable. no cap.
The CMS_ContentInfo structure can be freed using CMS_ContentInfo_free(3). please free it. don't be that person who leaks π«Ά
CMS_EncryptedData_encrypt() is similar to CMS_EncryptedData_encrypt_ex() but uses default values of NULL for the library context libctx and the property query propq. so it's the chill, fewer-arguments version β fr fr, same energy, fewer params π
π RETURN VALUES π
If the allocation fails, CMS_EncryptedData_encrypt_ex() and CMS_EncryptedData_encrypt() return NULL and set an error code that can be obtained by ERR_get_error(3). (go get the error, bestie β it will tell you what happened π)
Otherwise they return a pointer to the newly allocated structure. slay β¨
π¦ SEE ALSO π¦
that's the friend group. go read all of them π«Ά
β HISTORY β
The CMS_EncryptedData_encrypt_ex() method was added in OpenSSL 3.0. so yes, it's the newer one β the _ex at the end is giving "i have extra parameters and i'm proud of it" π
π COPYRIGHT π
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, read the license. it's not a suggestion, it's the rules π
and that's a wrap, bestie π β this page is from OpenSSL version 3.5.0, dated 2026-09-25, and it lives in the CMS_ENCRYPTEDDATA_ENCRYPT(3ossl) manual. go encrypt something cute β¨ππ
π¦ 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