diff options
author | schwarze <> | 2016-11-02 15:23:41 +0000 |
---|---|---|
committer | schwarze <> | 2016-11-02 15:23:41 +0000 |
commit | 878e440382fa65ddbadca1d2784ef1210f0ff652 (patch) | |
tree | d746bbb5cfe6d085f48965873fc3db01fe55f4d6 /src/lib/libcrypto/man/ERR.3 | |
parent | 0f15bae599b571173b77a87f7c4949ff89c55a23 (diff) | |
download | openbsd-878e440382fa65ddbadca1d2784ef1210f0ff652.tar.gz openbsd-878e440382fa65ddbadca1d2784ef1210f0ff652.tar.bz2 openbsd-878e440382fa65ddbadca1d2784ef1210f0ff652.zip |
convert ERR manuals from pod to mdoc; while reading this,
i wtfed, laughed, puked, and cried in more or less that order...
Diffstat (limited to 'src/lib/libcrypto/man/ERR.3')
-rw-r--r-- | src/lib/libcrypto/man/ERR.3 | 297 |
1 files changed, 297 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/ERR.3 b/src/lib/libcrypto/man/ERR.3 new file mode 100644 index 0000000000..2c9a4479f7 --- /dev/null +++ b/src/lib/libcrypto/man/ERR.3 | |||
@@ -0,0 +1,297 @@ | |||
1 | .Dd $Mdocdate: November 2 2016 $ | ||
2 | .Dt ERR 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm ERR | ||
6 | .Nd OpenSSL error codes | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/err.h | ||
9 | .Ft unsigned long | ||
10 | .Fn ERR_get_error void | ||
11 | .Ft unsigned long | ||
12 | .Fn ERR_peek_error void | ||
13 | .Ft unsigned long | ||
14 | .Fo ERR_get_error_line | ||
15 | .Fa "const char **file" | ||
16 | .Fa "int *line" | ||
17 | .Fc | ||
18 | .Ft unsigned long | ||
19 | .Fo ERR_peek_error_line | ||
20 | .Fa "const char **file" | ||
21 | .Fa "int *line" | ||
22 | .Fc | ||
23 | .Ft unsigned long | ||
24 | .Fo ERR_get_error_line_data | ||
25 | .Fa "const char **file" | ||
26 | .Fa "int *line" | ||
27 | .Fa "const char **data" | ||
28 | .Fa "int *flags" | ||
29 | .Fc | ||
30 | .Ft unsigned long | ||
31 | .Fo ERR_peek_error_line_data | ||
32 | .Fa "const char **file" | ||
33 | .Fa "int *line" | ||
34 | .Fa "const char **data" | ||
35 | .Fa "int *flags" | ||
36 | .Fc | ||
37 | .Ft int | ||
38 | .Fo ERR_GET_LIB | ||
39 | .Fa "unsigned long e" | ||
40 | .Fc | ||
41 | .Ft int | ||
42 | .Fo ERR_GET_FUNC | ||
43 | .Fa "unsigned long e" | ||
44 | .Fc | ||
45 | .Ft int | ||
46 | .Fo ERR_GET_REASON | ||
47 | .Fa "unsigned long e" | ||
48 | .Fc | ||
49 | .Ft void | ||
50 | .Fn ERR_clear_error void | ||
51 | .Ft char * | ||
52 | .Fo ERR_error_string | ||
53 | .Fa "unsigned long e" | ||
54 | .Fa "char *buf" | ||
55 | .Fc | ||
56 | .Ft const char * | ||
57 | .Fo ERR_lib_error_string | ||
58 | .Fa "unsigned long e" | ||
59 | .Fc | ||
60 | .Ft const char * | ||
61 | .Fo ERR_func_error_string | ||
62 | .Fa "unsigned long e" | ||
63 | .Fc | ||
64 | .Ft const char * | ||
65 | .Fo ERR_reason_error_string | ||
66 | .Fa "unsigned long e" | ||
67 | .Fc | ||
68 | .Ft void | ||
69 | .Fo ERR_print_errors | ||
70 | .Fa "BIO *bp" | ||
71 | .Fc | ||
72 | .Ft void | ||
73 | .Fo ERR_print_errors_fp | ||
74 | .Fa "FILE *fp" | ||
75 | .Fc | ||
76 | .Ft void | ||
77 | .Fn ERR_load_crypto_strings void | ||
78 | .Ft void | ||
79 | .Fn ERR_free_strings void | ||
80 | .Ft void | ||
81 | .Fo ERR_remove_state | ||
82 | .Fa "unsigned long pid" | ||
83 | .Fc | ||
84 | .Ft void | ||
85 | .Fo ERR_put_error | ||
86 | .Fa "int lib" | ||
87 | .Fa "int func" | ||
88 | .Fa "int reason" | ||
89 | .Fa "const char *file" | ||
90 | .Fa "int line" | ||
91 | .Fc | ||
92 | .Ft void | ||
93 | .Fo ERR_add_error_data | ||
94 | .Fa "int num" | ||
95 | .Fa ... | ||
96 | .Fc | ||
97 | .Ft void | ||
98 | .Fo ERR_load_strings | ||
99 | .Fa "int lib" | ||
100 | .Fa "ERR_STRING_DATA str[]" | ||
101 | .Fc | ||
102 | .Ft unsigned long | ||
103 | .Fo ERR_PACK | ||
104 | .Fa "int lib" | ||
105 | .Fa "int func" | ||
106 | .Fa "int reason" | ||
107 | .Fc | ||
108 | .Ft int | ||
109 | .Fn ERR_get_next_error_library void | ||
110 | .Sh DESCRIPTION | ||
111 | When a call to the OpenSSL library fails, this is usually signalled by | ||
112 | the return value, and an error code is stored in an error queue | ||
113 | associated with the current thread. | ||
114 | The | ||
115 | .Nm | ||
116 | library provides functions to obtain these error codes and textual error | ||
117 | messages. | ||
118 | The | ||
119 | .Xr ERR_get_error 3 | ||
120 | manpage describes how to access error codes. | ||
121 | .Pp | ||
122 | Error codes contain information about where the error occurred, and what | ||
123 | went wrong. | ||
124 | .Xr ERR_GET_LIB 3 | ||
125 | describes how to extract this information. | ||
126 | A method to obtain human-readable error messages is described in | ||
127 | .Xr ERR_error_string 3 . | ||
128 | .Pp | ||
129 | .Xr ERR_clear_error 3 | ||
130 | can be used to clear the error queue. | ||
131 | .Pp | ||
132 | Note that | ||
133 | .Xr ERR_remove_state 3 | ||
134 | should be used to avoid memory leaks when threads are terminated. | ||
135 | .Sh ADDING NEW ERROR CODES TO OPENSSL | ||
136 | See | ||
137 | .Xr ERR_put_error 3 | ||
138 | if you want to record error codes in the OpenSSL error system from | ||
139 | within your application. | ||
140 | .Pp | ||
141 | The remainder of this section is of interest only if you want to add new | ||
142 | error codes to OpenSSL or add error codes from external libraries. | ||
143 | .Ss Reporting errors | ||
144 | Each sub-library has a specific macro | ||
145 | .Fn XXXerr f r | ||
146 | that is used to report errors. | ||
147 | Its first argument is a function code | ||
148 | .Dv XXX_F_* , | ||
149 | the second argument is a reason code | ||
150 | .Dv XXX_R_* . | ||
151 | Function codes are derived from the function names; reason codes consist | ||
152 | of textual error descriptions. | ||
153 | For example, the function | ||
154 | .Fn ssl23_read | ||
155 | reports a "handshake failure" as follows: | ||
156 | .Pp | ||
157 | .Dl SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE); | ||
158 | .Pp | ||
159 | Function and reason codes should consist of upper case characters, | ||
160 | numbers and underscores only. | ||
161 | The error file generation script translates function codes into function | ||
162 | names by looking in the header files for an appropriate function name, | ||
163 | if none is found it just uses the capitalized form such as "SSL23_READ" | ||
164 | in the above example. | ||
165 | .Pp | ||
166 | The trailing section of a reason code (after the "_R_") is translated | ||
167 | into lower case and underscores changed to spaces. | ||
168 | .Pp | ||
169 | When you are using new function or reason codes, run | ||
170 | .Sy make errors . | ||
171 | The necessary | ||
172 | .Sy #define Ns s | ||
173 | will then automatically be added to the sub-library's header file. | ||
174 | .Pp | ||
175 | Although a library will normally report errors using its own specific | ||
176 | .Fn XXXerr | ||
177 | macro, another library's macro can be used. | ||
178 | This is normally only done when a library wants to include ASN1 code | ||
179 | which must use the | ||
180 | .Fn ASN1err | ||
181 | macro. | ||
182 | .Ss Adding new libraries | ||
183 | When adding a new sub-library to OpenSSL, assign it a library number | ||
184 | .Dv ERR_LIB_XXX , | ||
185 | define a macro | ||
186 | .Fn XXXerr | ||
187 | (both in | ||
188 | .In openssl/err.h ) , | ||
189 | add its name to | ||
190 | .Va ERR_str_libraries[] | ||
191 | (in | ||
192 | .Pa /usr/src/lib/libcrypto/err/err.c ) , | ||
193 | and add | ||
194 | .Fn ERR_load_XXX_strings | ||
195 | to the | ||
196 | .Fn ERR_load_crypto_strings | ||
197 | function (in | ||
198 | .Sy /usr/src/lib/libcrypto/err/err_all.c ) . | ||
199 | Finally, add an entry | ||
200 | .Pp | ||
201 | .Dl L XXX xxx.h xxx_err.c | ||
202 | .Pp | ||
203 | to | ||
204 | .Sy /usr/src/lib/libcrypto/err/openssl.ec , | ||
205 | and add | ||
206 | .Pa xxx_err.c | ||
207 | to the | ||
208 | .Pa Makefile . | ||
209 | Running | ||
210 | .Sy make errors | ||
211 | will then generate a file | ||
212 | .Pa xxx_err.c , | ||
213 | and add all error codes used in the library to | ||
214 | .Pa xxx.h . | ||
215 | .Pp | ||
216 | Additionally the library include file must have a certain form. | ||
217 | Typically it will initially look like this: | ||
218 | .Bd -literal -offset indent | ||
219 | #ifndef HEADER_XXX_H | ||
220 | #define HEADER_XXX_H | ||
221 | |||
222 | #ifdef __cplusplus | ||
223 | extern "C" { | ||
224 | #endif | ||
225 | |||
226 | /* Include files */ | ||
227 | |||
228 | #include <openssl/bio.h> | ||
229 | #include <openssl/x509.h> | ||
230 | |||
231 | /* Macros, structures and function prototypes */ | ||
232 | |||
233 | /* BEGIN ERROR CODES */ | ||
234 | .Ed | ||
235 | .Pp | ||
236 | The | ||
237 | .Sy BEGIN ERROR CODES | ||
238 | sequence is used by the error code generation script as the point to | ||
239 | place new error codes, any text after this point will be overwritten | ||
240 | when | ||
241 | .Sy make errors | ||
242 | is run. | ||
243 | The closing #endif etc. will be automatically added by the script. | ||
244 | .Pp | ||
245 | The generated C error code file | ||
246 | .Pa xxx_err.c | ||
247 | will load the header files | ||
248 | .In stdio.h , | ||
249 | .In openssl/err.h | ||
250 | and | ||
251 | .In openssl/xxx.h | ||
252 | so the header file must load any additional header files containing any | ||
253 | definitions it uses. | ||
254 | .Sh USING ERROR CODES IN EXTERNAL LIBRARIES | ||
255 | It is also possible to use OpenSSL's error code scheme in external | ||
256 | libraries. | ||
257 | The library needs to load its own codes and call the OpenSSL error code | ||
258 | insertion script | ||
259 | .Pa mkerr.pl | ||
260 | explicitly to add codes to the header file and generate the C error code | ||
261 | file. | ||
262 | This will normally be done if the external library needs to generate new | ||
263 | ASN1 structures but it can also be used to add more general purpose | ||
264 | error code handling. | ||
265 | .Sh INTERNALS | ||
266 | The error queues are stored in a hash table with one | ||
267 | .Vt ERR_STATE | ||
268 | entry for each pid. | ||
269 | .Fn ERR_get_state | ||
270 | returns the current thread's | ||
271 | .Vt ERR_STATE . | ||
272 | An | ||
273 | .Vt ERR_STATE | ||
274 | can hold up to | ||
275 | .Dv ERR_NUM_ERRORS | ||
276 | error codes. | ||
277 | When more error codes are added, the old ones are overwritten, on the | ||
278 | assumption that the most recent errors are most important. | ||
279 | .Pp | ||
280 | Error strings are also stored in hash table. | ||
281 | The hash tables can be obtained by calling | ||
282 | .Fn ERR_get_err_state_table | ||
283 | and | ||
284 | .Fn ERR_get_string_table . | ||
285 | .Sh SEE ALSO | ||
286 | .Xr CRYPTO_set_id_callback 3 , | ||
287 | .Xr CRYPTO_set_locking_callback 3 , | ||
288 | .Xr ERR_clear_error 3 , | ||
289 | .Xr ERR_error_string 3 , | ||
290 | .Xr ERR_get_error 3 , | ||
291 | .Xr ERR_GET_LIB 3 , | ||
292 | .Xr ERR_load_crypto_strings 3 , | ||
293 | .Xr ERR_load_strings 3 , | ||
294 | .Xr ERR_print_errors 3 , | ||
295 | .Xr ERR_put_error 3 , | ||
296 | .Xr ERR_remove_state 3 , | ||
297 | .Xr SSL_get_error 3 | ||