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 before calling EVP_SealInit().
55
56 The public key must be RSA because it is the only OpenSSL public key
57 algorithm that supports key transport.
58
59 Envelope encryption is the usual method of using public key encryption
60 on large amounts of data, this is because public key encryption is slow
61 but symmetric encryption is fast. So symmetric encryption is used for
62 bulk encryption and the small random symmetric key used is transferred
63 using public key encryption.
64
65 It is possible to call EVP_SealInit() twice in the same way as
66 EVP_EncryptInit(). The first call should have npubk set to 0 and (after
67 setting any cipher parameters) it should be called again with type set
68 to NULL.
69
71 evp(7), RAND_bytes(3), EVP_EncryptInit(3), EVP_OpenInit(3)
72
74 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
75
76 Licensed under the OpenSSL license (the "License"). You may not use
77 this file except in compliance with the License. You can obtain a copy
78 in the file LICENSE in the source distribution or at
79 <https://www.openssl.org/source/license.html>.
80
81
82
831.1.1c 2019-05-28 EVP_SEALINIT(3)