summaryrefslogtreecommitdiff
path: root/p11-kit/proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'p11-kit/proxy.c')
-rw-r--r--p11-kit/proxy.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/p11-kit/proxy.c b/p11-kit/proxy.c
index c8ba593..35f0c82 100644
--- a/p11-kit/proxy.c
+++ b/p11-kit/proxy.c
@@ -35,14 +35,14 @@
#include "config.h"
-#define DEBUG_FLAG DEBUG_PROXY
+#define P11_DEBUG_FLAG P11_DEBUG_PROXY
#include "debug.h"
-#include "hashmap.h"
+#include "dict.h"
+#include "library.h"
#define CRYPTOKI_EXPORTS
#include "pkcs11.h"
#include "p11-kit.h"
#include "private.h"
-#include "util.h"
#include <sys/types.h>
#include <assert.h>
@@ -77,7 +77,7 @@ static struct _Shared {
Mapping *mappings;
unsigned int n_mappings;
int mappings_refs;
- hashmap *sessions;
+ p11_dict *sessions;
CK_ULONG last_handle;
} gl = { NULL, 0, 0, NULL, FIRST_HANDLE };
@@ -115,7 +115,7 @@ map_slot_to_real (CK_SLOT_ID_PTR slot, Mapping *mapping)
assert (mapping);
- _p11_lock ();
+ p11_lock ();
if (!gl.mappings)
rv = CKR_CRYPTOKI_NOT_INITIALIZED;
@@ -124,7 +124,7 @@ map_slot_to_real (CK_SLOT_ID_PTR slot, Mapping *mapping)
if (rv == CKR_OK)
*slot = mapping->real_slot;
- _p11_unlock ();
+ p11_unlock ();
return rv;
}
@@ -138,13 +138,13 @@ map_session_to_real (CK_SESSION_HANDLE_PTR handle, Mapping *mapping, Session *se
assert (handle);
assert (mapping);
- _p11_lock ();
+ p11_lock ();
if (!gl.sessions) {
rv = CKR_CRYPTOKI_NOT_INITIALIZED;
} else {
assert (gl.sessions);
- sess = _p11_hash_get (gl.sessions, handle);
+ sess = p11_dict_get (gl.sessions, handle);
if (sess != NULL) {
*handle = sess->real_session;
rv = map_slot_unlocked (sess->wrap_slot, mapping);
@@ -155,7 +155,7 @@ map_session_to_real (CK_SESSION_HANDLE_PTR handle, Mapping *mapping, Session *se
}
}
- _p11_unlock ();
+ p11_unlock ();
return rv;
}
@@ -174,7 +174,7 @@ finalize_mappings_unlocked (void)
gl.n_mappings = 0;
/* no more sessions */
- _p11_hash_free (gl.sessions);
+ p11_dict_free (gl.sessions);
gl.sessions = NULL;
}
@@ -187,13 +187,13 @@ _p11_kit_proxy_after_fork (void)
* up any mappings and all
*/
- _p11_lock ();
+ p11_lock ();
gl.mappings_refs = 1;
finalize_mappings_unlocked ();
assert (!gl.mappings);
- _p11_unlock ();
+ p11_unlock ();
}
static CK_RV
@@ -201,7 +201,7 @@ proxy_C_Finalize (CK_VOID_PTR reserved)
{
CK_RV rv;
- _p11_debug ("in");
+ p11_debug ("in");
/* WARNING: This function must be reentrant */
@@ -209,7 +209,7 @@ proxy_C_Finalize (CK_VOID_PTR reserved)
rv = CKR_ARGUMENTS_BAD;
} else {
- _p11_lock ();
+ p11_lock ();
/* WARNING: Reentrancy can occur here */
rv = _p11_kit_finalize_registered_unlocked_reentrant ();
@@ -221,10 +221,10 @@ proxy_C_Finalize (CK_VOID_PTR reserved)
if (gl.mappings_refs)
finalize_mappings_unlocked ();
- _p11_unlock ();
+ p11_unlock ();
}
- _p11_debug ("out: %lu", rv);
+ p11_debug ("out: %lu", rv);
return rv;
}
@@ -248,7 +248,7 @@ initialize_mappings_unlocked_reentrant (void)
assert (funcs);
slots = NULL;
- _p11_unlock ();
+ p11_unlock ();
/* Ask module for its slots */
rv = (funcs->C_GetSlotList) (FALSE, NULL, &count);
@@ -257,7 +257,7 @@ initialize_mappings_unlocked_reentrant (void)
rv = (funcs->C_GetSlotList) (FALSE, slots, &count);
}
- _p11_lock ();
+ p11_lock ();
if (rv != CKR_OK) {
free (slots);
@@ -291,7 +291,7 @@ initialize_mappings_unlocked_reentrant (void)
assert (!gl.sessions);
gl.mappings = mappings;
gl.n_mappings = n_mappings;
- gl.sessions = _p11_hash_create (_p11_hash_ulongptr_hash, _p11_hash_ulongptr_equal, NULL, free);
+ gl.sessions = p11_dict_new (p11_dict_ulongptr_hash, p11_dict_ulongptr_equal, NULL, free);
++gl.mappings_refs;
/* Any cleanup necessary for failure will happen at caller */
@@ -303,13 +303,13 @@ proxy_C_Initialize (CK_VOID_PTR init_args)
{
CK_RV rv;
- _p11_library_init_once ();
+ p11_library_init_once ();
/* WARNING: This function must be reentrant */
- _p11_debug ("in");
+ p11_debug ("in");
- _p11_lock ();
+ p11_lock ();
/* WARNING: Reentrancy can occur here */
rv = _p11_kit_initialize_registered_unlocked_reentrant ();
@@ -318,14 +318,14 @@ proxy_C_Initialize (CK_VOID_PTR init_args)
if (rv == CKR_OK && gl.mappings_refs == 0)
rv = initialize_mappings_unlocked_reentrant ();
- _p11_unlock ();
+ p11_unlock ();
- _p11_debug ("here");
+ p11_debug ("here");
if (rv != CKR_OK)
proxy_C_Finalize (NULL);
- _p11_debug ("out: %lu", rv);
+ p11_debug ("out: %lu", rv);
return rv;
}
@@ -334,16 +334,16 @@ proxy_C_GetInfo (CK_INFO_PTR info)
{
CK_RV rv = CKR_OK;
- _p11_library_init_once ();
+ p11_library_init_once ();
return_val_if_fail (info != NULL, CKR_ARGUMENTS_BAD);
- _p11_lock ();
+ p11_lock ();
if (!gl.mappings)
rv = CKR_CRYPTOKI_NOT_INITIALIZED;
- _p11_unlock ();
+ p11_unlock ();
if (rv != CKR_OK)
return rv;
@@ -380,7 +380,7 @@ proxy_C_GetSlotList (CK_BBOOL token_present, CK_SLOT_ID_PTR slot_list,
return_val_if_fail (count != NULL, CKR_ARGUMENTS_BAD);
- _p11_lock ();
+ p11_lock ();
if (!gl.mappings) {
rv = CKR_CRYPTOKI_NOT_INITIALIZED;
@@ -413,7 +413,7 @@ proxy_C_GetSlotList (CK_BBOOL token_present, CK_SLOT_ID_PTR slot_list,
*count = index;
}
- _p11_unlock ();
+ p11_unlock ();
return rv;
}
@@ -503,7 +503,7 @@ proxy_C_OpenSession (CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR user_data,
rv = (map.funcs->C_OpenSession) (id, flags, user_data, callback, handle);
if (rv == CKR_OK) {
- _p11_lock ();
+ p11_lock ();
if (!gl.sessions) {
/*
@@ -519,11 +519,11 @@ proxy_C_OpenSession (CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR user_data,
sess->wrap_slot = map.wrap_slot;
sess->real_session = *handle;
sess->wrap_session = ++gl.last_handle; /* TODO: Handle wrapping, and then collisions */
- _p11_hash_set (gl.sessions, &sess->wrap_session, sess);
+ p11_dict_set (gl.sessions, &sess->wrap_session, sess);
*handle = sess->wrap_session;
}
- _p11_unlock ();
+ p11_unlock ();
}
return rv;
@@ -543,12 +543,12 @@ proxy_C_CloseSession (CK_SESSION_HANDLE handle)
rv = (map.funcs->C_CloseSession) (handle);
if (rv == CKR_OK) {
- _p11_lock ();
+ p11_lock ();
if (gl.sessions)
- _p11_hash_remove (gl.sessions, &key);
+ p11_dict_remove (gl.sessions, &key);
- _p11_unlock ();
+ p11_unlock ();
}
return rv;
@@ -561,27 +561,27 @@ proxy_C_CloseAllSessions (CK_SLOT_ID id)
CK_RV rv = CKR_OK;
Session *sess;
CK_ULONG i, count = 0;
- hashiter iter;
+ p11_dictiter iter;
- _p11_lock ();
+ p11_lock ();
if (!gl.sessions) {
rv = CKR_CRYPTOKI_NOT_INITIALIZED;
} else {
- to_close = calloc (sizeof (CK_SESSION_HANDLE), _p11_hash_size (gl.sessions));
+ to_close = calloc (sizeof (CK_SESSION_HANDLE), p11_dict_size (gl.sessions));
if (!to_close) {
rv = CKR_HOST_MEMORY;
} else {
- _p11_hash_iterate (gl.sessions, &iter);
+ p11_dict_iterate (gl.sessions, &iter);
count = 0;
- while (_p11_hash_next (&iter, NULL, (void**)&sess)) {
+ while (p11_dict_next (&iter, NULL, (void**)&sess)) {
if (sess->wrap_slot == id && to_close)
to_close[count++] = sess->wrap_session;
}
}
}
- _p11_unlock ();
+ p11_unlock ();
if (rv != CKR_OK)
return rv;
@@ -1390,6 +1390,6 @@ __declspec(dllexport)
CK_RV
C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list)
{
- _p11_library_init_once ();
+ p11_library_init_once ();
return proxy_C_GetFunctionList (list);
}