summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/ERR.3
diff options
context:
space:
mode:
authorschwarze <>2016-11-02 15:23:41 +0000
committerschwarze <>2016-11-02 15:23:41 +0000
commit878e440382fa65ddbadca1d2784ef1210f0ff652 (patch)
treed746bbb5cfe6d085f48965873fc3db01fe55f4d6 /src/lib/libcrypto/man/ERR.3
parent0f15bae599b571173b77a87f7c4949ff89c55a23 (diff)
downloadopenbsd-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.3297
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
111When a call to the OpenSSL library fails, this is usually signalled by
112the return value, and an error code is stored in an error queue
113associated with the current thread.
114The
115.Nm
116library provides functions to obtain these error codes and textual error
117messages.
118The
119.Xr ERR_get_error 3
120manpage describes how to access error codes.
121.Pp
122Error codes contain information about where the error occurred, and what
123went wrong.
124.Xr ERR_GET_LIB 3
125describes how to extract this information.
126A method to obtain human-readable error messages is described in
127.Xr ERR_error_string 3 .
128.Pp
129.Xr ERR_clear_error 3
130can be used to clear the error queue.
131.Pp
132Note that
133.Xr ERR_remove_state 3
134should be used to avoid memory leaks when threads are terminated.
135.Sh ADDING NEW ERROR CODES TO OPENSSL
136See
137.Xr ERR_put_error 3
138if you want to record error codes in the OpenSSL error system from
139within your application.
140.Pp
141The remainder of this section is of interest only if you want to add new
142error codes to OpenSSL or add error codes from external libraries.
143.Ss Reporting errors
144Each sub-library has a specific macro
145.Fn XXXerr f r
146that is used to report errors.
147Its first argument is a function code
148.Dv XXX_F_* ,
149the second argument is a reason code
150.Dv XXX_R_* .
151Function codes are derived from the function names; reason codes consist
152of textual error descriptions.
153For example, the function
154.Fn ssl23_read
155reports a "handshake failure" as follows:
156.Pp
157.Dl SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE);
158.Pp
159Function and reason codes should consist of upper case characters,
160numbers and underscores only.
161The error file generation script translates function codes into function
162names by looking in the header files for an appropriate function name,
163if none is found it just uses the capitalized form such as "SSL23_READ"
164in the above example.
165.Pp
166The trailing section of a reason code (after the "_R_") is translated
167into lower case and underscores changed to spaces.
168.Pp
169When you are using new function or reason codes, run
170.Sy make errors .
171The necessary
172.Sy #define Ns s
173will then automatically be added to the sub-library's header file.
174.Pp
175Although a library will normally report errors using its own specific
176.Fn XXXerr
177macro, another library's macro can be used.
178This is normally only done when a library wants to include ASN1 code
179which must use the
180.Fn ASN1err
181macro.
182.Ss Adding new libraries
183When adding a new sub-library to OpenSSL, assign it a library number
184.Dv ERR_LIB_XXX ,
185define a macro
186.Fn XXXerr
187(both in
188.In openssl/err.h ) ,
189add its name to
190.Va ERR_str_libraries[]
191(in
192.Pa /usr/src/lib/libcrypto/err/err.c ) ,
193and add
194.Fn ERR_load_XXX_strings
195to the
196.Fn ERR_load_crypto_strings
197function (in
198.Sy /usr/src/lib/libcrypto/err/err_all.c ) .
199Finally, add an entry
200.Pp
201.Dl L XXX xxx.h xxx_err.c
202.Pp
203to
204.Sy /usr/src/lib/libcrypto/err/openssl.ec ,
205and add
206.Pa xxx_err.c
207to the
208.Pa Makefile .
209Running
210.Sy make errors
211will then generate a file
212.Pa xxx_err.c ,
213and add all error codes used in the library to
214.Pa xxx.h .
215.Pp
216Additionally the library include file must have a certain form.
217Typically 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
223extern "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
236The
237.Sy BEGIN ERROR CODES
238sequence is used by the error code generation script as the point to
239place new error codes, any text after this point will be overwritten
240when
241.Sy make errors
242is run.
243The closing #endif etc. will be automatically added by the script.
244.Pp
245The generated C error code file
246.Pa xxx_err.c
247will load the header files
248.In stdio.h ,
249.In openssl/err.h
250and
251.In openssl/xxx.h
252so the header file must load any additional header files containing any
253definitions it uses.
254.Sh USING ERROR CODES IN EXTERNAL LIBRARIES
255It is also possible to use OpenSSL's error code scheme in external
256libraries.
257The library needs to load its own codes and call the OpenSSL error code
258insertion script
259.Pa mkerr.pl
260explicitly to add codes to the header file and generate the C error code
261file.
262This will normally be done if the external library needs to generate new
263ASN1 structures but it can also be used to add more general purpose
264error code handling.
265.Sh INTERNALS
266The error queues are stored in a hash table with one
267.Vt ERR_STATE
268entry for each pid.
269.Fn ERR_get_state
270returns the current thread's
271.Vt ERR_STATE .
272An
273.Vt ERR_STATE
274can hold up to
275.Dv ERR_NUM_ERRORS
276error codes.
277When more error codes are added, the old ones are overwritten, on the
278assumption that the most recent errors are most important.
279.Pp
280Error strings are also stored in hash table.
281The hash tables can be obtained by calling
282.Fn ERR_get_err_state_table
283and
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