aboutsummaryrefslogtreecommitdiff
path: root/pkcs11.c
diff options
context:
space:
mode:
Diffstat (limited to 'pkcs11.c')
-rw-r--r--pkcs11.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/pkcs11.c b/pkcs11.c
index 2350012..538654f 100644
--- a/pkcs11.c
+++ b/pkcs11.c
@@ -160,6 +160,7 @@ typedef struct p11_session {
unsigned find_query_session : 1; /* Find query for session objects in progress */
unsigned find_query_n : 30; /* Number of entries in find_query */
hal_uuid_t find_query_previous_uuid; /* Previous UUID for find queries */
+ unsigned find_query_state; /* hal_rpc_pkey_match() internal state */
hal_digest_algorithm_t
digest_algorithm, /* Hash algorithm for C_Digest*() */
sign_digest_algorithm, /* Hash algorithm for C_Sign*() */
@@ -1105,8 +1106,7 @@ static int p11_object_pkey_open(const p11_session_t *session,
return (session != NULL && pkey != NULL && object != NULL &&
hal_check(hal_rpc_pkey_open(p11_session_hal_client(session),
p11_session_hal_session(session),
- pkey, &object->uuid,
- p11_object_hal_flags(object_handle))));
+ pkey, &object->uuid)));
}
/*
@@ -2935,19 +2935,20 @@ CK_RV C_Logout(CK_SESSION_HANDLE hSession)
};
hal_uuid_t uuids[64];
- unsigned n;
+ unsigned n, state;
for (p11_session_t *session = p11_session_iterate(NULL);
session != NULL; session = p11_session_iterate(session)) {
memset(uuids, 0, sizeof(uuids));
+ state = 0;
do {
rv = p11_whine_from_hal(hal_rpc_pkey_match(p11_session_hal_client(session),
p11_session_hal_session(session),
HAL_KEY_TYPE_NONE, HAL_CURVE_NONE,
- 0,
- attrs, sizeof(attrs)/sizeof(*attrs),
+ HAL_KEY_FLAG_TOKEN, 0,
+ attrs, sizeof(attrs)/sizeof(*attrs), &state,
uuids, &n, sizeof(uuids)/sizeof(*uuids),
&uuids[sizeof(uuids)/sizeof(*uuids) - 1]));
if (rv != CKR_OK)
@@ -2957,8 +2958,8 @@ CK_RV C_Logout(CK_SESSION_HANDLE hSession)
p11_object_free(p11_object_by_uuid(&uuids[i]));
hal_pkey_handle_t pkey;
rv = p11_whine_from_hal(hal_rpc_pkey_open(p11_session_hal_client(session),
- p11_session_hal_session(session),
- &pkey, &uuids[i], 0));
+ p11_session_hal_session(session),
+ &pkey, &uuids[i]));
if (rv != CKR_OK)
goto fail;
if ((rv = p11_whine_from_hal(hal_rpc_pkey_delete(pkey))) != CKR_OK) {
@@ -2971,13 +2972,14 @@ CK_RV C_Logout(CK_SESSION_HANDLE hSession)
}
memset(uuids, 0, sizeof(uuids));
+ state = 0;
do {
rv = p11_whine_from_hal(hal_rpc_pkey_match(p11_session_hal_client(session),
p11_session_hal_session(session),
HAL_KEY_TYPE_NONE, HAL_CURVE_NONE,
- HAL_KEY_FLAG_TOKEN,
- attrs, sizeof(attrs)/sizeof(*attrs),
+ HAL_KEY_FLAG_TOKEN, HAL_KEY_FLAG_TOKEN,
+ attrs, sizeof(attrs)/sizeof(*attrs), &state,
uuids, &n, sizeof(uuids)/sizeof(*uuids),
&uuids[sizeof(uuids)/sizeof(*uuids) - 1]));
if (rv != CKR_OK)
@@ -3327,7 +3329,7 @@ CK_RV C_FindObjectsInit(CK_SESSION_HANDLE hSession,
if (session->find_query != NULL)
lose(CKR_OPERATION_ACTIVE);
- assert(!session->find_query_token && !session->find_query_session);
+ assert(!session->find_query_token && !session->find_query_session && !session->find_query_state);
for (int i = 0; i < ulCount; i++) {
if (pTemplate[i].pValue == NULL || pTemplate[i].ulValueLen == 0)
@@ -3356,6 +3358,7 @@ CK_RV C_FindObjectsInit(CK_SESSION_HANDLE hSession,
session->find_query_n = ulCount;
session->find_query_token = cka_token == NULL || *cka_token;
session->find_query_session = cka_token == NULL || !*cka_token;
+ session->find_query_state = 0;
memset(&session->find_query_previous_uuid, 0, sizeof(session->find_query_previous_uuid));
/*
@@ -3423,8 +3426,10 @@ CK_RV C_FindObjects(CK_SESSION_HANDLE hSession,
rv = p11_whine_from_hal(hal_rpc_pkey_match(p11_session_hal_client(session),
p11_session_hal_session(session),
- HAL_KEY_TYPE_NONE, HAL_CURVE_NONE, flags,
+ HAL_KEY_TYPE_NONE, HAL_CURVE_NONE,
+ HAL_KEY_FLAG_TOKEN, flags,
session->find_query, session->find_query_n,
+ &session->find_query_state,
uuids, &n, sizeof(uuids)/sizeof(*uuids),
&previous_uuid));
if (rv != CKR_OK)
@@ -3444,6 +3449,7 @@ CK_RV C_FindObjects(CK_SESSION_HANDLE hSession,
else {
memset(&session->find_query_previous_uuid, 0, sizeof(session->find_query_previous_uuid));
+ session->find_query_state = 0;
if (session->find_query_token)
session->find_query_token = 0;
@@ -3477,6 +3483,7 @@ CK_RV C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
session->find_query_n = 0;
session->find_query_token = 0;
session->find_query_session = 0;
+ session->find_query_state = 0;
memset(&session->find_query_previous_uuid, 0, sizeof(session->find_query_previous_uuid));
fail: