[Cryptech-Commits] [sw/pkcs11] 01/01: Add C_GetSessionInfo().

git at cryptech.is git at cryptech.is
Fri Jul 17 21:49:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch master
in repository sw/pkcs11.

commit 60a46afc01b73e763251370642cf61b15ba067d0
Author: Rob Austein <sra at hactrn.net>
Date:   Fri Jul 17 23:48:55 2015 +0200

    Add C_GetSessionInfo().
---
 pkcs11.c | 40 +++++++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/pkcs11.c b/pkcs11.c
index 2cf704f..318055e 100644
--- a/pkcs11.c
+++ b/pkcs11.c
@@ -3501,6 +3501,39 @@ CK_RV C_GetMechanismInfo(CK_SLOT_ID slotID,
   return CKR_OK;
 }
 
+CK_RV C_GetSessionInfo(CK_SESSION_HANDLE hSession,
+                       CK_SESSION_INFO_PTR pInfo)
+{
+  ENTER_PUBLIC_FUNCTION(C_GetSessionInfo);
+
+  p11_session_t *session;
+  CK_RV rv = CKR_OK;
+
+  mutex_lock_or_return_failure(p11_global_mutex);
+
+  if (pInfo == NULL)
+    lose(CKR_ARGUMENTS_BAD);
+
+  if ((session = p11_session_find(hSession)) == NULL)
+    lose(CKR_SESSION_HANDLE_INVALID);
+
+  pInfo->slotID = P11_ONE_AND_ONLY_SLOT;
+  pInfo->state = session->state;
+  pInfo->flags = CKF_SERIAL_SESSION;
+  pInfo->ulDeviceError = 0;
+
+  switch (session->state) {
+  case CKS_RW_PUBLIC_SESSION:
+  case CKS_RW_SO_FUNCTIONS:
+  case CKS_RW_USER_FUNCTIONS:
+    pInfo->flags |= CKF_RW_SESSION;
+  default:
+    break;
+  }
+
+ fail:
+  mutex_unlock_return_with_rv(rv, p11_global_mutex);
+}
 
 

 
@@ -3575,13 +3608,6 @@ CK_RV C_SetPIN(CK_SESSION_HANDLE hSession,
   return CKR_FUNCTION_NOT_SUPPORTED;
 }
 
-CK_RV C_GetSessionInfo(CK_SESSION_HANDLE hSession,
-                       CK_SESSION_INFO_PTR pInfo)
-{
-  ENTER_PUBLIC_FUNCTION(C_GetSessionInfo);
-  return CKR_FUNCTION_NOT_SUPPORTED;
-}
-
 CK_RV C_GetOperationState(CK_SESSION_HANDLE hSession,
                           CK_BYTE_PTR pOperationState,
                           CK_ULONG_PTR pulOperationStateLen)



More information about the Commits mailing list