EVP_SEALINIT(3SSL)
π EVP_SEALINIT β the OpenSSL page, bestie edition π
okay so this is EVP_SEALINIT(3SSL), and it's an OpenSSL situation, and honestly? it's giving "how do i send a secret to a whole group chat without mailing each of them a separate key." sit down, hydrate, let's go. π«Ά
β¨ NAME β¨
EVP_SealInit, EVP_SealUpdate, EVP_SealFinal β EVP envelope encryption. that's it, that's the name, no cap. π
β¨ 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);
three functions, one vibe. β¨
β¨ DESCRIPTION β¨
so the EVP envelope routines are a high-level interface to envelope encryption. they generate a random key and IV (if required) and then "envelope" it by using public key encryption. after that, data can be encrypted using this key. literally the whole point. π
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(). the secret key is encrypted using one or more public keys, and this allows the same encrypted data to be decrypted using any of the corresponding private keys β main character behavior honestly, the data is so wanted. π
ek is 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 for EVP_PKEY_get_size(pubk[i]) bytes. the actual size of each encrypted secret key is written to the array ekl. pubk is an array of npubk public keys. π
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).
heads up bestie: if the cipher does not require an IV then theivparameter is ignored and can beNULL. ignored!! it doesn't care. π¦
EVP_SealUpdate() and EVP_SealFinal() 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.EVP_SealUpdate()andEVP_SealFinal()return1for success and0for failure.
that's the whole vibe check. 1 good, 0 bad, and SealInit is quirky about it and hands you npubk. π
β¨ NOTES β¨
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 (see RAND(7)), the operation will fail. no key, no seal, no drama. π
the public key must be RSA because it is the only OpenSSL public key algorithm that supports key transport. RSA only. don't try to be cute with something else. π
envelope encryption is the usual method of using public key encryption on large amounts of data, this is 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. fast does the heavy lifting, slow does the tiny little messenger run. iconic division of labor. π
it is possible to call EVP_SealInit() twice in the same way as EVP_EncryptInit(). the first call should have npubk set to 0 and (after setting any cipher parameters) it should be called again with type set to NULL. yes, twice. it's a two-part situation, like a get-ready-with-me. β¨
β¨ SEE ALSO β¨
evp(7), RAND_bytes(3), EVP_EncryptInit(3), EVP_OpenInit(3), RAND(7)
all of them, linked, slay. π
β¨ 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>.
okay that's the page!! this was version 4.0.3, dated 2026-09-29, and it lives in the OpenSSL docs under the EVP_SEALINIT(3SSL) name. mwah, go encrypt something responsibly. ππβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms