FM_SetSessionUserData
Associates user data with a session handle. The data is associated with the (PID, hSession) pair by the library. The function specified in this call will be called to free the user data if the session is closed (via a C_CloseSession() or a C_CloseAllSessions() call), or the application owning the session finalizes.
If the session handle already contains user data it will be freed, by calling the current free function, before the new data association is created.
Synopsis
#include <objstate.h> CK_RV FM_SetSessionUserData(FmNumber_t fmNo,
CK_SESSION_HANDLE hSession,
CK_VOID_PTR userData,
CK_VOID (*freeUserData)(CK_VOID_PTR));
Parameters
fmNo | The FM number of the caller. It must be the FM_NUMBER_CUSTOM_FM in this release of the software. |
hSession | A session handle, which was obtained from an C_OpenSession () call. The validity of the parameter is checked. |
userData | Address of the memory block that will be associated with the session handle. If it is NULL, the current associated buffer is freed. |
freeUserData | Address of a function that will be called to free the userData if the library decides that it should be freed. Value must not be NULL if userData is not NULL |
Return Code
The function returns the following codes:
Function Code | Qualification |
---|---|
CKR_OK | The operation was successful |
CKR_ARGUMENTS_BAD | Free user date was NULL or fmNo was not FM_NUMBER_CUSTOM_FM |
CKR_SESSION_HANDLE_INVALID | The specified session handle is invalid |
CKR_CRYPTOKI_NOT_INITIALIZED | Cryptoki is not yet initialized |