1 .\" $OpenBSD: RSA_get_ex_new_index.3,v 1.7 2017/08/01 14:57:03 schwarze Exp $
2 .\" OpenSSL 35cb565a Nov 19 15:49:30 2015 -0500
4 .\" This file was written by Ulf Moeller <ulf@openssl.org> and
5 .\" Dr. Stephen Henson <steve@openssl.org>.
6 .\" Copyright (c) 2000, 2006 The OpenSSL Project. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: August 1 2017 $
53 .Dt RSA_GET_EX_NEW_INDEX 3
56 .Nm RSA_get_ex_new_index ,
62 .Nd add application specific data to RSA structures
66 .Fo RSA_get_ex_new_index
69 .Fa "CRYPTO_EX_new *new_func"
70 .Fa "CRYPTO_EX_dup *dup_func"
71 .Fa "CRYPTO_EX_free *free_func"
88 .Fa "CRYPTO_EX_DATA *ad"
97 .Fa "CRYPTO_EX_DATA *ad"
104 .Fa "CRYPTO_EX_DATA *to"
105 .Fa "CRYPTO_EX_DATA *from"
112 Several OpenSSL structures can have application specific data attached
114 This has several potential uses: it can be used to cache data associated
115 with a structure (for example the hash of some part of the structure) or
116 some additional data (for example a handle to the data in an external
119 Since the application data can be anything at all it is passed and
125 .Fn RSA_get_ex_new_index
126 function is initially called to "register" some new application specific
128 It takes three optional function pointers which are called when the
129 parent structure (in this case an RSA structure) is initially created,
130 when it is copied and when it is freed up.
131 If any or all of these function pointer arguments are not used, they
134 The precise manner in which these function pointers are called is
135 described in more detail below.
136 .Fn RSA_get_ex_new_index
137 also takes additional long and pointer parameters which will be passed
138 to the supplied functions but which otherwise have no special meaning.
139 It returns an index which should be stored (typically in a static
140 variable) and passed as the
142 parameter in the remaining functions.
143 Each successful call to
144 .Fn RSA_get_ex_new_index
145 will return an index greater than any previously returned.
147 important because the optional functions are called in order of
148 increasing index value.
151 is used to set application specific data.
152 The data is supplied in the
154 parameter and its precise meaning is up to the application.
157 is used to retrieve application specific data.
158 The data is returned to the application, which will be the same value as
159 supplied to a previous
164 is called when a structure is initially allocated (for example with
166 The parent structure members will not have any meaningful values at this
168 This function will typically be used to allocate any application
172 is called when a structure is being freed up.
173 The dynamic parent structure members should not be accessed because they
174 will be freed up when this function is called.
179 take the same parameters.
181 is a pointer to the parent
185 is the application specific data (this won't be of much use in
190 structure from the parent
192 structure: the functions
193 .Fn CRYPTO_get_ex_data
195 .Fn CRYPTO_set_ex_data
196 can be called to manipulate it.
199 parameter is the index: this will be the same value returned by
200 .Fn RSA_get_ex_new_index
201 when the functions were initially registered.
206 parameters are the values originally passed to the same corresponding
208 .Fn RSA_get_ex_new_index
212 is called when a structure is being copied.
213 Pointers to the destination and source
215 structures are passed in the
219 parameters, respectively.
222 parameter is passed a pointer to the source application data when the
224 When the function returns, the value is copied to the destination:
225 the application can thus modify the data pointed to by
227 and have different values in the source and destination.
233 parameters are the same as those in
238 .Fn RSA_get_ex_new_index
239 returns a new index or -1 on failure.
240 Note that 0 is a valid index value.
243 returns 1 on success or 0 on failure.
246 returns the application data or
250 may also be valid application data, but currently it can only fail if
258 should return 0 for failure and 1 for success.
260 On failure an error code can be obtained from
261 .Xr ERR_get_error 3 .
263 .Xr BIO_set_ex_data 3 ,
264 .Xr CRYPTO_set_ex_data 3 ,
265 .Xr DH_set_ex_data 3 ,
266 .Xr DSA_set_ex_data 3 ,
268 .Xr X509_STORE_CTX_set_ex_data 3
270 .Fn RSA_get_ex_new_index ,
271 .Fn RSA_set_ex_data ,
274 are available since SSLeay 0.9.0.
277 is currently never called.
285 function isn't very useful because no meaningful values are present in
286 the parent RSA structure when it is called.