Cryptographic Token Interface Standard

PKCS#11


Session types

Cryptoki represents session information with the following types:

CK_SESSION_HANDLE; CK_SESSION_HANDLE_PTR

CK_SESSION_HANDLE is a Cryptoki-assigned value that identifies a session. It is defined as follows:

typedef CK_ULONG CK_SESSION_HANDLE;

Valid session handles in Cryptoki always have nonzero values. For developers' convenience, Cryptoki defines the following symbolic value:

CK_INVALID_HANDLE

CK_SESSION_HANDLE_PTR is a pointer to a CK_SESSION_HANDLE.

CK_USER_TYPE

CK_USER_TYPE holds the types of Cryptoki users described in Section 6.5, and, in addition, a context-specific type described in Section 10.9. It is defined as follows:

typedef CK_ULONG CK_USER_TYPE;

For this version of Cryptoki, the following types of users are defined:

CKU_SO
CKU_USER
CKU_CONTEXT_SPECIFIC

CK_STATE

CK_STATE holds the session state, as described in Sections 6.7.1 and 6.7.2. It is defined as follows:

typedef CK_ULONG CK_STATE;

For this version of Cryptoki, the following session states are defined:

CKS_RO_PUBLIC_SESSION
CKS_RO_USER_FUNCTIONS
CKS_RW_PUBLIC_SESSION
CKS_RW_USER_FUNCTIONS
CKS_RW_SO_FUNCTIONS 

CK_SESSION_INFO; CK_SESSION_INFO_PTR

CK_SESSION_INFO provides information about a session. It is defined as follows:

typedef struct CK_SESSION_INFO {
CK_SLOT_ID slotID;
CK_STATE state;
CK_FLAGS flags;
CK_ULONG ulDeviceError;
} CK_SESSION_INFO;

slotID ID of the slot that interfaces with the token
state the state of the session
flags bit flags that define the type of session; the flags are defined below
ulDeviceError an error code defined by the cryptographic device. Used for errors not covered by Cryptoki.

The following table defines the flags field:

Table 12, Session Information Flags
Bit Flag Mask Meaning
CKF_RW_SESSION 0x00000002 True if the session is read/write; false if the session is read-only
CKF_SERIAL_SESSION 0x00000004 This flag is provided for backward compatibility, and should always be set to true

CK_SESSION_INFO_PTR is a pointer to a CK_SESSION_INFO.


RSA Security Inc. Public-Key Cryptography Standards - PKCS#11 - v220