5 EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption
9 #include <openssl/evp.h>
11 int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
12 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk);
13 void EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
14 int *outl, unsigned char *in, int inl);
15 void EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
20 The EVP envelope routines are a high level interface to envelope
21 encryption. They generate a random key and then "envelope" it by
22 using public key encryption. Data can then be encrypted using this
25 EVP_SealInit() initialises a cipher context B<ctx> for encryption
26 with cipher B<type> using a random secret key and IV supplied in
27 the B<iv> parameter. B<type> is normally supplied by a function such
28 as EVP_des_cbc(). The secret key is encrypted using one or more public
29 keys, this allows the same encrypted data to be decrypted using any
30 of the corresponding private keys. B<ek> is an array of buffers where
31 the public key encrypted secret key will be written, each buffer must
32 contain enough room for the corresponding encrypted key: that is
33 B<ek[i]> must have room for B<EVP_PKEY_size(pubk[i])> bytes. The actual
34 size of each encrypted secret key is written to the array B<ekl>. B<pubk> is
35 an array of B<npubk> public keys.
37 EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
38 as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
39 documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual
44 EVP_SealInit() returns -1 on error or B<npubk> if successful.
46 EVP_SealUpdate() and EVP_SealFinal() do not return values.
50 Because a random secret key is generated the random number generator
51 must be seeded before calling EVP_SealInit().
53 The public key must be RSA because it is the only OpenSSL public key
54 algorithm that supports key transport.
56 Envelope encryption is the usual method of using public key encryption
57 on large amounts of data, this is because public key encryption is slow
58 but symmetric encryption is fast. So symmetric encryption is used for
59 bulk encryption and the small random symmetric key used is transferred
60 using public key encryption.
64 L<evp(3)|evp(3)>,L<rand(3)|rand(3)>
65 L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
66 L<EVP_OpenInit(3)|EVP_OpenInit(3)>