diff options
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r-- | src/lib/libcrypto/man/BF_set_key.3 | 215 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO.3 | 56 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_ctrl.3 | 264 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_f_base64.3 | 80 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_f_buffer.3 | 110 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_f_cipher.3 | 114 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_f_md.3 | 209 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_f_null.3 | 25 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_find_type.3 | 117 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_new.3 | 104 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BIO_new_CMS.3 | 83 | ||||
-rw-r--r-- | src/lib/libcrypto/man/Makefile | 8 |
12 files changed, 1381 insertions, 4 deletions
diff --git a/src/lib/libcrypto/man/BF_set_key.3 b/src/lib/libcrypto/man/BF_set_key.3 new file mode 100644 index 0000000000..53ff53896c --- /dev/null +++ b/src/lib/libcrypto/man/BF_set_key.3 | |||
@@ -0,0 +1,215 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BF_SET_KEY 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BF_set_key , | ||
6 | .Nm BF_encrypt , | ||
7 | .Nm BF_decrypt , | ||
8 | .Nm BF_ecb_encrypt , | ||
9 | .Nm BF_cbc_encrypt , | ||
10 | .Nm BF_cfb64_encrypt , | ||
11 | .Nm BF_ofb64_encrypt , | ||
12 | .Nm BF_options | ||
13 | .Nd Blowfish encryption | ||
14 | .Sh SYNOPSIS | ||
15 | .In openssl/blowfish.h | ||
16 | .Ft void | ||
17 | .Fo BF_set_key | ||
18 | .Fa "BF_KEY *key" | ||
19 | .Fa "int len" | ||
20 | .Fa "const unsigned char *data" | ||
21 | .Fc | ||
22 | .Ft void | ||
23 | .Fo BF_ecb_encrypt | ||
24 | .Fa "const unsigned char *in" | ||
25 | .Fa "unsigned char *out" | ||
26 | .Fa "BF_KEY *key" | ||
27 | .Fa "int enc" | ||
28 | .Fc | ||
29 | .Ft void | ||
30 | .Fo BF_cbc_encrypt | ||
31 | .Fa "const unsigned char *in" | ||
32 | .Fa "unsigned char *out" | ||
33 | .Fa "long length" | ||
34 | .Fa "BF_KEY *schedule" | ||
35 | .Fa "unsigned char *ivec" | ||
36 | .Fa "int enc" | ||
37 | .Fc | ||
38 | .Ft void | ||
39 | .Fo BF_cfb64_encrypt | ||
40 | .Fa "const unsigned char *in" | ||
41 | .Fa "unsigned char *out" | ||
42 | .Fa "long length" | ||
43 | .Fa "BF_KEY *schedule" | ||
44 | .Fa "unsigned char *ivec" | ||
45 | .Fa "int *num" | ||
46 | .Fa "int enc" | ||
47 | .Fc | ||
48 | .Ft void | ||
49 | .Fo BF_ofb64_encrypt | ||
50 | .Fa "const unsigned char *in" | ||
51 | .Fa "unsigned char *out" | ||
52 | .Fa "long length" | ||
53 | .Fa "BF_KEY *schedule" | ||
54 | .Fa "unsigned char *ivec" | ||
55 | .Fa "int *num" | ||
56 | .Fc | ||
57 | .Ft const char * | ||
58 | .Fo BF_options | ||
59 | .Fa void | ||
60 | .Fc | ||
61 | .Ft void | ||
62 | .Fo BF_encrypt | ||
63 | .Fa "BF_LONG *data" | ||
64 | .Fa "const BF_KEY *key" | ||
65 | .Fc | ||
66 | .Ft void | ||
67 | .Fo BF_decrypt | ||
68 | .Fa "BF_LONG *data" | ||
69 | .Fa "const BF_KEY *key" | ||
70 | .Fc | ||
71 | .Sh DESCRIPTION | ||
72 | This library implements the Blowfish cipher, | ||
73 | which was invented and described by | ||
74 | .An Counterpane . | ||
75 | .Pp | ||
76 | Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data. | ||
77 | It uses a variable size key, but typically, 128 bit (16 byte) keys | ||
78 | are considered good for strong encryption. | ||
79 | Blowfish can be used in the same modes as DES (see | ||
80 | .Xr des_modes 3 ) . | ||
81 | Blowfish is currently one of the faster block ciphers. | ||
82 | It is quite a bit faster than DES, and much faster than IDEA or RC2. | ||
83 | .Pp | ||
84 | Blowfish consists of a key setup phase | ||
85 | and the actual encryption or decryption phase. | ||
86 | .Pp | ||
87 | .Fn BF_set_key | ||
88 | sets up the | ||
89 | .Vt BF_KEY | ||
90 | .Fa key | ||
91 | using the | ||
92 | .Fa len | ||
93 | bytes long key at | ||
94 | .Fa data . | ||
95 | .Pp | ||
96 | .Fn BF_ecb_encrypt | ||
97 | is the basic Blowfish encryption and decryption function. | ||
98 | It encrypts or decrypts the first 64 bits of | ||
99 | .Fa in | ||
100 | using the key | ||
101 | .Fa key , | ||
102 | putting the result in | ||
103 | .Fa out . | ||
104 | .Fa enc | ||
105 | decides if encryption | ||
106 | .Pq Dv BF_ENCRYPT | ||
107 | or decryption | ||
108 | .Pq Dv BF_DECRYPT | ||
109 | shall be performed. | ||
110 | The vector pointed at by | ||
111 | .Fa in | ||
112 | and | ||
113 | .Fa out | ||
114 | must be 64 bits in length, no less. | ||
115 | If they are larger, everything after the first 64 bits is ignored. | ||
116 | .Pp | ||
117 | The mode functions | ||
118 | .Fn BF_cbc_encrypt , | ||
119 | .Fn BF_cfb64_encrypt , | ||
120 | and | ||
121 | .Fn BF_ofb64_encrypt | ||
122 | all operate on variable length data. | ||
123 | They all take an initialization vector | ||
124 | .Fa ivec | ||
125 | which needs to be passed along into the next call of the same function | ||
126 | for the same message. | ||
127 | .Fa ivec | ||
128 | may be initialized with anything, but the recipient needs to know what | ||
129 | it was initialized with, or it won't be able to decrypt. | ||
130 | Some programs and protocols simplify this, like SSH, where | ||
131 | .Fa ivec | ||
132 | is simply initialized to zero. | ||
133 | .Fn BF_cbc_encrypt | ||
134 | operates on data that is a multiple of 8 bytes long, while | ||
135 | .Fn BF_cfb64_encrypt | ||
136 | and | ||
137 | .Fn BF_ofb64_encrypt | ||
138 | are used to encrypt an variable number of bytes (the amount | ||
139 | does not have to be an exact multiple of 8). | ||
140 | The purpose of the latter two is to simulate stream ciphers, | ||
141 | and therefore, they need the parameter | ||
142 | .Fa num , | ||
143 | which is a pointer to an integer where the current offset in | ||
144 | .Fa ivec | ||
145 | is stored between calls. | ||
146 | This integer must be initialized to zero when | ||
147 | .Fa ivec | ||
148 | is initialized. | ||
149 | .Pp | ||
150 | .Fn BF_cbc_encrypt | ||
151 | is the Cipher Block Chaining function for Blowfish. | ||
152 | It encrypts or decrypts the 64 bits chunks of | ||
153 | .Fa in | ||
154 | using the key | ||
155 | .Fa schedule , | ||
156 | putting the result in | ||
157 | .Fa out . | ||
158 | .Fa enc | ||
159 | decides if encryption | ||
160 | .Pq Dv BF_ENCRYPT | ||
161 | or decryption | ||
162 | .Pq Dv BF_DECRYPT | ||
163 | shall be performed. | ||
164 | .Fa ivec | ||
165 | must point at an 8 byte long initialization vector. | ||
166 | .Pp | ||
167 | .Fn BF_cfb64_encrypt | ||
168 | is the CFB mode for Blowfish with 64 bit feedback. | ||
169 | It encrypts or decrypts the bytes in | ||
170 | .Fa in | ||
171 | using the key | ||
172 | .Fa schedule , | ||
173 | putting the result in | ||
174 | .Fa out . | ||
175 | .Fa enc | ||
176 | decides if encryption | ||
177 | .Pq Dv BF_ENCRYPT | ||
178 | or decryption | ||
179 | .Pq Dv BF_DECRYPT | ||
180 | shall be performed. | ||
181 | .Fa ivec | ||
182 | must point at an | ||
183 | 8 byte long initialization vector. | ||
184 | .Fa num | ||
185 | must point at an integer which must be initially zero. | ||
186 | .Pp | ||
187 | .Fn BF_ofb64_encrypt | ||
188 | is the OFB mode for Blowfish with 64 bit feedback. | ||
189 | It uses the same parameters as | ||
190 | .Fn BF_cfb64_encrypt , | ||
191 | which must be initialized the same way. | ||
192 | .Pp | ||
193 | .Fn BF_encrypt | ||
194 | and | ||
195 | .Fn BF_decrypt | ||
196 | are the lowest level functions for Blowfish encryption. | ||
197 | They encrypt/decrypt the first 64 bits of the vector pointed by | ||
198 | .Fa data , | ||
199 | using the key | ||
200 | .Fa key . | ||
201 | These functions should not be used unless you implement 'modes' of Blowfish. | ||
202 | The alternative is to use | ||
203 | .Fn BF_ecb_encrypt . | ||
204 | If you still want to use these functions, you should be aware | ||
205 | that they take each 32-bit chunk in host-byte order, | ||
206 | which is little-endian on little-endian platforms | ||
207 | and big-endian on big-endian ones. | ||
208 | .Sh RETURN VALUES | ||
209 | None of the functions presented here return any value. | ||
210 | .Sh NOTE | ||
211 | Applications should use the higher level functions | ||
212 | .Xr EVP_EncryptInit 3 | ||
213 | etc. instead of calling the blowfish functions directly. | ||
214 | .Sh HISTORY | ||
215 | The Blowfish functions are available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/BIO.3 b/src/lib/libcrypto/man/BIO.3 new file mode 100644 index 0000000000..f352379003 --- /dev/null +++ b/src/lib/libcrypto/man/BIO.3 | |||
@@ -0,0 +1,56 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO | ||
6 | .Nd I/O abstraction | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/bio.h | ||
9 | .Sh DESCRIPTION | ||
10 | A BIO is an I/O abstraction, | ||
11 | it hides many of the underlying I/O details from an application. | ||
12 | If an application uses a BIO for its I/O, it can transparently handle | ||
13 | SSL connections, unencrypted network connections and file I/O. | ||
14 | .Pp | ||
15 | There are two types of BIO, a source/sink BIO and a filter BIO. | ||
16 | .Pp | ||
17 | As its name implies, a source/sink BIO is a source and/or sink of data, | ||
18 | examples include a socket BIO and a file BIO. | ||
19 | .Pp | ||
20 | A filter BIO takes data from one BIO and passes it through | ||
21 | to another, or to the application. | ||
22 | The data may be left unmodified (for example a message digest BIO) | ||
23 | or translated (for example an encryption BIO). | ||
24 | The effect of a filter BIO may change according to the I/O operation | ||
25 | it is performing: for example an encryption BIO will encrypt data | ||
26 | if it is being written to and decrypt data if it is being read from. | ||
27 | .Pp | ||
28 | BIOs can be joined together to form a chain | ||
29 | (a single BIO is a chain with one component). | ||
30 | A chain normally consist of one source/sink BIO | ||
31 | and one or more filter BIOs. | ||
32 | Data read from or written to the first BIO then traverses the chain | ||
33 | to the end (normally a source/sink BIO). | ||
34 | .Sh SEE ALSO | ||
35 | .Xr BIO_ctrl 3 , | ||
36 | .Xr BIO_f_base64 3 , | ||
37 | .Xr BIO_f_buffer 3 , | ||
38 | .Xr BIO_f_cipher 3 , | ||
39 | .Xr BIO_f_md 3 , | ||
40 | .Xr BIO_f_null 3 , | ||
41 | .Xr BIO_f_ssl 3 , | ||
42 | .Xr BIO_find_type 3 , | ||
43 | .Xr BIO_new 3 , | ||
44 | .Xr BIO_new_bio_pair 3 , | ||
45 | .Xr BIO_push 3 , | ||
46 | .Xr BIO_read 3 , | ||
47 | .Xr BIO_s_accept 3 , | ||
48 | .Xr BIO_s_bio 3 , | ||
49 | .Xr BIO_s_connect 3 , | ||
50 | .Xr BIO_s_fd 3 , | ||
51 | .Xr BIO_s_file 3 , | ||
52 | .Xr BIO_s_mem 3 , | ||
53 | .Xr BIO_s_null 3 , | ||
54 | .Xr BIO_s_socket 3 , | ||
55 | .Xr BIO_set_callback 3 , | ||
56 | .Xr BIO_should_retry 3 | ||
diff --git a/src/lib/libcrypto/man/BIO_ctrl.3 b/src/lib/libcrypto/man/BIO_ctrl.3 new file mode 100644 index 0000000000..75d665a4be --- /dev/null +++ b/src/lib/libcrypto/man/BIO_ctrl.3 | |||
@@ -0,0 +1,264 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_CTRL 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_ctrl , | ||
6 | .Nm BIO_callback_ctrl , | ||
7 | .Nm BIO_ptr_ctrl , | ||
8 | .Nm BIO_int_ctrl , | ||
9 | .Nm BIO_reset , | ||
10 | .Nm BIO_seek , | ||
11 | .Nm BIO_tell , | ||
12 | .Nm BIO_flush , | ||
13 | .Nm BIO_eof , | ||
14 | .Nm BIO_set_close , | ||
15 | .Nm BIO_get_close , | ||
16 | .Nm BIO_pending , | ||
17 | .Nm BIO_wpending , | ||
18 | .Nm BIO_ctrl_pending , | ||
19 | .Nm BIO_ctrl_wpending , | ||
20 | .Nm BIO_get_info_callback , | ||
21 | .Nm BIO_set_info_callback | ||
22 | .Nd BIO control operations | ||
23 | .Sh SYNOPSIS | ||
24 | .In openssl/bio.h | ||
25 | .Ft long | ||
26 | .Fo BIO_ctrl | ||
27 | .Fa "BIO *bp" | ||
28 | .Fa "int cmd" | ||
29 | .Fa "long larg" | ||
30 | .Fa "void *parg" | ||
31 | .Fc | ||
32 | .Ft long | ||
33 | .Fo BIO_callback_ctrl | ||
34 | .Fa "BIO *b" | ||
35 | .Fa "int cmd" | ||
36 | .Fa "void (*fp)(struct bio_st *, int, const char *, int, long, long)" | ||
37 | .Fc | ||
38 | .Ft char * | ||
39 | .Fo BIO_ptr_ctrl | ||
40 | .Fa "BIO *bp" | ||
41 | .Fa "int cmd" | ||
42 | .Fa "long larg" | ||
43 | .Fc | ||
44 | .Ft long | ||
45 | .Fo BIO_int_ctrl | ||
46 | .Fa "BIO *bp" | ||
47 | .Fa "int cmd" | ||
48 | .Fa "long larg" | ||
49 | .Fa "int iarg" | ||
50 | .Fc | ||
51 | .Ft int | ||
52 | .Fo BIO_reset | ||
53 | .Fa "BIO *b" | ||
54 | .Fc | ||
55 | .Ft int | ||
56 | .Fo BIO_seek | ||
57 | .Fa "BIO *b" | ||
58 | .Fa "int ofs" | ||
59 | .Fc | ||
60 | .Ft int | ||
61 | .Fo BIO_tell | ||
62 | .Fa "BIO *b" | ||
63 | .Fc | ||
64 | .Ft int | ||
65 | .Fo BIO_flush | ||
66 | .Fa "BIO *b" | ||
67 | .Fc | ||
68 | .Ft int | ||
69 | .Fo BIO_eof | ||
70 | .Fa "BIO *b" | ||
71 | .Fc | ||
72 | .Ft int | ||
73 | .Fo BIO_set_close | ||
74 | .Fa "BIO *b" | ||
75 | .Fa "long flag" | ||
76 | .Fc | ||
77 | .Ft int | ||
78 | .Fo BIO_get_close | ||
79 | .Fa "BIO *b" | ||
80 | .Fc | ||
81 | .Ft int | ||
82 | .Fo BIO_pending | ||
83 | .Fa "BIO *b" | ||
84 | .Fc | ||
85 | .Ft int | ||
86 | .Fo BIO_wpending | ||
87 | .Fa "BIO *b" | ||
88 | .Fc | ||
89 | .Ft size_t | ||
90 | .Fo BIO_ctrl_pending | ||
91 | .Fa "BIO *b" | ||
92 | .Fc | ||
93 | .Ft size_t | ||
94 | .Fo BIO_ctrl_wpending | ||
95 | .Fa "BIO *b" | ||
96 | .Fc | ||
97 | .Ft int | ||
98 | .Fo BIO_get_info_callback | ||
99 | .Fa "BIO *b" | ||
100 | .Fa "bio_info_cb **cbp" | ||
101 | .Fc | ||
102 | .Ft int | ||
103 | .Fo BIO_set_info_callback | ||
104 | .Fa "BIO *b" | ||
105 | .Fa "bio_info_cb *cb" | ||
106 | .Fc | ||
107 | .Ft typedef void | ||
108 | .Fo bio_info_cb | ||
109 | .Fa "BIO *b" | ||
110 | .Fa "int oper" | ||
111 | .Fa "const char *ptr" | ||
112 | .Fa "int arg1" | ||
113 | .Fa "long arg2" | ||
114 | .Fa "long arg3" | ||
115 | .Fc | ||
116 | .Sh DESCRIPTION | ||
117 | .Fn BIO_ctrl , | ||
118 | .Fn BIO_callback_ctrl , | ||
119 | .Fn BIO_ptr_ctrl , | ||
120 | and | ||
121 | .Fn BIO_int_ctrl | ||
122 | are BIO "control" operations taking arguments of various types. | ||
123 | These functions are not normally called directly, | ||
124 | various macros are used instead. | ||
125 | The standard macros are described below, macros specific to a | ||
126 | particular type of BIO are described in the specific BIO's manual | ||
127 | page as well as any special features of the standard calls. | ||
128 | .Pp | ||
129 | .Fn BIO_reset | ||
130 | typically resets a BIO to some initial state, in the case | ||
131 | of file related BIOs for example it rewinds the file pointer | ||
132 | to the start of the file. | ||
133 | .Pp | ||
134 | .Fn BIO_seek | ||
135 | resets a file related BIO's (that is file descriptor and | ||
136 | FILE BIOs) file position pointer to | ||
137 | .Fa ofs | ||
138 | bytes from start of file. | ||
139 | .Pp | ||
140 | .Fn BIO_tell | ||
141 | returns the current file position of a file related BIO. | ||
142 | .Pp | ||
143 | .Fn BIO_flush | ||
144 | normally writes out any internally buffered data, in some cases | ||
145 | it is used to signal EOF and that no more data will be written. | ||
146 | .Pp | ||
147 | .Fn BIO_eof | ||
148 | returns 1 if the BIO has read EOF, the precise meaning of | ||
149 | "EOF" varies according to the BIO type. | ||
150 | .Pp | ||
151 | .Fn BIO_set_close | ||
152 | sets the BIO | ||
153 | .Fa b | ||
154 | close flag to | ||
155 | .Fa flag . | ||
156 | .Fa flag | ||
157 | can take the value | ||
158 | .Dv BIO_CLOSE | ||
159 | or | ||
160 | .Dv BIO_NOCLOSE . | ||
161 | Typically | ||
162 | .Dv BIO_CLOSE | ||
163 | is used in a source/sink BIO to indicate that the underlying I/O stream | ||
164 | should be closed when the BIO is freed. | ||
165 | .Pp | ||
166 | .Fn BIO_get_close | ||
167 | returns the BIO's close flag. | ||
168 | .Pp | ||
169 | .Fn BIO_pending , | ||
170 | .Fn BIO_ctrl_pending , | ||
171 | .Fn BIO_wpending , | ||
172 | and | ||
173 | .Fn BIO_ctrl_wpending | ||
174 | return the number of pending characters in the BIO's read and write buffers. | ||
175 | Not all BIOs support these calls. | ||
176 | .Fn BIO_ctrl_pending | ||
177 | and | ||
178 | .Fn BIO_ctrl_wpending | ||
179 | return a | ||
180 | .Vt size_t | ||
181 | type and are functions, | ||
182 | .Fn BIO_pending | ||
183 | and | ||
184 | .Fn BIO_wpending | ||
185 | are macros which call | ||
186 | .Fn BIO_ctrl . | ||
187 | .Sh RETURN VALUES | ||
188 | .Fn BIO_reset | ||
189 | normally returns 1 for success and 0 or -1 for failure. | ||
190 | File BIOs are an exception, they return 0 for success and -1 for failure. | ||
191 | .Pp | ||
192 | .Fn BIO_seek | ||
193 | and | ||
194 | .Fn BIO_tell | ||
195 | both return the current file position on success | ||
196 | and -1 for failure, except file BIOs which for | ||
197 | .Fn BIO_seek | ||
198 | always return 0 for success and -1 for failure. | ||
199 | .Pp | ||
200 | .Fn BIO_flush | ||
201 | returns 1 for success and 0 or -1 for failure. | ||
202 | .Pp | ||
203 | .Fn BIO_eof | ||
204 | returns 1 if EOF has been reached 0 otherwise. | ||
205 | .Pp | ||
206 | .Fn BIO_set_close | ||
207 | always returns 1. | ||
208 | .Pp | ||
209 | .Fn BIO_get_close | ||
210 | returns the close flag value | ||
211 | .Dv BIO_CLOSE | ||
212 | or | ||
213 | .Dv BIO_NOCLOSE . | ||
214 | .Pp | ||
215 | .Fn BIO_pending , | ||
216 | .Fn BIO_ctrl_pending , | ||
217 | .Fn BIO_wpending , | ||
218 | and | ||
219 | .Fn BIO_ctrl_wpending | ||
220 | return the amount of pending data. | ||
221 | .Sh NOTES | ||
222 | Because it can write data, | ||
223 | .Fn BIO_flush | ||
224 | may return 0 or -1 indicating that the call should be retried later | ||
225 | in a similar manner to | ||
226 | .Fn BIO_write . | ||
227 | The | ||
228 | .Fn BIO_should_retry | ||
229 | call should be used and appropriate action taken is the call fails. | ||
230 | .Pp | ||
231 | The return values of | ||
232 | .Fn BIO_pending | ||
233 | and | ||
234 | .Fn BIO_wpending | ||
235 | may not reliably determine the amount of pending data in all cases. | ||
236 | For example in the case of a file BIO some data may be available in the | ||
237 | .Vt FILE | ||
238 | structure's internal buffers but it is not possible | ||
239 | to determine this in a portably way. | ||
240 | For other types of BIO they may not be supported. | ||
241 | .Pp | ||
242 | If they do not internally handle a particular | ||
243 | .Fn BIO_ctrl | ||
244 | operation, filter BIOs usually pass the operation | ||
245 | to the next BIO in the chain. | ||
246 | This often means there is no need to locate the required BIO for | ||
247 | a particular operation, it can be called on a chain and it will | ||
248 | be automatically passed to the relevant BIO. | ||
249 | However this can cause unexpected results: | ||
250 | for example no current filter BIOs implement | ||
251 | .Fn BIO_seek , | ||
252 | but this may still succeed if the chain ends | ||
253 | in a FILE or file descriptor BIO. | ||
254 | .Pp | ||
255 | Source/sink BIOs return an 0 if they do not recognize the | ||
256 | .Fn BIO_ctrl | ||
257 | operation. | ||
258 | .Sh BUGS | ||
259 | Some of the return values are ambiguous and care should be taken. | ||
260 | In particular a return value of 0 can be returned if an operation | ||
261 | is not supported, if an error occurred, if EOF has not been reached | ||
262 | and in the case of | ||
263 | .Fn BIO_seek | ||
264 | on a file BIO for a successful operation. | ||
diff --git a/src/lib/libcrypto/man/BIO_f_base64.3 b/src/lib/libcrypto/man/BIO_f_base64.3 new file mode 100644 index 0000000000..e08191b84a --- /dev/null +++ b/src/lib/libcrypto/man/BIO_f_base64.3 | |||
@@ -0,0 +1,80 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_F_BASE64 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_f_base64 | ||
6 | .Nd base64 BIO filter | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/bio.h | ||
9 | .In openssl/evp.h | ||
10 | .Ft BIO_METHOD * | ||
11 | .Fo BIO_f_base64 | ||
12 | .Fa void | ||
13 | .Fc | ||
14 | .Sh DESCRIPTION | ||
15 | .Fn BIO_f_base64 | ||
16 | returns the base64 BIO method. | ||
17 | This is a filter BIO that base64 encodes any data written through it | ||
18 | and decodes any data read through it. | ||
19 | .Pp | ||
20 | Base64 BIOs do not support | ||
21 | .Xr BIO_gets 3 | ||
22 | or | ||
23 | .Xr BIO_puts 3 . | ||
24 | .Pp | ||
25 | .Xr BIO_flush 3 | ||
26 | on a base64 BIO that is being written through | ||
27 | is used to signal that no more data is to be encoded: | ||
28 | this is used to flush the final block through the BIO. | ||
29 | .Pp | ||
30 | The flag | ||
31 | .Dv BIO_FLAGS_BASE64_NO_NL | ||
32 | can be set with | ||
33 | .Xr BIO_set_flags 3 | ||
34 | to encode the data all on one line | ||
35 | or expect the data to be all on one line. | ||
36 | .Sh NOTES | ||
37 | Because of the format of base64 encoding the end of the encoded | ||
38 | block cannot always be reliably determined. | ||
39 | .Sh RETURN VALUES | ||
40 | .Fn BIO_f_base64 | ||
41 | returns the base64 BIO method. | ||
42 | .Sh EXAMPLES | ||
43 | Base64 encode the string "Hello World\en" | ||
44 | and write the result to standard output: | ||
45 | .Bd -literal -offset indent | ||
46 | BIO *bio, *b64; | ||
47 | char message[] = "Hello World \en"; | ||
48 | |||
49 | b64 = BIO_new(BIO_f_base64()); | ||
50 | bio = BIO_new_fp(stdout, BIO_NOCLOSE); | ||
51 | BIO_push(b64, bio); | ||
52 | BIO_write(b64, message, strlen(message)); | ||
53 | BIO_flush(b64); | ||
54 | |||
55 | BIO_free_all(b64); | ||
56 | .Ed | ||
57 | .Pp | ||
58 | Read Base64 encoded data from standard input | ||
59 | and write the decoded data to standard output: | ||
60 | .Bd -literal -offset indent | ||
61 | BIO *bio, *b64, *bio_out; | ||
62 | char inbuf[512]; | ||
63 | int inlen; | ||
64 | |||
65 | b64 = BIO_new(BIO_f_base64()); | ||
66 | bio = BIO_new_fp(stdin, BIO_NOCLOSE); | ||
67 | bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); | ||
68 | BIO_push(b64, bio); | ||
69 | while((inlen = BIO_read(b64, inbuf, 512)) > 0) | ||
70 | BIO_write(bio_out, inbuf, inlen); | ||
71 | |||
72 | BIO_flush(bio_out); | ||
73 | BIO_free_all(b64); | ||
74 | .Ed | ||
75 | .Sh BUGS | ||
76 | The ambiguity of EOF in base64 encoded data can cause additional | ||
77 | data following the base64 encoded block to be misinterpreted. | ||
78 | .Pp | ||
79 | There should be some way of specifying a test that the BIO can perform | ||
80 | to reliably determine EOF (for example a MIME boundary). | ||
diff --git a/src/lib/libcrypto/man/BIO_f_buffer.3 b/src/lib/libcrypto/man/BIO_f_buffer.3 new file mode 100644 index 0000000000..c01ab4809b --- /dev/null +++ b/src/lib/libcrypto/man/BIO_f_buffer.3 | |||
@@ -0,0 +1,110 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_F_BUFFER 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_f_buffer | ||
6 | .Nd buffering BIO | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/bio.h | ||
9 | .Ft BIO_METHOD * | ||
10 | .Fo BIO_f_buffer | ||
11 | .Fa void | ||
12 | .Fc | ||
13 | .Bd -literal | ||
14 | #define BIO_get_buffer_num_lines(b) \e | ||
15 | BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) | ||
16 | #define BIO_set_read_buffer_size(b,size) \e | ||
17 | BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) | ||
18 | #define BIO_set_write_buffer_size(b,size) \e | ||
19 | BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) | ||
20 | #define BIO_set_buffer_size(b,size) \e | ||
21 | BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) | ||
22 | #define BIO_set_buffer_read_data(b,buf,num) \e | ||
23 | BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) | ||
24 | .Ed | ||
25 | .Sh DESCRIPTION | ||
26 | .Fn BIO_f_buffer | ||
27 | returns the buffering BIO method. | ||
28 | .Pp | ||
29 | Data written to a buffering BIO is buffered and periodically written | ||
30 | to the next BIO in the chain. | ||
31 | Data read from a buffering BIO comes from an internal buffer | ||
32 | which is filled from the next BIO in the chain. | ||
33 | Both | ||
34 | .Xr BIO_gets 3 | ||
35 | and | ||
36 | .Xr BIO_puts 3 | ||
37 | are supported. | ||
38 | .Pp | ||
39 | Calling | ||
40 | .Xr BIO_reset 3 | ||
41 | on a buffering BIO clears any buffered data. | ||
42 | .Pp | ||
43 | .Fn BIO_get_buffer_num_lines | ||
44 | returns the number of lines currently buffered. | ||
45 | .Pp | ||
46 | .Fn BIO_set_read_buffer_size , | ||
47 | .Fn BIO_set_write_buffer_size , | ||
48 | and | ||
49 | .Fn BIO_set_buffer_size | ||
50 | set the read, write or both read and write buffer sizes to | ||
51 | .Fa size . | ||
52 | The initial buffer size is | ||
53 | .Dv DEFAULT_BUFFER_SIZE , | ||
54 | currently 4096. | ||
55 | Any attempt to reduce the buffer size below | ||
56 | .Dv DEFAULT_BUFFER_SIZE | ||
57 | is ignored. | ||
58 | Any buffered data is cleared when the buffer is resized. | ||
59 | .Pp | ||
60 | .Fn BIO_set_buffer_read_data | ||
61 | clears the read buffer and fills it with | ||
62 | .Fa num | ||
63 | bytes of | ||
64 | .Fa buf . | ||
65 | If | ||
66 | .Fa num | ||
67 | is larger than the current buffer size the buffer is expanded. | ||
68 | .Sh NOTES | ||
69 | Buffering BIOs implement | ||
70 | .Xr BIO_gets 3 | ||
71 | by using | ||
72 | .Xr BIO_read 3 | ||
73 | operations on the next BIO in the chain. | ||
74 | By prepending a buffering BIO to a chain | ||
75 | it is therefore possible to provide | ||
76 | .Xr BIO_gets 3 | ||
77 | functionality if the following BIOs do not support it (for example SSL BIOs). | ||
78 | .Pp | ||
79 | Data is only written to the next BIO in the chain | ||
80 | when the write buffer fills or when | ||
81 | .Xr BIO_flush 3 | ||
82 | is called. | ||
83 | It is therefore important to call | ||
84 | .Xr BIO_flush 3 | ||
85 | whenever any pending data should be written | ||
86 | such as when removing a buffering BIO using | ||
87 | .Xr BIO_pop 3 . | ||
88 | .Xr BIO_flush 3 | ||
89 | may need to be retried if the ultimate source/sink BIO is non blocking. | ||
90 | .Sh RETURN VALUES | ||
91 | .Fn BIO_f_buffer | ||
92 | returns the buffering BIO method. | ||
93 | .Pp | ||
94 | .Fn BIO_get_buffer_num_lines | ||
95 | returns the number of lines buffered (may be 0). | ||
96 | .Pp | ||
97 | .Fn BIO_set_read_buffer_size , | ||
98 | .Fn BIO_set_write_buffer_size , | ||
99 | and | ||
100 | .Fn BIO_set_buffer_size | ||
101 | return 1 if the buffer was successfully resized or 0 for failure. | ||
102 | .Pp | ||
103 | .Fn BIO_set_buffer_read_data | ||
104 | returns 1 if the data was set correctly or 0 if there was an error. | ||
105 | .Sh SEE ALSO | ||
106 | .Xr BIO 3 , | ||
107 | .Xr BIO_ctrl 3 , | ||
108 | .Xr BIO_flush 3 , | ||
109 | .Xr BIO_pop 3 , | ||
110 | .Xr BIO_reset 3 | ||
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. | ||
diff --git a/src/lib/libcrypto/man/BIO_f_md.3 b/src/lib/libcrypto/man/BIO_f_md.3 new file mode 100644 index 0000000000..de21722608 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_f_md.3 | |||
@@ -0,0 +1,209 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_F_MD 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_f_md , | ||
6 | .Nm BIO_set_md , | ||
7 | .Nm BIO_get_md , | ||
8 | .Nm BIO_get_md_ctx | ||
9 | .Nd message digest BIO filter | ||
10 | .Sh SYNOPSIS | ||
11 | .In openssl/bio.h | ||
12 | .In openssl/evp.h | ||
13 | .Ft BIO_METHOD * | ||
14 | .Fo BIO_f_md | ||
15 | .Fa void | ||
16 | .Fc | ||
17 | .Ft int | ||
18 | .Fo BIO_set_md | ||
19 | .Fa "BIO *b" | ||
20 | .Fa "EVP_MD *md" | ||
21 | .Fc | ||
22 | .Ft int | ||
23 | .Fo BIO_get_md | ||
24 | .Fa "BIO *b" | ||
25 | .Fa "EVP_MD **mdp" | ||
26 | .Fc | ||
27 | .Ft int | ||
28 | .Fo BIO_get_md_ctx | ||
29 | .Fa "BIO *b" | ||
30 | .Fa "EVP_MD_CTX **mdcp" | ||
31 | .Fc | ||
32 | .Sh DESCRIPTION | ||
33 | .Fn BIO_f_md | ||
34 | returns the message digest BIO method. | ||
35 | This is a filter BIO that digests any data passed through it. | ||
36 | It is a BIO wrapper for the digest routines | ||
37 | .Fn EVP_DigestInit , | ||
38 | .Fn EVP_DigestUpdate , | ||
39 | and | ||
40 | .Fn EVP_DigestFinal . | ||
41 | .Pp | ||
42 | Any data written or read through a digest BIO using | ||
43 | .Xr BIO_read 3 | ||
44 | and | ||
45 | .Xr BIO_write 3 | ||
46 | is digested. | ||
47 | .Pp | ||
48 | .Xr BIO_gets 3 , | ||
49 | if its | ||
50 | .Sy size | ||
51 | parameter is large enough, | ||
52 | finishes the digest calculation and returns the digest value. | ||
53 | .Xr BIO_puts 3 | ||
54 | is | ||
55 | not supported. | ||
56 | .Pp | ||
57 | .Xr BIO_reset 3 | ||
58 | reinitialises a digest BIO. | ||
59 | .Pp | ||
60 | .Fn BIO_set_md | ||
61 | sets the message digest of BIO | ||
62 | .Fa b | ||
63 | to | ||
64 | .Fa md : | ||
65 | this must be called to initialize a digest BIO | ||
66 | before any data is passed through it. | ||
67 | It is a | ||
68 | .Xr BIO_ctrl 3 | ||
69 | macro. | ||
70 | .Pp | ||
71 | .Fn BIO_get_md | ||
72 | places the a pointer to the digest BIOs digest method in | ||
73 | .Fa mdp . | ||
74 | It is a | ||
75 | .Xr BIO_ctrl 3 | ||
76 | macro. | ||
77 | .Pp | ||
78 | .Fn BIO_get_md_ctx | ||
79 | returns the digest BIOs context in | ||
80 | .Fa mdcp . | ||
81 | .Sh NOTES | ||
82 | The context returned by | ||
83 | .Fn BIO_get_md_ctx | ||
84 | can be used in calls to | ||
85 | .Xr EVP_DigestFinal 3 | ||
86 | and also in the signature routines | ||
87 | .Xr EVP_SignFinal 3 | ||
88 | and | ||
89 | .Xr EVP_VerifyFinal 3 . | ||
90 | .Pp | ||
91 | The context returned by | ||
92 | .Fn BIO_get_md_ctx | ||
93 | is an internal context structure. | ||
94 | Changes made to this context will affect the digest BIO itself, and | ||
95 | the context pointer will become invalid when the digest BIO is freed. | ||
96 | .Pp | ||
97 | After the digest has been retrieved from a digest BIO, | ||
98 | it must be reinitialized by calling | ||
99 | .Xr BIO_reset 3 | ||
100 | or | ||
101 | .Fn BIO_set_md | ||
102 | before any more data is passed through it. | ||
103 | .Pp | ||
104 | If an application needs to call | ||
105 | .Xr BIO_gets 3 | ||
106 | or | ||
107 | .Xr BIO_puts 3 | ||
108 | through a chain containing digest BIOs, | ||
109 | then this can be done by prepending a buffering BIO. | ||
110 | .Pp | ||
111 | Before OpenSSL 1.0.0 the call to | ||
112 | .Fn BIO_get_md_ctx | ||
113 | would only work if the BIO had been initialized for example by calling | ||
114 | .Fn BIO_set_md . | ||
115 | In OpenSSL 1.0.0 and later the context is always returned | ||
116 | and the BIO is state is set to initialized. | ||
117 | This allows applications to initialize the context externally | ||
118 | if the standard calls such as | ||
119 | .Fn BIO_set_md | ||
120 | are not sufficiently flexible. | ||
121 | .Sh RETURN VALUES | ||
122 | .Fn BIO_f_md | ||
123 | returns the digest BIO method. | ||
124 | .Pp | ||
125 | .Fn BIO_set_md , | ||
126 | .Fn BIO_get_md , | ||
127 | and | ||
128 | .Fn BIO_get_md_ctx | ||
129 | return 1 for success and 0 for failure. | ||
130 | .Sh EXAMPLES | ||
131 | The following example creates a BIO chain containing an SHA1 and MD5 | ||
132 | digest BIO and passes the string "Hello World" through it. | ||
133 | Error checking has been omitted for clarity. | ||
134 | .Bd -literal -offset 2n | ||
135 | BIO *bio, *mdtmp; | ||
136 | const char message[] = "Hello World"; | ||
137 | bio = BIO_new(BIO_s_null()); | ||
138 | mdtmp = BIO_new(BIO_f_md()); | ||
139 | BIO_set_md(mdtmp, EVP_sha1()); | ||
140 | /* | ||
141 | * For BIO_push() we want to append the sink BIO | ||
142 | * and keep a note of the start of the chain. | ||
143 | */ | ||
144 | bio = BIO_push(mdtmp, bio); | ||
145 | mdtmp = BIO_new(BIO_f_md()); | ||
146 | BIO_set_md(mdtmp, EVP_md5()); | ||
147 | bio = BIO_push(mdtmp, bio); | ||
148 | /* Note: mdtmp can now be discarded */ | ||
149 | BIO_write(bio, message, strlen(message)); | ||
150 | .Ed | ||
151 | .Pp | ||
152 | The next example digests data by reading through a chain instead: | ||
153 | .Bd -literal -offset 2n | ||
154 | BIO *bio, *mdtmp; | ||
155 | char buf[1024]; | ||
156 | int rdlen; | ||
157 | |||
158 | bio = BIO_new_file(file, "rb"); | ||
159 | mdtmp = BIO_new(BIO_f_md()); | ||
160 | BIO_set_md(mdtmp, EVP_sha1()); | ||
161 | bio = BIO_push(mdtmp, bio); | ||
162 | mdtmp = BIO_new(BIO_f_md()); | ||
163 | BIO_set_md(mdtmp, EVP_md5()); | ||
164 | bio = BIO_push(mdtmp, bio); | ||
165 | do { | ||
166 | rdlen = BIO_read(bio, buf, sizeof(buf)); | ||
167 | /* Might want to do something with the data here */ | ||
168 | } while (rdlen > 0); | ||
169 | .Ed | ||
170 | .Pp | ||
171 | This next example retrieves the message digests from a BIO chain | ||
172 | and outputs them. | ||
173 | This could be used with the examples above. | ||
174 | .Bd -literal -offset 2n | ||
175 | BIO *mdtmp; | ||
176 | unsigned char mdbuf[EVP_MAX_MD_SIZE]; | ||
177 | int mdlen; | ||
178 | int i; | ||
179 | |||
180 | mdtmp = bio; /* Assume bio has previously been set up */ | ||
181 | do { | ||
182 | EVP_MD *md; | ||
183 | mdtmp = BIO_find_type(mdtmp, BIO_TYPE_MD); | ||
184 | if (!mdtmp) | ||
185 | break; | ||
186 | BIO_get_md(mdtmp, &md); | ||
187 | printf("%s digest", OBJ_nid2sn(EVP_MD_type(md))); | ||
188 | mdlen = BIO_gets(mdtmp, mdbuf, EVP_MAX_MD_SIZE); | ||
189 | for(i = 0; i < mdlen; i++) | ||
190 | printf(":%02X", mdbuf[i]); | ||
191 | printf("\en"); | ||
192 | mdtmp = BIO_next(mdtmp); | ||
193 | } while(mdtmp); | ||
194 | BIO_free_all(bio); | ||
195 | .Ed | ||
196 | .Sh BUGS | ||
197 | The lack of support for | ||
198 | .Xr BIO_puts 3 | ||
199 | and the non standard behaviour of | ||
200 | .Xr BIO_gets 3 | ||
201 | could be regarded as anomalous. | ||
202 | It could be argued that | ||
203 | .Xr BIO_gets 3 | ||
204 | and | ||
205 | .Xr BIO_puts 3 | ||
206 | should be passed to the next BIO in the chain and digest the data | ||
207 | passed through and that digests should be retrieved using a separate | ||
208 | .Xr BIO_ctrl 3 | ||
209 | call. | ||
diff --git a/src/lib/libcrypto/man/BIO_f_null.3 b/src/lib/libcrypto/man/BIO_f_null.3 new file mode 100644 index 0000000000..a09cc77631 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_f_null.3 | |||
@@ -0,0 +1,25 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_F_NULL 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_f_null | ||
6 | .Nd null filter | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/bio.h | ||
9 | .Ft BIO_METHOD * | ||
10 | .Fo BIO_f_null | ||
11 | .Fa void | ||
12 | .Fc | ||
13 | .Sh DESCRIPTION | ||
14 | .Fn BIO_f_null | ||
15 | returns the null filter BIO method. | ||
16 | This is a filter BIO that does nothing. | ||
17 | .Pp | ||
18 | All requests to a null filter BIO are passed through to the next BIO | ||
19 | in the chain: this means that a BIO chain containing a null filter BIO | ||
20 | behaves just as though the BIO was not there. | ||
21 | .Sh NOTES | ||
22 | As may be apparent, a null filter BIO is not particularly useful. | ||
23 | .Sh RETURN VALUES | ||
24 | .Fn BIO_f_null | ||
25 | returns the null filter BIO method. | ||
diff --git a/src/lib/libcrypto/man/BIO_find_type.3 b/src/lib/libcrypto/man/BIO_find_type.3 new file mode 100644 index 0000000000..f573ad7675 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_find_type.3 | |||
@@ -0,0 +1,117 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_FIND_TYPE 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_find_type , | ||
6 | .Nm BIO_next , | ||
7 | .Nm BIO_method_type | ||
8 | .Nd BIO chain traversal | ||
9 | .Sh SYNOPSIS | ||
10 | .In openssl/bio.h | ||
11 | .Ft BIO * | ||
12 | .Fo BIO_find_type | ||
13 | .Fa "BIO *b" | ||
14 | .Fa "int bio_type" | ||
15 | .Fc | ||
16 | .Ft BIO * | ||
17 | .Fo BIO_next | ||
18 | .Fa "BIO *b" | ||
19 | .Fc | ||
20 | .Fd #define BIO_method_type(b) ((b)->method->type) | ||
21 | .Fd #define BIO_TYPE_NONE 0 | ||
22 | .Fd #define BIO_TYPE_MEM (1|0x0400) | ||
23 | .Fd #define BIO_TYPE_FILE (2|0x0400) | ||
24 | .Fd #define BIO_TYPE_FD (4|0x0400|0x0100) | ||
25 | .Fd #define BIO_TYPE_SOCKET (5|0x0400|0x0100) | ||
26 | .Fd #define BIO_TYPE_NULL (6|0x0400) | ||
27 | .Fd #define BIO_TYPE_SSL (7|0x0200) | ||
28 | .Fd #define BIO_TYPE_MD (8|0x0200) | ||
29 | .Fd #define BIO_TYPE_BUFFER (9|0x0200) | ||
30 | .Fd #define BIO_TYPE_CIPHER (10|0x0200) | ||
31 | .Fd #define BIO_TYPE_BASE64 (11|0x0200) | ||
32 | .Fd #define BIO_TYPE_CONNECT (12|0x0400|0x0100) | ||
33 | .Fd #define BIO_TYPE_ACCEPT (13|0x0400|0x0100) | ||
34 | .Fd #define BIO_TYPE_PROXY_CLIENT (14|0x0200) | ||
35 | .Fd #define BIO_TYPE_PROXY_SERVER (15|0x0200) | ||
36 | .Fd #define BIO_TYPE_NBIO_TEST (16|0x0200) | ||
37 | .Fd #define BIO_TYPE_NULL_FILTER (17|0x0200) | ||
38 | .Fd #define BIO_TYPE_BER (18|0x0200) | ||
39 | .Fd #define BIO_TYPE_BIO (19|0x0400) | ||
40 | .Fd #define BIO_TYPE_DESCRIPTOR 0x0100 | ||
41 | .Fd #define BIO_TYPE_FILTER 0x0200 | ||
42 | .Fd #define BIO_TYPE_SOURCE_SINK 0x0400 | ||
43 | .Sh DESCRIPTION | ||
44 | The function | ||
45 | .Fn BIO_find_type | ||
46 | searches for a BIO of a given type in a chain, starting at BIO | ||
47 | .Fa b . | ||
48 | If | ||
49 | .Fa bio_type | ||
50 | is a specific type (such as | ||
51 | .Dv BIO_TYPE_MEM ) , | ||
52 | then a search is made for a BIO of that type. | ||
53 | If | ||
54 | .Fa bio_type | ||
55 | is a general type (such as | ||
56 | .Dv BIO_TYPE_SOURCE_SINK ) , | ||
57 | then the next matching BIO of the given general type is searched for. | ||
58 | .Fn BIO_find_type | ||
59 | returns the next matching BIO or | ||
60 | .Dv NULL | ||
61 | if none is found. | ||
62 | .Pp | ||
63 | Note: not all the | ||
64 | .Dv BIO_TYPE_* | ||
65 | types above have corresponding BIO implementations. | ||
66 | .Pp | ||
67 | .Fn BIO_next | ||
68 | returns the next BIO in a chain. | ||
69 | It can be used to traverse all BIOs in a chain or used in conjunction with | ||
70 | .Fn BIO_find_type | ||
71 | to find all BIOs of a certain type. | ||
72 | .Pp | ||
73 | .Fn BIO_method_type | ||
74 | returns the type of a BIO. | ||
75 | .Sh RETURN VALUES | ||
76 | .Fn BIO_find_type | ||
77 | returns a matching BIO or | ||
78 | .Dv NULL | ||
79 | for no match. | ||
80 | .Pp | ||
81 | .Fn BIO_next | ||
82 | returns the next BIO in a chain. | ||
83 | .Pp | ||
84 | .Fn BIO_method_type | ||
85 | returns the type of the BIO | ||
86 | .Fa b . | ||
87 | .Sh NOTES | ||
88 | .Fn BIO_next | ||
89 | was added to OpenSSL 0.9.6 to provide a 'clean' way to traverse a BIO | ||
90 | chain or find multiple matches using | ||
91 | .Fn BIO_find_type . | ||
92 | Previous versions had to use: | ||
93 | .Pp | ||
94 | .Dl next = bio->next_bio; | ||
95 | .Sh BUGS | ||
96 | .Fn BIO_find_type | ||
97 | in OpenSSL 0.9.5a and earlier could not be safely passed a | ||
98 | .Dv NULL | ||
99 | pointer for the | ||
100 | .Fa b | ||
101 | argument. | ||
102 | .Sh EXAMPLE | ||
103 | Traverse a chain looking for digest BIOs: | ||
104 | .Bd -literal -offset 2n | ||
105 | BIO *btmp; | ||
106 | btmp = in_bio; /* in_bio is chain to search through */ | ||
107 | |||
108 | do { | ||
109 | btmp = BIO_find_type(btmp, BIO_TYPE_MD); | ||
110 | if (btmp == NULL) | ||
111 | break; /* Not found */ | ||
112 | /* btmp is a digest BIO, do something with it ...*/ | ||
113 | ... | ||
114 | |||
115 | btmp = BIO_next(btmp); | ||
116 | } while(btmp); | ||
117 | .Ed | ||
diff --git a/src/lib/libcrypto/man/BIO_new.3 b/src/lib/libcrypto/man/BIO_new.3 new file mode 100644 index 0000000000..5f5030cdfa --- /dev/null +++ b/src/lib/libcrypto/man/BIO_new.3 | |||
@@ -0,0 +1,104 @@ | |||
1 | .Dd July 17, 2014 | ||
2 | .Dt BIO_NEW 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_new , | ||
6 | .Nm BIO_set , | ||
7 | .Nm BIO_free , | ||
8 | .Nm BIO_vfree , | ||
9 | .Nm BIO_free_all | ||
10 | .Nd BIO allocation and freeing functions | ||
11 | .Sh SYNOPSIS | ||
12 | .In openssl/bio.h | ||
13 | .Ft BIO * | ||
14 | .Fo BIO_new | ||
15 | .Fa "BIO_METHOD *type" | ||
16 | .Fc | ||
17 | .Ft int | ||
18 | .Fo BIO_set | ||
19 | .Fa "BIO *a" | ||
20 | .Fa "BIO_METHOD *type" | ||
21 | .Fc | ||
22 | .Ft int | ||
23 | .Fo BIO_free | ||
24 | .Fa "BIO *a" | ||
25 | .Fc | ||
26 | .Ft void | ||
27 | .Fo BIO_vfree | ||
28 | .Fa "BIO *a" | ||
29 | .Fc | ||
30 | .Ft void | ||
31 | .Fo BIO_free_all | ||
32 | .Fa "BIO *a" | ||
33 | .Fc | ||
34 | .Sh DESCRIPTION | ||
35 | The | ||
36 | .Fn BIO_new | ||
37 | function returns a new BIO using method | ||
38 | .Fa type . | ||
39 | .Pp | ||
40 | .Fn BIO_set | ||
41 | sets the method of an already existing BIO. | ||
42 | .Pp | ||
43 | .Fn BIO_free | ||
44 | frees up a single BIO, | ||
45 | .Fn BIO_vfree | ||
46 | also frees up a single BIO, but it does not return a value. | ||
47 | Calling | ||
48 | .Fn BIO_free | ||
49 | may also have some effect on the underlying I/O structure, | ||
50 | for example it may close the file being | ||
51 | referred to under certain circumstances. | ||
52 | For more details see the individual | ||
53 | .Vt BIO_METHOD | ||
54 | descriptions. | ||
55 | .Pp | ||
56 | .Fn BIO_free_all | ||
57 | frees up an entire BIO chain. | ||
58 | It does not halt if an error occurs | ||
59 | freeing up an individual BIO in the chain. | ||
60 | .Sh RETURN VALUES | ||
61 | .Fn BIO_new | ||
62 | returns a newly created BIO or | ||
63 | .Dv NULL | ||
64 | if the call fails. | ||
65 | .Pp | ||
66 | .Fn BIO_set | ||
67 | and | ||
68 | .Fn BIO_free | ||
69 | return 1 for success and 0 for failure. | ||
70 | .Pp | ||
71 | .Fn BIO_free_all | ||
72 | and | ||
73 | .Fn BIO_vfree | ||
74 | do not return values. | ||
75 | .Sh NOTES | ||
76 | Some BIOs (such as memory BIOs) can be used immediately after calling | ||
77 | .Fn BIO_new . | ||
78 | Others (such as file BIOs) need some additional initialization, and | ||
79 | frequently a utility function exists to create and initialize such BIOs. | ||
80 | .Pp | ||
81 | If | ||
82 | .Fn BIO_free | ||
83 | is called on a BIO chain, it will only free one BIO, | ||
84 | resulting in a memory leak. | ||
85 | .Pp | ||
86 | Calling | ||
87 | .Fn BIO_free_all | ||
88 | on a single BIO has the same effect as calling | ||
89 | .Fn BIO_free | ||
90 | on it other than the discarded return value. | ||
91 | .Pp | ||
92 | Normally the | ||
93 | .Fa type | ||
94 | argument is supplied by a function which returns a pointer to a | ||
95 | .Vt BIO_METHOD . | ||
96 | There is a naming convention for such functions: | ||
97 | a source/sink BIO is normally called | ||
98 | .Fn BIO_s_* | ||
99 | and a filter BIO | ||
100 | .Fn BIO_f_* . | ||
101 | .Sh EXAMPLES | ||
102 | Create a memory BIO: | ||
103 | .Pp | ||
104 | .Dl BIO *mem = BIO_new(BIO_s_mem()); | ||
diff --git a/src/lib/libcrypto/man/BIO_new_CMS.3 b/src/lib/libcrypto/man/BIO_new_CMS.3 new file mode 100644 index 0000000000..59c20347e5 --- /dev/null +++ b/src/lib/libcrypto/man/BIO_new_CMS.3 | |||
@@ -0,0 +1,83 @@ | |||
1 | .Dd October 2, 2010 | ||
2 | .Dt BIO_NEW_CMS 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BIO_new_CMS | ||
6 | .Nd CMS streaming filter BIO | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/cms.h | ||
9 | .Ft BIO * | ||
10 | .Fo BIO_new_CMS | ||
11 | .Fa "BIO *out" | ||
12 | .Fa "CMS_ContentInfo *cms" | ||
13 | .Fc | ||
14 | .Sh DESCRIPTION | ||
15 | .Fn BIO_new_CMS | ||
16 | returns a streaming filter BIO chain based on | ||
17 | .Fa cms . | ||
18 | The output of the filter is written to | ||
19 | .Fa out . | ||
20 | Any data written to the chain is automatically translated | ||
21 | to a BER format CMS structure of the appropriate type. | ||
22 | .Sh RETURN VALUES | ||
23 | .Fn BIO_new_CMS | ||
24 | returns a BIO chain when successful or | ||
25 | .Dv NULL | ||
26 | if an error occurred. | ||
27 | The error can be obtained from | ||
28 | .Xr ERR_get_error 3 . | ||
29 | .Sh NOTES | ||
30 | The chain returned by this function behaves like a standard filter BIO. | ||
31 | It supports non blocking I/O. | ||
32 | Content is processed and streamed on the fly and not all held in memory | ||
33 | at once: so it is possible to encode very large structures. | ||
34 | After all content has been written through the chain | ||
35 | .Xr BIO_flush 3 | ||
36 | must be called to finalise the structure. | ||
37 | .Pp | ||
38 | The | ||
39 | .Dv CMS_STREAM | ||
40 | flag must be included in the corresponding | ||
41 | .Fa flags | ||
42 | parameter of the | ||
43 | .Fa cms | ||
44 | creation function. | ||
45 | .Pp | ||
46 | If an application wishes to write additional data to | ||
47 | .Fa out , | ||
48 | BIOs should be removed from the chain using | ||
49 | .Xr BIO_pop 3 | ||
50 | and freed with | ||
51 | .Xr BIO_free 3 | ||
52 | until | ||
53 | .Fa out | ||
54 | is reached. | ||
55 | If no additional data needs to be written, | ||
56 | .Xr BIO_free_all 3 | ||
57 | can be called to free up the whole chain. | ||
58 | .Pp | ||
59 | Any content written through the filter is used verbatim: | ||
60 | no canonical translation is performed. | ||
61 | .Pp | ||
62 | It is possible to chain multiple BIOs to, for example, | ||
63 | create a triple wrapped signed, enveloped, signed structure. | ||
64 | In this case it is the application's responsibility | ||
65 | to set the inner content type of any outer | ||
66 | .Vt CMS_ContentInfo | ||
67 | structures. | ||
68 | .Pp | ||
69 | Large numbers of small writes through the chain should be avoided as this | ||
70 | will produce an output consisting of lots of OCTET STRING structures. | ||
71 | Prepending a | ||
72 | .Xr BIO_f_buffer 3 | ||
73 | buffering BIO will prevent this. | ||
74 | .Sh SEE ALSO | ||
75 | .Xr CMS_encrypt 3 , | ||
76 | .Xr CMS_sign 3 , | ||
77 | .Xr ERR_get_error 3 | ||
78 | .Sh HISTORY | ||
79 | .Fn BIO_new_CMS | ||
80 | was added to OpenSSL 1.0.0. | ||
81 | .Sh BUGS | ||
82 | There is currently no corresponding inverse BIO | ||
83 | which can decode a CMS structure on the fly. | ||
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index 5edbf7e394..fcf9416248 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.16 2015/02/14 13:54:59 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.17 2015/02/14 14:09:01 schwarze Exp $ |
2 | 2 | ||
3 | .include <bsd.own.mk> # for NOMAN | 3 | .include <bsd.own.mk> # for NOMAN |
4 | 4 | ||
@@ -10,9 +10,7 @@ MAN= \ | |||
10 | ASN1_STRING_length.3 \ | 10 | ASN1_STRING_length.3 \ |
11 | ASN1_STRING_new.3 \ | 11 | ASN1_STRING_new.3 \ |
12 | ASN1_STRING_print_ex.3 \ | 12 | ASN1_STRING_print_ex.3 \ |
13 | ASN1_generate_nconf.3 | 13 | ASN1_generate_nconf.3 \ |
14 | |||
15 | GENMAN= \ | ||
16 | BF_set_key.3 \ | 14 | BF_set_key.3 \ |
17 | BIO.3 \ | 15 | BIO.3 \ |
18 | BIO_ctrl.3 \ | 16 | BIO_ctrl.3 \ |
@@ -23,6 +21,8 @@ GENMAN= \ | |||
23 | BIO_f_null.3 \ | 21 | BIO_f_null.3 \ |
24 | BIO_find_type.3 \ | 22 | BIO_find_type.3 \ |
25 | BIO_new.3 \ | 23 | BIO_new.3 \ |
24 | |||
25 | GENMAN= \ | ||
26 | BIO_push.3 \ | 26 | BIO_push.3 \ |
27 | BIO_read.3 \ | 27 | BIO_read.3 \ |
28 | BIO_s_accept.3 \ | 28 | BIO_s_accept.3 \ |