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:

#define CK_INVALID_HANDLE 0

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.4. It is defined as follows:

typedef CK_ULONG CK_USER_TYPE;

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

#define CKU_SO 0
#define CKU_USER 1

CK_STATE

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

typedef CK_ULONG CK_STATE;

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

#define CKS_RO_PUBLIC_SESSION 0
#define CKS_RO_USER_FUNCTIONS 1
#define CKS_RW_PUBLIC_SESSION 2
#define CKS_RW_USER_FUNCTIONS 3
#define CKS_RW_SO_FUNCTIONS 4

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 - v211