LIBRESSL-EVP_CIPHER_CTX_GET_CIPHER_DATA(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… EVP_CIPHER_CTX_GET_CIPHER_DATA β€” like, the whole glow-up

okay so bestie, this is a page from the Library Functions Manual for libcrypto, and it's all about poking around inside EVP_CIPHER_CTX objects β€” inspecting them, messing with them, the whole vibe. Three functions, one page, let's go πŸ’–


✨ NAME ✨

EVP_CIPHER_CTX_get_cipher_data, EVP_CIPHER_CTX_set_cipher_data, EVP_CIPHER_CTX_buf_noconst β€” inspect and modify EVP_CIPHER_CTX objects 🫢


🌸 SYNOPSIS 🌸

library β€œlibcrypto”

#include <openssl/evp.h>

void *
EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);

void *
EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);

unsigned char *
EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx);

πŸ¦‹ DESCRIPTION πŸ¦‹

πŸ’œ EVP_CIPHER_CTX_get_cipher_data()

Returns a pointer to the cipher data of ctx. and like… the format and content of this data is specific to the algorithm and to the particular implementation of the cipher. no cap, it's giving very "you had to be there" energy β€” every cipher does its own thing ✨

For example, this data can be used by engines to store engine specific information πŸ‘‘ The data is automatically allocated and freed by OpenSSL, so applications and engines should not normally free this directly (but see below πŸ™ˆ).

πŸ’œ EVP_CIPHER_CTX_set_cipher_data()

Allows an application or engine to replace the existing cipher data with new data, transferring ownership of cipher_data to the ctx object πŸ”₯ A pointer to any existing cipher data is returned from this function. If the old data is no longer required, it should be freed through a call to free(3) β€” yes bestie, you have to clean that up yourself πŸ’€

πŸ’œ EVP_CIPHER_CTX_buf_noconst()

Provides engines and custom cipher implementations with access to the internal buffer that EVP_EncryptUpdate(3) copies input data into before encrypting it 🧚 This function can for example be used inside callback functions installed with EVP_CIPHER_meth_set_do_cipher(3). lowkey iconic access right there ⭐


πŸŽ€ RETURN VALUES πŸŽ€

  • EVP_CIPHER_CTX_get_cipher_data() β€” returns an internal pointer owned by ctx πŸ‘‘
  • EVP_CIPHER_CTX_set_cipher_data() β€” returns a pointer to the old cipher data of ctx and transfers ownership to the caller 🫢
  • EVP_CIPHER_CTX_buf_noconst() β€” returns a pointer to an internal buffer owned by ctx 🌈
bestie note: notice the "owned by" energy on those first and last ones β€” those pointers are not yours to free, periodt πŸ’…

🌟 SEE ALSO 🌟

evp(3), EVP_CIPHER_meth_new(3), EVP_EncryptInit(3) β€” go read these next, iykyk πŸ“š


🌈 HISTORY 🌈

EVP_CIPHER_CTX_get_cipher_data(), EVP_CIPHER_CTX_set_cipher_data(), and EVP_CIPHER_CTX_buf_noconst() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 7.1 πŸŽ‰


aaand that's the page, bestie πŸ’– mwah. this Debian build is dated June 8, 2025 β€” so yeah, freshly served, go forth and inspect those cipher contexts responsibly πŸ“βœ¨

πŸ“¦ where this page comes from