CMS_ENCRYPTEDDATA_ENCRYPT(3ossl)
π CMS_ENCRYPTEDDATA_ENCRYPT π
okay bestie, pull up a chair, because today we're talking about CMS_EncryptedData_encrypt_ex and CMS_EncryptedData_encrypt β the OpenSSL 3 functions that literally create a CMS EncryptedData for you. yeah. main character energy fr. πΈ
β¨ NAME β¨
CMS_EncryptedData_encrypt_ex, CMS_EncryptedData_encrypt β they create a CMS EncryptedData structure. that's the whole job. iconic. π
π 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);
no cap, those signatures are exact, copy them character for character or the compiler WILL be petty about it. π
π¦ DESCRIPTION π¦
so CMS_EncryptedData_encrypt_ex() builds you a CMS_ContentInfo structure whose type is NID_pkcs7_encrypted. slay.
inis aBIOholding the data you wanna encrypt π₯cipheris the cipher you're encrypting withkeyis the encryption key, and it'skeylenbytes long- the library context
libctxand the property querypropqget used when retrieving algorithms from providers (iykyk) flagsis a set of optional flags, and girl, there are three of them
the flags field supports these options: CMS_DETACHED, CMS_STREAM and CMS_PARTIAL. π
lowkey important: internallyCMS_final()gets called unlessCMS_STREAMand/orCMS_PARTIALis specified. so if you pass those, you're on your own for finalizing. just so you know. π
and now for the part that ruins the vibe:
the algorithm you pass in the cipher parameter must support ASN1 encoding of its parameters. and AEAD cipher algorithms? not supported. periodt. π
when you're done with it, you can free the CMS_ContentInfo structure with CMS_ContentInfo_free(3). be a good citizen and clean up after yourself. π§
CMS_EncryptedData_encrypt() is the same vibe as CMS_EncryptedData_encrypt_ex() except it just uses default values of NULL for the library context libctx and the property query propq. easy peasy. π
β RETURN VALUES β
if the allocation fails, both CMS_EncryptedData_encrypt_ex() and CMS_EncryptedData_encrypt() return NULL and set an error code that you can grab with ERR_get_error(3). π
otherwise? they return a pointer to the newly allocated structure. ate. π
π SEE ALSO π
go read those next, bestie, they're the supporting cast. π«Ά
π HISTORY π
the CMS_EncryptedData_encrypt_ex() method was added in OpenSSL 3.0. glow up. β¨
πΈ 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>.
okay that's the whole page, bestie, you're officially fluent π
and hey β this was OpenSSL 3.5.9, dated 2026-09-29, from the CMS_ENCRYPTEDDATA_ENCRYPT(3ossl) manual. go encrypt something cute. mwah. πππ¦
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms