Implement C_SessionCancel from PKCS #11 3.0

This commit is contained in:
Jakub Jelen 2020-08-17 14:35:50 +02:00 committed by Frank Morgner
parent 8e71118cd4
commit 224e265266
1 changed files with 50 additions and 1 deletions

View File

@ -192,7 +192,56 @@ out:
CK_RV C_SessionCancel(CK_SESSION_HANDLE hSession, /* the session's handle */
CK_FLAGS flags) /* flags control which sessions are cancelled */
{
return CKR_FUNCTION_NOT_SUPPORTED;
struct sc_pkcs11_session *session;
CK_RV rv;
rv = sc_pkcs11_lock();
if (rv != CKR_OK)
return rv;
rv = get_session(hSession, &session);
if (rv != CKR_OK)
goto out;
/* Ignore return value of the cancel operation as it is valid to
* cancel not started operation and it can not fail for other reasons */
if (flags & CKF_ENCRYPT) {
/* unused */
}
if (flags & CKF_DECRYPT) {
session_stop_operation(session, SC_PKCS11_OPERATION_DECRYPT);
}
if (flags & CKF_DIGEST) {
session_stop_operation(session, SC_PKCS11_OPERATION_DIGEST);
}
if (flags & CKF_SIGN) {
session_stop_operation(session, SC_PKCS11_OPERATION_SIGN);
}
if (flags & CKF_SIGN_RECOVER) {
/* unused */
}
if (flags & CKF_VERIFY) {
session_stop_operation(session, SC_PKCS11_OPERATION_VERIFY);
}
if (flags & CKF_VERIFY_RECOVER) {
/* unused */
}
if (flags & CKF_GENERATE || flags & CKF_GENERATE_KEY_PAIR) {
/* unused */
}
if (flags & CKF_WRAP) {
session_stop_operation(session, SC_PKCS11_OPERATION_WRAP);
}
if (flags & CKF_UNWRAP) {
session_stop_operation(session, SC_PKCS11_OPERATION_UNWRAP);
}
if (flags & CKF_DERIVE) {
session_stop_operation(session, SC_PKCS11_OPERATION_DERIVE);
}
out:
sc_pkcs11_unlock();
return rv;
}
CK_RV C_GetSessionInfo(CK_SESSION_HANDLE hSession, /* the session's handle */