FM_SetSessionUserData

This function can be used to associate 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() cal), 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));
Parameter Description
fmNo The fm number of the caller. It must be 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 this 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. It must be non-NULL if userData is not NULL.

Return Code

CKR_OK: The operation was successful.

CKR_ARGUMENTS_BAD: freeUserData 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.