diff options
Diffstat (limited to 'src/lib/libcrypto/man/BIO_f_cipher.3')
-rw-r--r-- | src/lib/libcrypto/man/BIO_f_cipher.3 | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BIO_f_cipher.3 b/src/lib/libcrypto/man/BIO_f_cipher.3 new file mode 100644 index 0000000000..68f425eb75 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_f_cipher.3 | |||
@@ -0,0 +1,114 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_F_CIPHER 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_f_cipher , | ||
6 | .Nm BIO_set_cipher , | ||
7 | .Nm BIO_get_cipher_status , | ||
8 | .Nm BIO_get_cipher_ctx | ||
9 | .Nd cipher BIO filter | ||
10 | .Sh SYNOPSIS | ||
11 | .In openssl/bio.h | ||
12 | .In openssl/evp.h | ||
13 | .Ft BIO_METHOD * | ||
14 | .Fo BIO_f_cipher | ||
15 | .Fa void | ||
16 | .Fc | ||
17 | .Ft void | ||
18 | .Fo BIO_set_cipher | ||
19 | .Fa "BIO *b" | ||
20 | .Fa "const EVP_CIPHER *cipher" | ||
21 | .Fa "unsigned char *key" | ||
22 | .Fa "unsigned char *iv" | ||
23 | .Fa "int enc" | ||
24 | .Fc | ||
25 | .Ft int | ||
26 | .Fo BIO_get_cipher_status | ||
27 | .Fa "BIO *b" | ||
28 | .Fc | ||
29 | .Ft int | ||
30 | .Fo BIO_get_cipher_ctx | ||
31 | .Fa "BIO *b" | ||
32 | .Fa "EVP_CIPHER_CTX **pctx" | ||
33 | .Fc | ||
34 | .Sh DESCRIPTION | ||
35 | .Fn BIO_f_cipher | ||
36 | returns the cipher BIO method. | ||
37 | This is a filter BIO that encrypts any data written through it, | ||
38 | and decrypts any data read from it. | ||
39 | It is a BIO wrapper for the cipher routines | ||
40 | .Xr EVP_CipherInit 3 , | ||
41 | .Xr EVP_CipherUpdate 3 , | ||
42 | and | ||
43 | .Xr EVP_CipherFinal 3 . | ||
44 | .Pp | ||
45 | Cipher BIOs do not support | ||
46 | .Xr BIO_gets 3 | ||
47 | or | ||
48 | .Xr BIO_puts 3 . | ||
49 | .Pp | ||
50 | .Xr BIO_flush 3 | ||
51 | on an encryption BIO that is being written through | ||
52 | is used to signal that no more data is to be encrypted: | ||
53 | this is used to flush and possibly pad the final block through the BIO. | ||
54 | .Pp | ||
55 | .Fn BIO_set_cipher | ||
56 | sets the cipher of BIO | ||
57 | .Fa b | ||
58 | to | ||
59 | .Fa cipher | ||
60 | using key | ||
61 | .Fa key | ||
62 | and IV | ||
63 | .Fa iv . | ||
64 | .Fa enc | ||
65 | should be set to 1 for encryption and zero for decryption. | ||
66 | .Pp | ||
67 | When reading from an encryption BIO, the final block is automatically | ||
68 | decrypted and checked when EOF is detected. | ||
69 | .Fn BIO_get_cipher_status | ||
70 | is a | ||
71 | .Xr BIO_ctrl 3 | ||
72 | macro which can be called to determine | ||
73 | whether the decryption operation was successful. | ||
74 | .Pp | ||
75 | .Fn BIO_get_cipher_ctx | ||
76 | is a | ||
77 | .Xr BIO_ctrl 3 | ||
78 | macro which retrieves the internal BIO cipher context. | ||
79 | The retrieved context can be used in conjunction | ||
80 | with the standard cipher routines to set it up. | ||
81 | This is useful when | ||
82 | .Fn BIO_set_cipher | ||
83 | is not flexible enough for the applications needs. | ||
84 | .Sh NOTES | ||
85 | When encrypting, | ||
86 | .Xr BIO_flush 3 | ||
87 | must be called to flush the final block through the BIO. | ||
88 | If it is not, then the final block will fail a subsequent decrypt. | ||
89 | .Pp | ||
90 | When decrypting, an error on the final block is signalled | ||
91 | by a zero return value from the read operation. | ||
92 | A successful decrypt followed by EOF | ||
93 | will also return zero for the final read. | ||
94 | .Fn BIO_get_cipher_status | ||
95 | should be called to determine if the decrypt was successful. | ||
96 | .Pp | ||
97 | As always, if | ||
98 | .Xr BIO_gets 3 | ||
99 | or | ||
100 | .Xr BIO_puts 3 | ||
101 | support is needed, then it can be achieved | ||
102 | by preceding the cipher BIO with a buffering BIO. | ||
103 | .Sh RETURN VALUES | ||
104 | .Fn BIO_f_cipher | ||
105 | returns the cipher BIO method. | ||
106 | .Pp | ||
107 | .Fn BIO_set_cipher | ||
108 | does not return a value. | ||
109 | .Pp | ||
110 | .Fn BIO_get_cipher_status | ||
111 | returns 1 for a successful decrypt and 0 for failure. | ||
112 | .Pp | ||
113 | .Fn BIO_get_cipher_ctx | ||
114 | currently always returns 1. | ||