1 .\" $OpenBSD: BIO_f_cipher.3,v 1.6 2016/12/06 14:45:08 schwarze Exp $
2 .\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2000, 2003, 2015, 2016 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: December 6 2016 $
58 .Nm BIO_get_cipher_status ,
59 .Nm BIO_get_cipher_ctx
71 .Fa "const EVP_CIPHER *cipher"
72 .Fa "unsigned char *key"
73 .Fa "unsigned char *iv"
77 .Fo BIO_get_cipher_status
81 .Fo BIO_get_cipher_ctx
83 .Fa "EVP_CIPHER_CTX **pctx"
87 returns the cipher BIO method.
88 This is a filter BIO that encrypts any data written through it,
89 and decrypts any data read from it.
90 It is a BIO wrapper for the cipher routines
91 .Xr EVP_CipherInit 3 ,
92 .Xr EVP_CipherUpdate 3 ,
94 .Xr EVP_CipherFinal 3 .
96 Cipher BIOs do not support
102 on an encryption BIO that is being written through
103 is used to signal that no more data is to be encrypted:
104 this is used to flush and possibly pad the final block through the BIO.
107 sets the cipher of BIO
116 should be set to 1 for encryption and zero for decryption.
118 When reading from an encryption BIO, the final block is automatically
119 decrypted and checked when EOF is detected.
120 .Fn BIO_get_cipher_status
123 macro which can be called to determine
124 whether the decryption operation was successful.
126 .Fn BIO_get_cipher_ctx
129 macro which retrieves the internal BIO cipher context.
130 The retrieved context can be used in conjunction
131 with the standard cipher routines to set it up.
134 is not flexible enough for the applications needs.
138 must be called to flush the final block through the BIO.
139 If it is not, then the final block will fail a subsequent decrypt.
141 When decrypting, an error on the final block is signalled
142 by a zero return value from the read operation.
143 A successful decrypt followed by EOF
144 will also return zero for the final read.
145 .Fn BIO_get_cipher_status
146 should be called to determine if the decrypt was successful.
152 support is needed, then it can be achieved
153 by preceding the cipher BIO with a buffering BIO.
156 returns the cipher BIO method.
158 .Fn BIO_get_cipher_status
159 returns 1 for a successful decrypt and 0 for failure.
161 .Fn BIO_get_cipher_ctx
162 currently always returns 1.