EVP_OPENINIT(3ossl)

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

πŸ’… EVP_OPENINIT πŸ’…

okay so bestie, this is the OpenSSL page for EVP_OpenInit, EVP_OpenUpdate and EVP_OpenFinal β€” the whole envelope-decryption friend group. it's giving "open the envelope, get the key, get the tea" πŸ”₯

✨ NAME ✨

EVP_OpenInit, EVP_OpenUpdate, EVP_OpenFinal β€” EVP envelope decryption. yes queen, we're opening envelopes πŸ’Œ

🌸 SYNOPSIS 🌸

#include <openssl/evp.h>

int EVP_OpenInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char *ek,
                 int ekl, unsigned char *iv, EVP_PKEY *priv);
int EVP_OpenUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
                   int *outl, unsigned char *in, int inl);
int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);

copy these exactly, no cap 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

the EVP envelope routines are like the high-level, main-character interface to envelope decryption. what they do is: first they decrypt a public key encrypted symmetric key, and then they use that key to decrypt the actual data. it's a two-step slay ✨

  • EVP_OpenInit() β€” initializes a cipher context ctx for decryption with cipher type. it decrypts the encrypted symmetric key of length ekl bytes passed in the ek parameter, using the private key priv. the IV is supplied in the iv parameter. iconic behaviour honestly πŸ’…
  • EVP_OpenUpdate() and EVP_OpenFinal() β€” these have exactly the same properties as the EVP_DecryptUpdate() and EVP_DecryptFinal() routines, as documented on the EVP_EncryptInit(3) manual page. literally identical vibe, different name πŸŽ€

πŸ’œ NOTES πŸ’œ

you can call EVP_OpenInit() twice, same way as EVP_DecryptInit(). here's the choreography:

  1. first call: have priv set to NULL
  2. after setting any cipher parameters
  3. call it again with type set to NULL

and about key lengths, listen up πŸ”ˆ if the cipher you passed in the type parameter is a variable length cipher, then the key length gets set to the value of the recovered key length. but if the cipher is a fixed length cipher, then the recovered key length must match the fixed cipher length. no wiggle room, periodt πŸ’€


⭐ RETURN VALUES ⭐

  • EVP_OpenInit() β€” returns 0 on error, or a non zero integer (and yeah, it's actually the recovered secret key size) if successful πŸŽ‰
  • EVP_OpenUpdate() β€” returns 1 for success or 0 for failure.
  • EVP_OpenFinal() β€” returns 0 if the decrypt failed or 1 for success.
so like… 0 means different things depending on which function you're in. read carefully bestie, i'm begging πŸ™ˆ

🌈 SEE ALSO 🌈

evp(7), RAND_bytes(3), EVP_EncryptInit(3), EVP_SealInit(3)

go read those too, iykyk 🧚


Copyright 2000-2020 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>.


and that's the whole page, bestie πŸ“ this was version 3.5.0, dated 2026-09-25, from the fine people at OpenSSL β€” EVP_OPENINIT(3ossl), signing off πŸ’–βœ¨

πŸ“¦ where this page comes from