EVP_SealInit.pod 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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, int *outl);
  12. =head1 DESCRIPTION
  13. The EVP envelope routines are a high level interface to envelope
  14. encryption. They generate a random key and IV (if required) then
  15. "envelope" it by using public key encryption. Data can then be
  16. encrypted using this key.
  17. EVP_SealInit() initializes a cipher context B<ctx> for encryption
  18. with cipher B<type> using a random secret key and IV. B<type> is normally
  19. supplied by a function such as EVP_aes_256_cbc(). The secret key is encrypted
  20. using one or more public keys, this allows the same encrypted data to be
  21. decrypted using any of the corresponding private keys. B<ek> is an array of
  22. buffers where the public key encrypted secret key will be written, each buffer
  23. must contain enough room for the corresponding encrypted key: that is
  24. B<ek[i]> must have room for B<EVP_PKEY_size(pubk[i])> bytes. The actual
  25. size of each encrypted secret key is written to the array B<ekl>. B<pubk> is
  26. an array of B<npubk> public keys.
  27. The B<iv> parameter is a buffer where the generated IV is written to. It must
  28. contain enough room for the corresponding cipher's IV, as determined by (for
  29. example) EVP_CIPHER_iv_length(type).
  30. If the cipher does not require an IV then the B<iv> parameter is ignored
  31. and can be B<NULL>.
  32. EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
  33. as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
  34. documented on the L<EVP_EncryptInit(3)> manual
  35. page.
  36. =head1 RETURN VALUES
  37. EVP_SealInit() returns 0 on error or B<npubk> if successful.
  38. EVP_SealUpdate() and EVP_SealFinal() return 1 for success and 0 for
  39. failure.
  40. =head1 NOTES
  41. Because a random secret key is generated the random number generator
  42. must be seeded before calling EVP_SealInit().
  43. The public key must be RSA because it is the only OpenSSL public key
  44. algorithm that supports key transport.
  45. Envelope encryption is the usual method of using public key encryption
  46. on large amounts of data, this is because public key encryption is slow
  47. but symmetric encryption is fast. So symmetric encryption is used for
  48. bulk encryption and the small random symmetric key used is transferred
  49. using public key encryption.
  50. It is possible to call EVP_SealInit() twice in the same way as
  51. EVP_EncryptInit(). The first call should have B<npubk> set to 0
  52. and (after setting any cipher parameters) it should be called again
  53. with B<type> set to NULL.
  54. =head1 SEE ALSO
  55. L<evp(7)>, L<RAND_bytes(3)>,
  56. L<EVP_EncryptInit(3)>,
  57. L<EVP_OpenInit(3)>
  58. =head1 COPYRIGHT
  59. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  60. Licensed under the OpenSSL license (the "License"). You may not use
  61. this file except in compliance with the License. You can obtain a copy
  62. in the file LICENSE in the source distribution or at
  63. L<https://www.openssl.org/source/license.html>.
  64. =cut