FM_SetTokenUserData

This function can be used to associate user data with a token. The data is associated with the token in slotId by the library. The function specified in this call will be called to free the data when the last application using the library finalizes, or when the token is removed from that slot.

If the token already has associated 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_SetTokenUserData(FmNumber_t fmNo,
CK_SLOTID slotId,
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.
slotId The slot ID of the slot containing the token.
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_SLOT_ID_INVALID: The specified slot ID is invalid.

CKR_TOKEN_NOT_PRESENT: The specified slot does not contain a token.

CKR_CRYPTOKI_NOT_INITIALIZED: Cryptoki is not yet initialized.