EVP_SEALINIT(3ossl)
π EVP_SEALINIT(3ossl) β like, the OpenSSL manual page, but make it make sense
okay bestie, sit down, grab a strawberry π β this is the OpenSSL 3ossl page for the EVP envelope encryption girlies, and it's genuinely iconic once you get it, i promise.
β¨ NAME β¨
EVP_SealInit, EVP_SealUpdate, EVP_SealFinal β EVP envelope encryption. yes, that's the whole name section, she's short and she knows it π
π SYNOPSIS π
#include <openssl/evp.h>
int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
unsigned char **ek, int *ekl, unsigned char *iv,
EVP_PKEY **pubk, int npubk);
int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
int *outl, unsigned char *in, int inl);
int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
like, that's a lot of parameters, but we're gonna walk through each one, no panic π«Ά
π¦ DESCRIPTION π¦
So the EVP envelope routines are basically a high-level interface to envelope encryption. What do they do? They generate a random key and IV (if required) and then "envelope" it β like wrapping a lil gift π β by using public key encryption. After that, you can encrypt your actual data with that key. slay.
π EVP_SealInit()
EVP_SealInit() initializes a cipher context ctx for encryption with cipher type using a random secret key and IV.
type is normally supplied by a function such as EVP_aes_256_cbc().
Here's the actually cool part: the secret key gets encrypted using one or more public keys. that means the same encrypted data can be decrypted using any of the corresponding private keys. main character flexibility, honestly π
ekis an array of buffers where the public key encrypted secret key will be written. Each buffer must contain enough room for the corresponding encrypted key β that is,ek[i]must have room forEVP_PKEY_get_size(pubk[i])bytes.- The actual size of each encrypted secret key gets written to the array
ekl. pubkis an array ofnpubkpublic keys.
πΈ the iv situation
The iv parameter is a buffer where the generated IV is written to. It must contain enough room for the corresponding cipher's IV, as determined by (for example) EVP_CIPHER_get_iv_length(type).
If the cipher doesn't require an IV then theivparameter is ignored and can beNULL. so don't stress about it if your cipher's not that kind of cipher π
π§ EVP_SealUpdate() and EVP_SealFinal()
These two have exactly the same properties as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as documented on the EVP_EncryptInit(3) manual page. same energy, different name, iykyk.
β RETURN VALUES β
EVP_SealInit()returns0on error, ornpubkif successful. (yes, the success value is literally the number of public keys, she's quirky like that π)EVP_SealUpdate()andEVP_SealFinal()return1for success and0for failure.
π₯ NOTES π₯
okay this is the part where you actually pay attention, bestie:
- Because a random secret key is generated, the random number generator must be seeded when
EVP_SealInit()is called. If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to external circumstances (seeRAND(7)), the operation will fail. no cap, this one matters π - The public key must be RSA, because it is the only OpenSSL public key algorithm that supports key transport. that's the whole reason, no shade to the others, they just don't do that π
- Envelope encryption is the usual method of using public key encryption on large amounts of data. why? because public key encryption is slow but symmetric encryption is fast πββοΈπ¨ So symmetric encryption is used for bulk encryption, and the small random symmetric key used is transferred using public key encryption. it's giving teamwork, it's giving division of labour, we love to see it.
- It is possible to call
EVP_SealInit()twice in the same way asEVP_EncryptInit(). The first call should havenpubkset to0and (after setting any cipher parameters) it should be called again withtypeset toNULL. two-step init, iconic behaviour β¨
π SEE ALSO π
evp(7), RAND_bytes(3), EVP_EncryptInit(3), EVP_OpenInit(3), RAND(7) β go read them, they're all friends of this page π«Ά
π COPYRIGHT π
Copyright 2000-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>.
and that's the page, bestie π this was OpenSSL 3.5.0, dated 2026-09-25, and yes the footer says EVP_SEALINIT(3ossl) β go forth and envelope-encrypt responsibly, mwah π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms