1EVP_SEALINIT(3ossl) OpenSSL EVP_SEALINIT(3ossl)
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
32 EVP_PKEY_get_size(pubk[i]) bytes. The actual size of each encrypted
33 secret key is written to the array ekl. pubk is an array of npubk
34 public keys.
35
36 The iv parameter is a buffer where the generated IV is written to. It
37 must contain enough room for the corresponding cipher's IV, as
38 determined by (for example) EVP_CIPHER_get_iv_length(type).
39
40 If the cipher does not require an IV then the iv parameter is ignored
41 and can be NULL.
42
43 EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
44 as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
45 documented on the EVP_EncryptInit(3) manual page.
46
48 EVP_SealInit() returns 0 on error or npubk if successful.
49
50 EVP_SealUpdate() and EVP_SealFinal() return 1 for success and 0 for
51 failure.
52
54 Because a random secret key is generated the random number generator
55 must be seeded when EVP_SealInit() is called. If the automatic seeding
56 or reseeding of the OpenSSL CSPRNG fails due to external circumstances
57 (see RAND(7)), the operation will fail.
58
59 The public key must be RSA because it is the only OpenSSL public key
60 algorithm that supports key transport.
61
62 Envelope encryption is the usual method of using public key encryption
63 on large amounts of data, this is because public key encryption is slow
64 but symmetric encryption is fast. So symmetric encryption is used for
65 bulk encryption and the small random symmetric key used is transferred
66 using public key encryption.
67
68 It is possible to call EVP_SealInit() twice in the same way as
69 EVP_EncryptInit(). The first call should have npubk set to 0 and (after
70 setting any cipher parameters) it should be called again with type set
71 to NULL.
72
74 evp(7), RAND_bytes(3), EVP_EncryptInit(3), EVP_OpenInit(3), RAND(7)
75
77 Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
78
79 Licensed under the Apache License 2.0 (the "License"). You may not use
80 this file except in compliance with the License. You can obtain a copy
81 in the file LICENSE in the source distribution or at
82 <https://www.openssl.org/source/license.html>.
83
84
85
863.0.5 2022-07-05 EVP_SEALINIT(3ossl)