Cryptoki: a cryptographic Token Interface


Cryptoki function return values for functions that use a session handle



Download 360.55 Kb.
Page74/196
Date22.12.2023
Size360.55 Kb.
#63026
1   ...   70   71   72   73   74   75   76   77   ...   196
v201-95
pkcs11-base-v2.40-cos01

10.1.2. Cryptoki function return values for functions that use a session handle


Any Cryptoki function that takes a session handle as one of its arguments (i.e., any Cryptoki function except for C_Initialize, C_Finalize, C_GetInfo, C_GetFunctionList, C_GetSlotList, C_GetSlotInfo, C_GetTokenInfo, C_WaitForSlotEvent, C_GetMechanismList, C_GetMechanismInfo, C_InitToken, C_OpenSession, and C_CloseAllSessions) can return the following values:

  • CKR_SESSION_HANDLE_INVALID: The specified session handle was invalid at the time that the function was invoked. Note that this can happen if the session’s token is removed before the function invocation, since removing a token closes all sessions with it.

  • CKR_DEVICE_REMOVED: The token was removed from its slot during the execution of the function.

  • CKR_SESSION_CLOSED: The session was closed during the execution of the function. Note that, as stated in Section , the behavior of Cryptoki is undefined if multiple threads of an application attempt to access a common Cryptoki session simultaneously. Therefore, there is actually no guarantee that a function invocation could ever return the value CKR_SESSION_CLOSED—if one thread is using a session when another thread closes that session, that is an instance of multiple threads accessing a common session simultaneously.

The relative priorities of these errors are in the order listed above, e.g., if either of CKR_SESSION_HANDLE_INVALID or CKR_DEVICE_REMOVED would be an appropriate error return, then CKR_SESSION_HANDLE_INVALID should be returned.
In practice, it is often not crucial (or possible) for a Cryptoki library to be able to make a distinction between a token being removed before a function invocation and a token being removed during a function execution.

10.1.3. Cryptoki function return values for functions that use a token


Any Cryptoki function that uses a particular token (i.e., any Cryptoki function except for C_Initialize, C_Finalize, C_GetInfo, C_GetFunctionList, C_GetSlotList, C_GetSlotInfo, or C_WaitForSlotEvent) can return any of the following values:

  • CKR_DEVICE_MEMORY: The token does not have sufficient memory to perform the requested function.

  • CKR_DEVICE_ERROR: Some problem has occurred with the token and/or slot. This error code can be returned by more than just the functions mentioned above; in particular, it is possible for C_GetSlotInfo to return CKR_DEVICE_ERROR.

  • CKR_TOKEN_NOT_PRESENT: The token was not present in its slot at the time that the function was invoked.

  • CKR_DEVICE_REMOVED: The token was removed from its slot during the execution of the function.

The relative priorities of these errors are in the order listed above, e.g., if either of CKR_DEVICE_MEMORY or CKR_DEVICE_ERROR would be an appropriate error return, then CKR_DEVICE_MEMORY should be returned.
In practice, it is often not critical (or possible) for a Cryptoki library to be able to make a distinction between a token being removed before a function invocation and a token being removed during a function execution.

Download 360.55 Kb.

Share with your friends:
1   ...   70   71   72   73   74   75   76   77   ...   196




The database is protected by copyright ©ininet.org 2024
send message

    Main page