Blame doc/man3/BIO_f_cipher.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
BIO_f_cipher, BIO_set_cipher, BIO_get_cipher_status, BIO_get_cipher_ctx - cipher BIO filter
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
=for comment multiple includes
Packit c4476c
Packit c4476c
 #include <openssl/bio.h>
Packit c4476c
 #include <openssl/evp.h>
Packit c4476c
Packit c4476c
 const BIO_METHOD *BIO_f_cipher(void);
Packit c4476c
 void BIO_set_cipher(BIO *b, const EVP_CIPHER *cipher,
Packit c4476c
                     unsigned char *key, unsigned char *iv, int enc);
Packit c4476c
 int BIO_get_cipher_status(BIO *b)
Packit c4476c
 int BIO_get_cipher_ctx(BIO *b, EVP_CIPHER_CTX **pctx)
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
BIO_f_cipher() returns the cipher BIO method. This is a filter
Packit c4476c
BIO that encrypts any data written through it, and decrypts any data
Packit c4476c
read from it. It is a BIO wrapper for the cipher routines
Packit c4476c
EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal().
Packit c4476c
Packit c4476c
Cipher BIOs do not support BIO_gets() or BIO_puts().
Packit c4476c
Packit c4476c
BIO_flush() on an encryption BIO that is being written through is
Packit c4476c
used to signal that no more data is to be encrypted: this is used
Packit c4476c
to flush and possibly pad the final block through the BIO.
Packit c4476c
Packit c4476c
BIO_set_cipher() sets the cipher of BIO B to B<cipher> using key B<key>
Packit c4476c
and IV B<iv>. B<enc> should be set to 1 for encryption and zero for
Packit c4476c
decryption.
Packit c4476c
Packit c4476c
When reading from an encryption BIO the final block is automatically
Packit c4476c
decrypted and checked when EOF is detected. BIO_get_cipher_status()
Packit c4476c
is a BIO_ctrl() macro which can be called to determine whether the
Packit c4476c
decryption operation was successful.
Packit c4476c
Packit c4476c
BIO_get_cipher_ctx() is a BIO_ctrl() macro which retrieves the internal
Packit c4476c
BIO cipher context. The retrieved context can be used in conjunction
Packit c4476c
with the standard cipher routines to set it up. This is useful when
Packit c4476c
BIO_set_cipher() is not flexible enough for the applications needs.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
When encrypting BIO_flush() B<must> be called to flush the final block
Packit c4476c
through the BIO. If it is not then the final block will fail a subsequent
Packit c4476c
decrypt.
Packit c4476c
Packit c4476c
When decrypting an error on the final block is signaled by a zero
Packit c4476c
return value from the read operation. A successful decrypt followed
Packit c4476c
by EOF will also return zero for the final read. BIO_get_cipher_status()
Packit c4476c
should be called to determine if the decrypt was successful.
Packit c4476c
Packit c4476c
As always, if BIO_gets() or BIO_puts() support is needed then it can
Packit c4476c
be achieved by preceding the cipher BIO with a buffering BIO.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
BIO_f_cipher() returns the cipher BIO method.
Packit c4476c
Packit c4476c
BIO_set_cipher() does not return a value.
Packit c4476c
Packit c4476c
BIO_get_cipher_status() returns 1 for a successful decrypt and 0
Packit c4476c
for failure.
Packit c4476c
Packit c4476c
BIO_get_cipher_ctx() currently always returns 1.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut