2
0

EVP_SealInit.pod 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. =pod
  2. =head1 NAME
  3. EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption
  4. =head1 SYNOPSIS
  5. #include <openssl/evp.h>
  6. int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  7. unsigned char **ek, int *ekl, unsigned char *iv,
  8. EVP_PKEY **pubk, int npubk);
  9. int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
  10. int *outl, unsigned char *in, int inl);
  11. int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
  12. int *outl);
  13. =head1 DESCRIPTION
  14. The EVP envelope routines are a high level interface to envelope
  15. encryption. They generate a random key and IV (if required) then
  16. "envelope" it by using public key encryption. Data can then be
  17. encrypted using this key.
  18. EVP_SealInit() initializes a cipher context B<ctx> for encryption
  19. with cipher B<type> using a random secret key and IV. B<type> is normally
  20. supplied by a function such as EVP_des_cbc(). The secret key is encrypted
  21. using one or more public keys, this allows the same encrypted data to be
  22. decrypted using any of the corresponding private keys. B<ek> is an array of
  23. buffers where the public key encrypted secret key will be written, each buffer
  24. must contain enough room for the corresponding encrypted key: that is
  25. B<ek[i]> must have room for B<EVP_PKEY_size(pubk[i])> bytes. The actual
  26. size of each encrypted secret key is written to the array B<ekl>. B<pubk> is
  27. an array of B<npubk> public keys.
  28. The B<iv> parameter is a buffer where the generated IV is written to. It must
  29. contain enough room for the corresponding cipher's IV, as determined by (for
  30. example) EVP_CIPHER_iv_length(type).
  31. If the cipher does not require an IV then the B<iv> parameter is ignored
  32. and can be B<NULL>.
  33. EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
  34. as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
  35. documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual
  36. page.
  37. =head1 RETURN VALUES
  38. EVP_SealInit() returns 0 on error or B<npubk> if successful.
  39. EVP_SealUpdate() and EVP_SealFinal() return 1 for success and 0 for
  40. failure.
  41. =head1 NOTES
  42. Because a random secret key is generated the random number generator
  43. must be seeded before calling EVP_SealInit().
  44. The public key must be RSA because it is the only OpenSSL public key
  45. algorithm that supports key transport.
  46. Envelope encryption is the usual method of using public key encryption
  47. on large amounts of data, this is because public key encryption is slow
  48. but symmetric encryption is fast. So symmetric encryption is used for
  49. bulk encryption and the small random symmetric key used is transferred
  50. using public key encryption.
  51. It is possible to call EVP_SealInit() twice in the same way as
  52. EVP_EncryptInit(). The first call should have B<npubk> set to 0
  53. and (after setting any cipher parameters) it should be called again
  54. with B<type> set to NULL.
  55. =head1 SEE ALSO
  56. L<evp(3)|evp(3)>, L<rand(3)|rand(3)>,
  57. L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
  58. L<EVP_OpenInit(3)|EVP_OpenInit(3)>
  59. =head1 HISTORY
  60. EVP_SealFinal() did not return a value before OpenSSL 0.9.7.
  61. =cut