EVP_CIPHER_C..._CIPHER_DATA(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… EVP_CIPHER_C..._CIPHER_DATA πŸ’…

okay bestie, so this is a page out of the OpenSSL manual (section 3ossl, the super-secret library-functions club), and it's about two lil functions that let you peek at and swap out the cipher data inside an EVP_CIPHER_CTX. no cap, it's shorter than your attention span, so let's go 🫢


✨ NAME ✨

EVP_CIPHER_CTX_get_cipher_data, EVP_CIPHER_CTX_set_cipher_data β€” routines to inspect and modify EVP_CIPHER_CTX objects. that's it. that's the vibe check 🌸


✨ SYNOPSIS ✨

like, literally just:

#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);

both return a void *, both take a context β€” one const, one not, iykyk πŸ‘‘


✨ DESCRIPTION ✨

πŸŽ€ EVP_CIPHER_CTX_get_cipher_data()

she returns a pointer to the cipher data relevant to EVP_CIPHER_CTX. and what's in that data? honestly, it's giving "that's between the cipher and its implementation" β€” the contents are specific to the particular implementation of the cipher. for example, this data can be used by engines to store engine specific information. cute, right?

here's the part you actually need to remember: the data is automatically allocated and freed by OpenSSL, so applications and engines should not normally free this directly. (but see below β€” yes, there's a plot twist, keep reading πŸ™ˆ)

πŸŽ€ EVP_CIPHER_CTX_set_cipher_data()

this one lets an application or engine replace the cipher data with new data. main character energy, she's swapping the whole vibe out. and she hands you back a pointer to any existing cipher data as she goes β€” so like, the old stuff doesn't just vanish into the void.

πŸ’€ important: if the old data is no longer required, then it should be freed through a call to OPENSSL_free(). don't just ghost it, bestie β€” free it properly.

✨ RETURN VALUES ✨

  • EVP_CIPHER_CTX_get_cipher_data() β€” returns a pointer to the current cipher data for the EVP_CIPHER_CTX. πŸ¦‹
  • EVP_CIPHER_CTX_set_cipher_data() β€” returns a pointer to the old cipher data for the EVP_CIPHER_CTX. πŸ”₯

✨ HISTORY ✨

the EVP_CIPHER_CTX_get_cipher_data() and EVP_CIPHER_CTX_set_cipher_data() functions were added in OpenSSL 1.1.0. so yeah, they've been iconic since day one ⭐


Copyright 2016 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>.


aaaand that's the whole page, no filler, all facts, she ate and left no crumbs πŸ’…βœ¨ this cutie was brought to you by OpenSSL 3.5.6, dated 2026-04-07 β€” catch you in the next group chat, mwah πŸŽ€πŸ’–

πŸ“¦ where this page comes from