EVP_CIPHER_C..._ORIGINAL_IV(3ossl)
π EVP_CIPHER_C..._ORIGINAL_IV (3ossl) β the OpenSSL girlies know β¨
okay so bestie, this is one of those pages from the OpenSSL manual set β section 3ossl, the crypto-library corner of the docs π. It's all about peeking inside an EVP_CIPHER_CTX to see what IV data is living in there. like, the cipher context is a whole main character and we're just asking it "soooo what's your IV rn?" π
β¨ 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 β these are the routines that let you inspect the IV data inside an EVP_CIPHER_CTX. it's giving "let me see your notes" energy ππ
πΈ 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 but the next batch? π«Ά these ones have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value β see openssl_user_macros(7) for the deets:
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 π¦
so 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 supply. very "bring your own container" of them ngl π
you can use EVP_CIPHER_CTX_get_iv_length(3) to figure out an appropriate buffer size β and lowkey important: if the buffer you supply is too small, an error will be returned and no data gets copied. so like, size it right, bestie π
here's the tea on which one does what β:
EVP_CIPHER_CTX_get_original_iv()β grabs the ("original") IV that was supplied when theEVP_CIPHER_CTXwas initialized. the first-look IV, the one that walked in the room π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.,CBCandOFB). it's the IV after the glow-up β¨
and now the deprecated girlies π β EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and EVP_CIPHER_CTX_iv_noconst() are deprecated functions that do similar (at a conceptual level) stuff. literally "conceptually similar" is doing so much work in that sentence π
EVP_CIPHER_CTX_iv()returns a pointer to the beginning of the "IV state" as maintained internally in theEVP_CIPHER_CTX.EVP_CIPHER_CTX_original_iv()returns a pointer to the beginning of the ("original") IV, as maintained by theEVP_CIPHER_CTX, that was provided when theEVP_CIPHER_CTXwas initialized.EVP_CIPHER_CTX_get_iv_noconst()is the same asEVP_CIPHER_CTX_iv()but has a different return type for the pointer. same vibe, different type π
β οΈ heads up bestie: those three are deprecated β they're the legacy era, keep that in mind before you build on them π
π₯ RETURN VALUES π₯
EVP_CIPHER_CTX_get_original_iv()andEVP_CIPHER_CTX_get_updated_iv()return1on success and0on failure. simple. iconic. slay β- the functions
EVP_CIPHER_CTX_iv(),EVP_CIPHER_CTX_original_iv(), andEVP_CIPHER_CTX_iv_noconst()return a pointer to an IV as an array of bytes on success, andNULLon failure π«Ά
β HISTORY β
EVP_CIPHER_CTX_get_original_iv()andEVP_CIPHER_CTX_get_updated_iv()were added in OpenSSL 3.0.0. the new girls πEVP_CIPHER_CTX_iv(),EVP_CIPHER_CTX_original_iv(), andEVP_CIPHER_CTX_iv_noconst()were added in OpenSSL 1.1.0, and were deprecated in OpenSSL 3.0.0. started from the bottom, then got deprecated, now they'reβ¦ here ππ
π 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>.
k that's the whole page bestie, hope the IV lore hit π¦ and fr fr go check your buffer sizes before you call any of this β it's giving "measure twice, cut once" ππ
version 3.5.6, dated 2026-04-07 β mwah, go touch some grass, or at least some elliptic curves πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms