1EVP_SEALINIT(3) OpenSSL EVP_SEALINIT(3)
2
3
4
6 EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption
7
9 #include <openssl/evp.h>
10
11 int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
12 unsigned char **ek, int *ekl, unsigned char *iv,
13 EVP_PKEY **pubk, int npubk);
14 int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
15 int *outl, unsigned char *in, int inl);
16 int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
17
19 The EVP envelope routines are a high-level interface to envelope
20 encryption. They generate a random key and IV (if required) then
21 "envelope" it by using public key encryption. Data can then be
22 encrypted using this key.
23
24 EVP_SealInit() initializes a cipher context ctx for encryption with
25 cipher type using a random secret key and IV. type is normally supplied
26 by a function such as EVP_aes_256_cbc(). The secret key is encrypted
27 using one or more public keys, this allows the same encrypted data to
28 be decrypted using any of the corresponding private keys. ek is an
29 array of buffers where the public key encrypted secret key will be
30 written, each buffer must contain enough room for the corresponding
31 encrypted key: that is ek[i] must have room for EVP_PKEY_size(pubk[i])
32 bytes. The actual size of each encrypted secret key is written to the
33 array ekl. pubk is an array of npubk public keys.
34
35 The iv parameter is a buffer where the generated IV is written to. It
36 must contain enough room for the corresponding cipher's IV, as
37 determined by (for example) EVP_CIPHER_iv_length(type).
38
39 If the cipher does not require an IV then the iv parameter is ignored
40 and can be NULL.
41
42 EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
43 as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
44 documented on the EVP_EncryptInit(3) manual page.
45
47 EVP_SealInit() returns 0 on error or npubk if successful.
48
49 EVP_SealUpdate() and EVP_SealFinal() return 1 for success and 0 for
50 failure.
51
53 Because a random secret key is generated the random number generator
54 must be seeded when EVP_SealInit() is called. If the automatic seeding
55 or reseeding of the OpenSSL CSPRNG fails due to external circumstances
56 (see RAND(7)), the operation will fail.
57
58 The public key must be RSA because it is the only OpenSSL public key
59 algorithm that supports key transport.
60
61 Envelope encryption is the usual method of using public key encryption
62 on large amounts of data, this is because public key encryption is slow
63 but symmetric encryption is fast. So symmetric encryption is used for
64 bulk encryption and the small random symmetric key used is transferred
65 using public key encryption.
66
67 It is possible to call EVP_SealInit() twice in the same way as
68 EVP_EncryptInit(). The first call should have npubk set to 0 and (after
69 setting any cipher parameters) it should be called again with type set
70 to NULL.
71
73 evp(7), RAND_bytes(3), EVP_EncryptInit(3), EVP_OpenInit(3), RAND(7)
74
76 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
77
78 Licensed under the OpenSSL license (the "License"). You may not use
79 this file except in compliance with the License. You can obtain a copy
80 in the file LICENSE in the source distribution or at
81 <https://www.openssl.org/source/license.html>.
82
83
84
851.1.1q 2022-07-07 EVP_SEALINIT(3)