C_SetOperationState

C_SetOperationState restores the cryptographic Operations State of a session from a string of bytes obtained with C_GetOperationState. SafeNet ProtectToolkit-C implements a subset of the full PKCS#11 specification – only the current Message Digest state and object search state may be saved and restored.

hSession is the session’s handle; pOperationState points to the location holding the saved state; ulOperationStateLen holds the length of the saved state; hEncryptionKey and hAuthenticationKey must be zero.

The state need not have been obtained from the same session (the “source session”) as it is being restored to (the “destination session”). However, the source session and destination session should have a common session state (for example, CKS_RW_USER_FUNCTIONS), and should be with a common tokenMessage digest operation states may be carried across logins but not across different Cryptoki implementations.

If C_SetOperationState is supplied with a saved cryptographic Operations State, which it determines is not a valid saved State, it fails with the error CKR_SAVED_STATE_INVALID. Invalid States include cryptographic Operations State from a session with a different session state and cryptographic Operations State from a different token.

C_SetOperationState can successfully restore the message digest Operations State to a session, even if that session has an active message digest or object search operation when C_SetOperationState is called. The ongoing operations are abruptly cancelled.  However if the saved state did not contain an active message digest operation and the current session does, then the C_SetOperationState function will have no effect on the current operation.

Synopsis

C_SetOperationState(
        CK_SESSION_HANDLE hSession,
        CK_BYTE_PTR pOperationState,
        CK_ULONG ulOperationStateLen,
        CK_OBJECT_HANDLE hEncryptionKey,
        CK_OBJECT_HANDLE hAuthenticationKey
); 

Operation in WLD Mode

When SafeNet ProtectToolkit is configured to operate in WLD mode, this function is not supported and will return the error CKR_FUNCTION_NOT_SUPPORTED.