NAME
RSAgetexnewindex, RSAsetexdata, RSAgetexdata - add
application specific data to RSA structuresSYNOPSIS
#include
int RSAgetexnewindex(long argl, void *argp, CRYPTOEXnew *newfunc, CRYPTOEXdup *dupfunc, CRYPTOEXfree *freefunc); int RSAsetexdata(RSA *r, int idx, void *arg); void *RSAgetexdata(RSA *r, int idx); typedef int newfunc(void *parent, void *ptr, CRYPTOEXDATA *ad, int idx, long argl, void *argp); typedef void freefunc(void *parent, void *ptr, CRYPTOEXDATA *ad, int idx, long argl, void *argp); typedef int dupfunc(CRYPTOEXDATA *to, CRYPTOEXDATA *from, void *fromd, 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 vvooiidd ** type. The RRSSAAggeetteexxnneewwiinnddeexx(()) 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. RRSSAAggeetteexxnneewwiinnddeexx(()) also takes additional long and pointer parameters which will be passed to the supplied functions but which otherwise have no special meaning. It returns an iinnddeexx which should be stored (typically in a static variable) and passed used in the iiddxx parameter in the remaining functions. Each successful call to RRSSAAggeetteexxnneewwiinnddeexx(()) will return an index greater than any previously returned, this is important because the optional functions are called in order of increasing index value. RRSSAAsseetteexxddaattaa(()) is used to set application specific data, the data is supplied in the aarrgg parameter and its precise meaning is up to the application. RRSSAAggeetteexxddaattaa(()) 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 RRSSAAsseetteexxddaattaa(()) call. nneewwffuunncc(()) is called when a structure is initially allocated (for example with RRSSAAnneeww(()). 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. ffrreeeeffuunncc(()) 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. nneewwffuunncc(()) and ffrreeeeffuunncc(()) take the same parameters. ppaarreenntt is a pointer to the parent RSA structure. ppttrr is a the application specific data (this wont be of much use in nneewwffuunncc(()). aadd is a pointer to the CCRRYYPPTTOOEEXXDDAATTAA structure from the parent RSA structure: the functions CCRRYYPPTTOOggeetteexxddaattaa(()) and CCRRYYPPTTOOsseetteexxddaattaa(()) can be called to manipulate it. The iiddxx parameter is the index: this will be the same value returned by RRSSAAggeetteexxnneewwiinnddeexx(()) when the functions were initially registered. Finally the aarrggll and aarrggpp parameters are the values originally passed to the same corresponding parameters when RRSSAAggeetteexxnneewwiinnddeexx(()) was called. dduuppffuunncc(()) is called when a structure is being copied. Pointers to the destination and source CCRRYYPPTTOOEEXXDDAATTAA structures are passed in the ttoo and ffrroomm parameters respectively. The ffrroommdd 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 ffrroommdd and have different values in the source and destination. The iiddxx, aarrggll and aarrggpp parameters are the same as those in nneewwffuunncc(()) and ffrreeeeffuunncc(()).RETURN VALUES
RRSSAAggeetteexxnneewwiinnddeexx(()) returns a new index or -1 on failure (note 0 is
a valid index value). RRSSAAsseetteexxddaattaa(()) returns 1 on success or 0 on failure. RRSSAAggeetteexxddaattaa(()) 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 iiddxx parameter. nneewwffuunncc(()) and dduuppffuunncc(()) should return 0 for failure and 1 for success. On failure an error code can be obtained from ERRgeterror(3).BUGS
dduuppffuunncc(()) is currently never called. The return value of nneewwffuunncc(()) is ignored. The nneewwffuunncc(()) function isn't very useful because no meaningful values are present in the parent RSA structure when it is called.SEE ALSO
rsa(3), CRYPTOsetexdata(3) HISTORY RSAgetexnewindex(), RSAsetexdata() and RSAgetexdata() are available since SSLeay 0.9.0.0.9.7l 2000-09-14 RSAgetexnewindex(3)