5 EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption
9 #include <openssl/evp.h>
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,
21 The EVP envelope routines are a high level interface to envelope
22 encryption. They generate a random key and IV (if required) then
23 "envelope" it by using public key encryption. Data can then be
24 encrypted using this key.
26 EVP_SealInit() initializes a cipher context B<ctx> for encryption
27 with cipher B<type> using a random secret key and IV. B<type> is normally
28 supplied by a function such as EVP_des_cbc(). The secret key is encrypted
29 using one or more public keys, this allows the same encrypted data to be
30 decrypted using any of the corresponding private keys. B<ek> is an array of
31 buffers where the public key encrypted secret key will be written, each buffer
32 must 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 The B<iv> parameter is a buffer where the generated IV is written to. It must
38 contain enough room for the corresponding cipher's IV, as determined by (for
39 example) EVP_CIPHER_iv_length(type).
41 If the cipher does not require an IV then the B<iv> parameter is ignored
44 EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
45 as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
46 documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual
51 EVP_SealInit() returns 0 on error or B<npubk> if successful.
53 EVP_SealUpdate() and EVP_SealFinal() return 1 for success and 0 for
58 Because a random secret key is generated the random number generator
59 must be seeded before calling EVP_SealInit().
61 The public key must be RSA because it is the only OpenSSL public key
62 algorithm that supports key transport.
64 Envelope encryption is the usual method of using public key encryption
65 on large amounts of data, this is because public key encryption is slow
66 but symmetric encryption is fast. So symmetric encryption is used for
67 bulk encryption and the small random symmetric key used is transferred
68 using public key encryption.
70 It is possible to call EVP_SealInit() twice in the same way as
71 EVP_EncryptInit(). The first call should have B<npubk> set to 0
72 and (after setting any cipher parameters) it should be called again
73 with B<type> set to NULL.
77 L<evp(3)|evp(3)>, L<rand(3)|rand(3)>,
78 L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
79 L<EVP_OpenInit(3)|EVP_OpenInit(3)>
83 EVP_SealFinal() did not return a value before OpenSSL 0.9.7.