1BIO_F_CIPHER(3ossl)                 OpenSSL                BIO_F_CIPHER(3ossl)
2
3
4

NAME

6       BIO_f_cipher, BIO_set_cipher, BIO_get_cipher_status, BIO_get_cipher_ctx
7       - cipher BIO filter
8

SYNOPSIS

10        #include <openssl/bio.h>
11        #include <openssl/evp.h>
12
13        const BIO_METHOD *BIO_f_cipher(void);
14        int BIO_set_cipher(BIO *b, const EVP_CIPHER *cipher,
15                           const unsigned char *key, const unsigned char *iv, int enc);
16        int BIO_get_cipher_status(BIO *b);
17        int BIO_get_cipher_ctx(BIO *b, EVP_CIPHER_CTX **pctx);
18

DESCRIPTION

20       BIO_f_cipher() returns the cipher BIO method. This is a filter BIO that
21       encrypts any data written through it, and decrypts any data read from
22       it. It is a BIO wrapper for the cipher routines EVP_CipherInit(),
23       EVP_CipherUpdate() and EVP_CipherFinal().
24
25       Cipher BIOs do not support BIO_gets() or BIO_puts().
26
27       BIO_flush() on an encryption BIO that is being written through is used
28       to signal that no more data is to be encrypted: this is used to flush
29       and possibly pad the final block through the BIO.
30
31       BIO_set_cipher() sets the cipher of BIO b to cipher using key key and
32       IV iv. enc should be set to 1 for encryption and zero for decryption.
33
34       When reading from an encryption BIO the final block is automatically
35       decrypted and checked when EOF is detected. BIO_get_cipher_status() is
36       a BIO_ctrl() macro which can be called to determine whether the
37       decryption operation was successful.
38
39       BIO_get_cipher_ctx() is a BIO_ctrl() macro which retrieves the internal
40       BIO cipher context. The retrieved context can be used in conjunction
41       with the standard cipher routines to set it up. This is useful when
42       BIO_set_cipher() is not flexible enough for the applications needs.
43

NOTES

45       When encrypting BIO_flush() must be called to flush the final block
46       through the BIO. If it is not then the final block will fail a
47       subsequent decrypt.
48
49       When decrypting an error on the final block is signaled by a zero
50       return value from the read operation. A successful decrypt followed by
51       EOF will also return zero for the final read. BIO_get_cipher_status()
52       should be called to determine if the decrypt was successful.
53
54       As always, if BIO_gets() or BIO_puts() support is needed then it can be
55       achieved by preceding the cipher BIO with a buffering BIO.
56

RETURN VALUES

58       BIO_f_cipher() returns the cipher BIO method.
59
60       BIO_set_cipher() returns 1 for success and 0 for failure.
61
62       BIO_get_cipher_status() returns 1 for a successful decrypt and <=0 for
63       failure.
64
65       BIO_get_cipher_ctx() returns 1 for success and <=0 for failure.
66
68       Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
69
70       Licensed under the Apache License 2.0 (the "License").  You may not use
71       this file except in compliance with the License.  You can obtain a copy
72       in the file LICENSE in the source distribution or at
73       <https://www.openssl.org/source/license.html>.
74
75
76
773.0.5                             2022-07-05               BIO_F_CIPHER(3ossl)
Impressum