EVP_CIPHER_C..._ORIGINAL_IV(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… EVP_CIPHER_C..._ORIGINAL_IV πŸ’…

okay bestie, this is a page from the OpenSSL manual β€” section 3ossl, iykyk β€” and it's all about peeking at the IV data inside an EVP_CIPHER_CTX. Yes, that name up top is a little cursed and abbreviated, but we move. πŸŽ€


✨ NAME ✨

EVP_CIPHER_CTX_get_original_iv, EVP_CIPHER_CTX_get_updated_iv, EVP_CIPHER_CTX_iv, EVP_CIPHER_CTX_original_iv, EVP_CIPHER_CTX_iv_noconst β€” literally the routines that let you inspect EVP_CIPHER_CTX IV data. That's the whole job. 🫢


🌸 SYNOPSIS 🌸

#include <openssl/evp.h>

int EVP_CIPHER_CTX_get_original_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len);
int EVP_CIPHER_CTX_get_updated_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len);

okay so these next ones are deprecated β€” they've been deprecated since OpenSSL 3.0, and you can make them disappear entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):

const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx);
const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx);
unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx);

πŸ¦‹ DESCRIPTION πŸ¦‹

EVP_CIPHER_CTX_get_original_iv() and EVP_CIPHER_CTX_get_updated_iv() copy initialization vector (IV) information out of the EVP_CIPHER_CTX and into the buffer you, the caller, supply. πŸŽ€

Pro tip straight from the page: EVP_CIPHER_CTX_get_iv_length(3) can be used to figure out an appropriate buffer size β€” and if your buffer is too small, an error gets returned and no data is copied. So like, size it right, bestie. πŸ’€

Here's the vibe split:

  • EVP_CIPHER_CTX_get_original_iv() β€” grabs the ("original") IV, aka the one that was supplied when the EVP_CIPHER_CTX was initialized. The before picture. πŸ“Έ
  • EVP_CIPHER_CTX_get_updated_iv() β€” grabs the current "IV state" of the cipher, which gets updated during cipher operation for certain cipher modes (e.g., CBC and OFB). The glow-up picture. ✨

Now for the deprecated trio β€” they give you similar functionality, at a conceptual level. Conceptually slay, technically old:

  • EVP_CIPHER_CTX_iv() returns a pointer to the beginning of the "IV state" as maintained internally in the EVP_CIPHER_CTX.
  • EVP_CIPHER_CTX_original_iv() returns a pointer to the beginning of the ("original") IV, as maintained by the EVP_CIPHER_CTX, that was provided when the EVP_CIPHER_CTX was initialized.
  • EVP_CIPHER_CTX_get_iv_noconst() is the same as EVP_CIPHER_CTX_iv() but has a different return type for the pointer. (yes, the page really says EVP_CIPHER_CTX_get_iv_noconst() there β€” that's what's written, don't come for me πŸ™ˆ)

πŸ’– RETURN VALUES πŸ’–

  • EVP_CIPHER_CTX_get_original_iv() and EVP_CIPHER_CTX_get_updated_iv() return 1 on success and 0 on failure. Classic. πŸ‘‘
  • EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and EVP_CIPHER_CTX_iv_noconst() return a pointer to an IV as an array of bytes on success, and NULL on failure.

🌈 HISTORY 🌈

  • EVP_CIPHER_CTX_get_original_iv() and EVP_CIPHER_CTX_get_updated_iv() were added in OpenSSL 3.0.0. New kids, freshest fits. ⭐
  • EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and EVP_CIPHER_CTX_iv_noconst() were added in OpenSSL 1.1.0, and were deprecated in OpenSSL 3.0.0. They had their era, we respect it. πŸ’

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

fr fr, read the license before you go copying stuff. it's giving "respect the authors" energy. πŸ’œ

and that's the whole page, bestie β€” no cap, every last NULL and 1-on-success accounted for. 🌸

k bye, this page was brought to you by OpenSSL 3.5.0, dated 2026-09-25, and the letter EVP_CIPHER_C..._ORIGINAL_IV(3ossl) πŸ’…πŸ¦‹πŸ§š

πŸ“¦ where this page comes from