BIO_f_cipher.pod 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. =pod
  2. =head1 NAME
  3. BIO_f_cipher, BIO_set_cipher, BIO_get_cipher_status, BIO_get_cipher_ctx - cipher BIO filter
  4. =head1 SYNOPSIS
  5. #include <openssl/bio.h>
  6. #include <openssl/evp.h>
  7. BIO_METHOD * BIO_f_cipher(void);
  8. void BIO_set_cipher(BIO *b,const EVP_CIPHER *cipher,
  9. unsigned char *key, unsigned char *iv, int enc);
  10. int BIO_get_cipher_status(BIO *b)
  11. int BIO_get_cipher_ctx(BIO *b, EVP_CIPHER_CTX **pctx)
  12. =head1 DESCRIPTION
  13. BIO_f_cipher() returns the cipher BIO method. This is a filter
  14. BIO that encrypts any data written through it, and decrypts any data
  15. read from it. It is a BIO wrapper for the cipher routines
  16. EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal().
  17. Cipher BIOs do not support BIO_gets() or BIO_puts().
  18. BIO_flush() on an encryption BIO that is being written through is
  19. used to signal that no more data is to be encrypted: this is used
  20. to flush and possibly pad the final block through the BIO.
  21. BIO_set_cipher() sets the cipher of BIO B<b> to B<cipher> using key B<key>
  22. and IV B<iv>. B<enc> should be set to 1 for encryption and zero for
  23. decryption.
  24. When reading from an encryption BIO the final block is automatically
  25. decrypted and checked when EOF is detected. BIO_get_cipher_status()
  26. is a BIO_ctrl() macro which can be called to determine whether the
  27. decryption operation was successful.
  28. BIO_get_cipher_ctx() is a BIO_ctrl() macro which retrieves the internal
  29. BIO cipher context. The retrieved context can be used in conjunction
  30. with the standard cipher routines to set it up. This is useful when
  31. BIO_set_cipher() is not flexible enough for the applications needs.
  32. =head1 NOTES
  33. When encrypting BIO_flush() B<must> be called to flush the final block
  34. through the BIO. If it is not then the final block will fail a subsequent
  35. decrypt.
  36. When decrypting an error on the final block is signalled by a zero
  37. return value from the read operation. A successful decrypt followed
  38. by EOF will also return zero for the final read. BIO_get_cipher_status()
  39. should be called to determine if the decrypt was successful.
  40. As always, if BIO_gets() or BIO_puts() support is needed then it can
  41. be achieved by preceding the cipher BIO with a buffering BIO.
  42. =head1 RETURN VALUES
  43. BIO_f_cipher() returns the cipher BIO method.
  44. BIO_set_cipher() does not return a value.
  45. BIO_get_cipher_status() returns 1 for a successful decrypt and 0
  46. for failure.
  47. BIO_get_cipher_ctx() currently always returns 1.
  48. =head1 EXAMPLES
  49. TBA
  50. =head1 SEE ALSO
  51. TBA