Cryptoki: a cryptographic Token Interface



Download 360.55 Kb.
Page89/196
Date22.12.2023
Size360.55 Kb.
#63026
1   ...   85   86   87   88   89   90   91   92   ...   196
v201-95
pkcs11-base-v2.40-cos01

C_CloseSession


CK_DEFINE_FUNCTION(CK_RV, C_CloseSession)(
CK_SESSION_HANDLE hSession
);
C_CloseSession closes a session between an application and a token. hSession is the session’s handle.
When a session is closed, all session objects created by the session are destroyed automatically, even if the application has other sessions “using” the objects (see Sections - for more details).
Depending on the token, when the last open session any application has with the token is closed, the token may be “ejected” from its reader (if this capability exists).
Despite the fact this C_CloseSession is supposed to close a session, the return value CKR_SESSION_CLOSED is an error return. It actually indicates the (probably somewhat unlikely) event that while this function call was executing, another call was made to C_CloseSession to close this particular session, and that call finished executing first. Such uses of sessions are a bad idea, and Cryptoki makes little promise of what will occur in general if an application indulges in this sort of behavior.
Return values: CKR_CRYPTOKI_NOT_INITIALIZED, CKR_DEVICE_ERROR, CKR_DEVICE_MEMORY, CKR_DEVICE_REMOVED, CKR_FUNCTION_FAILED, CKR_GENERAL_ERROR, CKR_HOST_MEMORY, CKR_OK, CKR_SESSION_CLOSED, CKR_SESSION_HANDLE_INVALID.
Example:
CK_SLOT_ID slotID;
CK_BYTE application;
CK_NOTIFY MyNotify;
CK_SESSION_HANDLE hSession;
CK_RV rv;

.
.
.


application = 17;
MyNotify = &EncryptionSessionCallback;
rv = C_OpenSession(
slotID, CKF_RW_SESSION,(CK_VOID_PTR) &application, MyNotify,
&hSession);
if (rv == CKR_OK) {
.
.
.
C_CloseSession(hSession);
}
  • C_CloseAllSessions


CK_DEFINE_FUNCTION(CK_RV, C_CloseAllSessions)(
CK_SLOT_ID slotID
);
C_CloseAllSessions closes all sessions an application has with a token. slotID specifies the token’s slot.
When a session is closed, all session objects created by the session are destroyed automatically.
Depending on the token, when the last open session any application has with the token is closed, the token may be “ejected” from its reader (if this capability exists).
Return values: CKR_CRYPTOKI_NOT_INITIALIZED, CKR_DEVICE_ERROR, CKR_DEVICE_MEMORY, CKR_DEVICE_REMOVED, CKR_FUNCTION_FAILED, CKR_GENERAL_ERROR, CKR_HOST_MEMORY, CKR_OK, CKR_SLOT_ID_INVALID, CKR_TOKEN_NOT_PRESENT.
Example:
CK_SLOT_ID slotID;
CK_RV rv;

.
.
.


rv = C_CloseAllSessions(slotID);
1   ...   85   86   87   88   89   90   91   92   ...   196




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

    Main page