summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/man/CRYPTO_set_ex_data.3316
1 files changed, 295 insertions, 21 deletions
diff --git a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
index 86cbadc46b..7cf8f6377c 100644
--- a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
+++ b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3
@@ -1,5 +1,5 @@
1.\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.4 2016/11/23 16:28:23 schwarze Exp $ 1.\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.5 2016/11/28 22:25:51 schwarze Exp $
2.\" OpenSSL 35cb565a Nov 19 15:49:30 2015 -0500 2.\" OpenSSL CRYPTO_get_ex_new_index.pod 35cb565a Nov 19 15:49:30 2015 -0500
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000, 2006 The OpenSSL Project. All rights reserved. 5.\" Copyright (c) 2000, 2006 The OpenSSL Project. All rights reserved.
@@ -47,17 +47,115 @@
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" OpenSSL
50.\" 51.\"
51.Dd $Mdocdate: November 23 2016 $ 52.\" This file was written by Dr. Stephen Henson <steve@openssl.org>
53.\" and by Rich Salz <rsalz@akamai.com>.
54.\" Copyright (c) 2000, 2006, 2015, 2016 The OpenSSL Project.
55.\" All rights reserved.
56.\"
57.\" Redistribution and use in source and binary forms, with or without
58.\" modification, are permitted provided that the following conditions
59.\" are met:
60.\"
61.\" 1. Redistributions of source code must retain the above copyright
62.\" notice, this list of conditions and the following disclaimer.
63.\"
64.\" 2. Redistributions in binary form must reproduce the above copyright
65.\" notice, this list of conditions and the following disclaimer in
66.\" the documentation and/or other materials provided with the
67.\" distribution.
68.\"
69.\" 3. All advertising materials mentioning features or use of this
70.\" software must display the following acknowledgment:
71.\" "This product includes software developed by the OpenSSL Project
72.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
73.\"
74.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
75.\" endorse or promote products derived from this software without
76.\" prior written permission. For written permission, please contact
77.\" openssl-core@openssl.org.
78.\"
79.\" 5. Products derived from this software may not be called "OpenSSL"
80.\" nor may "OpenSSL" appear in their names without prior written
81.\" permission of the OpenSSL Project.
82.\"
83.\" 6. Redistributions of any form whatsoever must retain the following
84.\" acknowledgment:
85.\" "This product includes software developed by the OpenSSL Project
86.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
87.\"
88.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
89.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
90.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
91.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
92.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
93.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
94.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
95.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
97.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
98.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
99.\" OF THE POSSIBILITY OF SUCH DAMAGE.
100.\"
101.Dd $Mdocdate: November 28 2016 $
52.Dt CRYPTO_SET_EX_DATA 3 102.Dt CRYPTO_SET_EX_DATA 3
53.Os 103.Os
54.Sh NAME 104.Sh NAME
105.Nm CRYPTO_EX_new ,
106.Nm CRYPTO_EX_free ,
107.Nm CRYPTO_EX_dup ,
108.Nm CRYPTO_get_ex_new_index ,
55.Nm CRYPTO_set_ex_data , 109.Nm CRYPTO_set_ex_data ,
56.Nm CRYPTO_get_ex_data 110.Nm CRYPTO_get_ex_data ,
57.Nd internal application specific data functions 111.Nm CRYPTO_free_ex_data ,
112.Nm CRYPTO_new_ex_data
113.Nd functions supporting application-specific data
58.Sh SYNOPSIS 114.Sh SYNOPSIS
59.In openssl/crypto.h 115.In openssl/crypto.h
60.Ft int 116.Ft int
117.Fo CRYPTO_get_ex_new_index
118.Fa "int class_index"
119.Fa "long argl"
120.Fa "void *argp"
121.Fa "CRYPTO_EX_new *new_func"
122.Fa "CRYPTO_EX_dup *dup_func"
123.Fa "CRYPTO_EX_free *free_func"
124.Fc
125.Ft typedef int
126.Fo CRYPTO_EX_new
127.Fa "void *parent"
128.Fa "void *ptr"
129.Fa "CRYPTO_EX_DATA *ad"
130.Fa "int idx"
131.Fa "long argl"
132.Fa "void *argp"
133.Fc
134.Ft typedef void
135.Fo CRYPTO_EX_free
136.Fa "void *parent"
137.Fa "void *ptr"
138.Fa "CRYPTO_EX_DATA *ad"
139.Fa "int idx"
140.Fa "long argl"
141.Fa "void *argp"
142.Fc
143.Ft typedef int
144.Fo CRYPTO_EX_dup
145.Fa "CRYPTO_EX_DATA *to"
146.Fa "const CRYPTO_EX_DATA *from"
147.Fa "void *from_d"
148.Fa "int idx"
149.Fa "long argl"
150.Fa "void *argp"
151.Fc
152.Ft int
153.Fo CRYPTO_new_ex_data
154.Fa "int class_index"
155.Fa "void *obj"
156.Fa "CRYPTO_EX_DATA *ad"
157.Fc
158.Ft int
61.Fo CRYPTO_set_ex_data 159.Fo CRYPTO_set_ex_data
62.Fa "CRYPTO_EX_DATA *r" 160.Fa "CRYPTO_EX_DATA *r"
63.Fa "int idx" 161.Fa "int idx"
@@ -68,22 +166,191 @@
68.Fa "CRYPTO_EX_DATA *r" 166.Fa "CRYPTO_EX_DATA *r"
69.Fa "int idx" 167.Fa "int idx"
70.Fc 168.Fc
169.Ft void
170.Fo CRYPTO_free_ex_data
171.Fa "int class_index"
172.Fa "void *obj"
173.Fa "CRYPTO_EX_DATA *r"
174.Fc
71.Sh DESCRIPTION 175.Sh DESCRIPTION
72Several OpenSSL structures can have application specific data attached 176Several OpenSSL structures can have application specific data attached
73to them. 177to them, known as "exdata."
74These functions are used internally by OpenSSL to manipulate application 178The specific structures are:
75specific data attached to a specific structure. 179.Bd -literal
180 SSL
181 SSL_CTX
182 SSL_SESSION
183 X509
184 X509_STORE
185 X509_STORE_CTX
186 DH
187 DSA
188 RSA
189 ENGINE
190 UI
191 BIO
192.Ed
76.Pp 193.Pp
77These functions should only be used by applications to manipulate 194Each is identified by a
195.Dv CRYPTO_EX_INDEX_*
196constant defined in the
197.In openssl/crypto.h
198header file.
199.Pp
200The API described here is used by OpenSSL to manipulate exdata for
201specific structures.
202Since the application data can be anything at all it is passed and
203retrieved as a
204.Vt void *
205type.
206.Pp
207The
78.Vt CRYPTO_EX_DATA 208.Vt CRYPTO_EX_DATA
79structures passed to the 209type is opaque.
80.Fn new_func , 210To initialize the exdata part of a structure, call
81.Fn free_func , 211.Fn CRYPTO_new_ex_data .
212.Pp
213Exdata types are identified by an index, an integer guaranteed to
214be unique within structures for the lifetime of the program.
215Applications using exdata typically call
216.Fn CRYPTO_get_ex_new_index
217at startup and store the result in a global variable, or write a
218wrapper function to provide lazy evaluation.
219The
220.Fa class_index
221should be one of the
222.Dv CRYPTO_EX_INDEX_*
223values.
224The
225.Fa argl
82and 226and
83.Fn dup_func 227.Fa argp
84callbacks, as passed to 228parameters are saved to be passed to the callbacks but are otherwise not
85.Xr RSA_get_ex_new_index 3 , 229used.
86for example. 230In order to transparently manipulate exdata, three callbacks must be
231provided.
232The semantics of those callbacks are described below.
233.Pp
234When copying or releasing objects with exdata, the callback functions
235are called in increasing order of their index value.
236.Pp
237To set or get the exdata on an object, the appropriate type-specific
238routine must be used.
239This is because the containing structure is opaque and the
240.Vt CRYPTO_EX_DATA
241field is not accessible.
242In both APIs, the
243.Fa idx
244parameter should be an already-created index value.
245.Pp
246When setting exdata, the pointer specified with a particular index is
247saved, and returned on a subsequent "get" call.
248If the application is going to release the data, it must make sure to
249set a
250.Dv NULL
251value at the index, to avoid likely double-free crashes.
252.Pp
253The function
254.Fn CRYPTO_free_ex_data
255is used to free all exdata attached to a structure.
256The appropriate type-specific routine must be used.
257The
258.Fa class_index
259identifies the structure type, the
260.Fa obj
261is be the pointer to the actual structure, and
262.Fa r
263is a pointer to the structure's exdata field.
264.Pp
265The callback functions are used as follows.
266.Pp
267When a structure is initially allocated (such as by
268.Xr RSA_new 3 ) ,
269then
270.Fa new_func
271is called for every defined index.
272There is no requirement that the entire parent, or containing, structure
273has been set up.
274The
275.Fa new_func
276is typically used only to allocate memory to store the
277exdata, and perhaps an "initialized" flag within that memory.
278The exdata value should be set by calling
279.Fn CRYPTO_set_ex_data .
280.Pp
281When a structure is free'd (such as by
282.Xr SSL_CTX_free 3 ) ,
283then the
284.Fa free_func
285is called for every defined index.
286Again, the state of the parent structure is not guaranteed.
287The
288.Fa free_func
289may be called with a
290.Dv NULL
291pointer.
292.Pp
293Both
294.Fa new_func
295and
296.Fa free_func
297take the same parameters.
298The
299.Fa parent
300is the pointer to the structure that contains the exdata.
301The
302.Fa ptr
303is the current exdata item; for
304.Fa new_func
305this will typically be
306.Dv NULL .
307The
308.Fa r
309parameter is a pointer to the exdata field of the object.
310The
311.Fa idx
312is the index and is the value returned when the callbacks were initially
313registered via
314.Fn CRYPTO_get_ex_new_index
315and can be used if the same callback handles different types of exdata.
316.Pp
317.Fa dup_func
318is called when a structure is being copied.
319This is only done for
320.Vt SSL
321and
322.Vt SSL_SESSION
323objects.
324The
325.Fa to
326and
327.Fa from
328parameters are pointers to the destination and source
329.Vt CRYPTO_EX_DATA
330structures, respectively.
331The
332.Fa from_d
333parameter is a pointer to the source exdata.
334When
335.Fa dup_func
336returns, the value in
337.Fa from_d
338is copied to the destination ex_data.
339If the pointer contained in
340.Fa from_d
341is not modified by the
342.Fa dup_func ,
343then both
344.Fa to
345and
346.Fa from
347will point to the same data.
348The
349.Fa idx ,
350.Fa argl
351and
352.Fa argp
353parameters are as described for the other two callbacks.
87.Pp 354.Pp
88.Fn CRYPTO_set_ex_data 355.Fn CRYPTO_set_ex_data
89is used to set application specific data. 356is used to set application specific data.
@@ -98,15 +365,22 @@ supplied to a previous
98.Fn CRYPTO_set_ex_data 365.Fn CRYPTO_set_ex_data
99call. 366call.
100.Sh RETURN VALUES 367.Sh RETURN VALUES
368.Fn CRYPTO_get_ex_new_index
369returns a new index or -1 on failure; the value 0 is reserved for
370the legacy "app_data" APIs.
371.Pp
101.Fn CRYPTO_set_ex_data 372.Fn CRYPTO_set_ex_data
102returns 1 on success or 0 on failure. 373returns 1 on success or 0 on failure.
103.Pp 374.Pp
104.Fn CRYPTO_get_ex_data 375.Fn CRYPTO_get_ex_data
105returns the application data or 0 on failure. 376returns the application data or
1060 may also be valid application data but currently it can only fail if 377.Dv NULL
107given an invalid 378on failure; note that
108.Fa idx 379.Dv NULL
109parameter. 380may be a valid value.
381.Pp
382.Fa dup_func
383should return 0 for failure and 1 for success.
110.Pp 384.Pp
111On failure an error code can be obtained from 385On failure an error code can be obtained from
112.Xr ERR_get_error 3 . 386.Xr ERR_get_error 3 .