YKCS11: add more precondition checks during SingInit.

This commit is contained in:
Alessio Di Mauro
2015-11-05 14:09:09 +01:00
parent 83099997c0
commit f3bd827100
+24 -1
View File
@@ -1747,7 +1747,30 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
goto sign_out;
}
// TODO: check other conditions
if (session.handle != YKCS11_SESSION_ID) {
DBG(("Session is not open"));
rv = CKR_SESSION_CLOSED;
goto sign_out;
}
if (hSession != session.handle) {
DBG(("Unknown session %lu", hSession));
rv = CKR_SESSION_HANDLE_INVALID;
goto sign_out;
}
if (op_info.type != YKCS11_SIGN) {
DBG(("Operation not initialized"));
rv = CKR_OPERATION_NOT_INITIALIZED;
goto sign_out;
}
if (session.info.state == CKS_RO_PUBLIC_SESSION ||
session.info.state == CKS_RW_PUBLIC_SESSION) {
DBG(("User is not logged in"));
rv = CKR_USER_NOT_LOGGED_IN;
goto sign_out;
}
if (pSignature == NULL_PTR) {
// Just return the size of the signature