/usr/man2/cat.3/RSA_set_ex_data.3.Z(/usr/man2/cat.3/RSA_set_ex_data.3.Z)
NAME
RSA_get_ex_new_index, RSA_set_ex_data, RSA_get_ex_data - add applica-
tion specific data to RSA structures
SYNOPSIS
#include <openssl/rsa.h>
int RSA_get_ex_new_index(long argl, void *argp,
CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func);
int RSA_set_ex_data(RSA *r, int idx, void *arg);
void *RSA_get_ex_data(RSA *r, int idx);
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
int idx, long argl, void *argp);
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
int idx, long argl, void *argp);
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
int idx, long argl, void *argp);
DESCRIPTION
Several OpenSSL structures can have application specific data attached
to them. This has several potential uses, it can be used to cache data
associated with a structure (for example the hash of some part of the
structure) or some additional data (for example a handle to the data in
an external library).
Since the application data can be anything at all it is passed and
retrieved as a void * type.
The RRSSAA_ggeett_eexx_nneeww_iinnddeexx(()) function is initially called to "register"
some new application specific data. It takes three optional function
pointers which are called when the parent structure (in this case an
RSA structure) is initially created, when it is copied and when it is
freed up. If any or all of these function pointer arguments are not
used they should be set to NULL. The precise manner in which these
function pointers are called is described in more detail below.
RRSSAA_ggeett_eexx_nneeww_iinnddeexx(()) also takes additional long and pointer parame-
ters which will be passed to the supplied functions but which otherwise
have no special meaning. It returns an index which should be stored
(typically in a static variable) and passed used in the idx parameter
in the remaining functions. Each successful call to
RRSSAA_ggeett_eexx_nneeww_iinnddeexx(()) will return an index greater than any previously
returned, this is important because the optional functions are called
in order of increasing index value.
RRSSAA_sseett_eexx_ddaattaa(()) is used to set application specific data, the data is
supplied in the arg parameter and its precise meaning is up to the
application.
RRSSAA_ggeett_eexx_ddaattaa(()) is used to retrieve application specific data. The
data is returned to the application, this will be the same value as
supplied to a previous RRSSAA_sseett_eexx_ddaattaa(()) call.
nneeww_ffuunncc(()) is called when a structure is initially allocated (for exam-
ple with RRSSAA_nneeww(()). The parent structure members will not have any
meaningful values at this point. This function will typically be used
to allocate any application specific structure.
ffrreeee_ffuunncc(()) is called when a structure is being freed up. The dynamic
parent structure members should not be accessed because they will be
freed up when this function is called.
nneeww_ffuunncc(()) and ffrreeee_ffuunncc(()) take the same parameters. parent is a
pointer to the parent RSA structure. ptr is a the application specific
data (this wont be of much use in nneeww_ffuunncc(()). ad is a pointer to the
CRYPTO_EX_DATA structure from the parent RSA structure: the functions
CCRRYYPPTTOO_ggeett_eexx_ddaattaa(()) and CCRRYYPPTTOO_sseett_eexx_ddaattaa(()) can be called to manipu-
late it. The idx parameter is the index: this will be the same value
returned by RRSSAA_ggeett_eexx_nneeww_iinnddeexx(()) when the functions were initially
registered. Finally the argl and argp parameters are the values origi-
nally passed to the same corresponding parameters when
RRSSAA_ggeett_eexx_nneeww_iinnddeexx(()) was called.
dduupp_ffuunncc(()) is called when a structure is being copied. Pointers to the
destination and source CRYPTO_EX_DATA structures are passed in the to
and from parameters respectively. The from_d parameter is passed a
pointer to the source application data when the function is called,
when the function returns the value is copied to the destination: the
application can thus modify the data pointed to by from_d and have dif-
ferent values in the source and destination. The idx, argl and argp
parameters are the same as those in nneeww_ffuunncc(()) and ffrreeee_ffuunncc(()).
RETURN VALUES
RRSSAA_ggeett_eexx_nneeww_iinnddeexx(()) returns a new index or -1 on failure (note 0 is
a valid index value).
RRSSAA_sseett_eexx_ddaattaa(()) returns 1 on success or 0 on failure.
RRSSAA_ggeett_eexx_ddaattaa(()) returns the application data or 0 on failure. 0 may
also be valid application data but currently it can only fail if given
an invalid idx parameter.
nneeww_ffuunncc(()) and dduupp_ffuunncc(()) should return 0 for failure and 1 for suc-
cess.
On failure an error code can be obtained from ERR_get_error(3).
BUGS
dduupp_ffuunncc(()) is currently never called.
The return value of nneeww_ffuunncc(()) is ignored.
The nneeww_ffuunncc(()) function isn't very useful because no meaningful values
are present in the parent RSA structure when it is called.
SEE ALSO
rsa(3), CRYPTO_set_ex_data(3)
HISTORY
RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data() are
available since SSLeay 0.9.0.
1.0.2t 2019-09-10 RSA_get_ex_new_index(3)
See also RSA_get_ex_data(3)
See also RSA_get_ex_new_index(3)
Man(1) output converted with
man2html