summaryrefslogtreecommitdiff
path: root/ckcapi-object.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2007-05-11 17:07:19 +0000
committerStef Walter <stef@memberwebs.com>2007-05-11 17:07:19 +0000
commitc6d18eea781bc98a362595e2334223b48f41b522 (patch)
treefe4c326602a5c1ae3d3b92d85c3a4368f7427390 /ckcapi-object.c
parente7b1e2fecde1053e661984f2dcb33f7e1cdd6dda (diff)
Add different tokens for different certificate stores.
Diffstat (limited to 'ckcapi-object.c')
-rw-r--r--ckcapi-object.c168
1 files changed, 0 insertions, 168 deletions
diff --git a/ckcapi-object.c b/ckcapi-object.c
index 6d8bb86..051baf4 100644
--- a/ckcapi-object.c
+++ b/ckcapi-object.c
@@ -23,174 +23,6 @@
#include <memory.h>
-static CkCapiArray* object_array = NULL;
-static CkCapiHash* object_hash = NULL;
-
-static void
-object_free(CkCapiObject* obj)
-{
- ASSERT(obj);
- ASSERT(obj->obj_funcs);
- ASSERT(obj->obj_funcs->release);
- (obj->obj_funcs->release)(obj);
-}
-
-void
-ckcapi_object_clear_all(void)
-{
- size_t i;
-
- ckcapi_lock_global();
-
- if(object_hash)
- {
- ckcapi_hash_free(object_hash, NULL);
- object_hash = NULL;
- }
-
- if(object_array)
- {
- for(i = 1; i < object_array->len; ++i)
- {
- ASSERT(ckcapi_array_index(object_array, CkCapiObject*, i));
- object_free(ckcapi_array_index(object_array, CkCapiObject*, i));
- }
-
- ckcapi_array_free(object_array, TRUE);
- object_array = NULL;
- }
-
- ckcapi_unlock_global();
-}
-
-CK_OBJECT_HANDLE
-ckcapi_object_get_max_handle(void)
-{
- if(!object_array)
- return 0;
- return object_array->len;
-}
-
-CkCapiObject*
-ckcapi_object_lookup(CkCapiSession* sess, CK_OBJECT_HANDLE obj)
-{
- /* This must be called without any locks held */
-
- CkCapiObject* ret = NULL;
-
- ASSERT(sess);
- ASSERT(obj > 0);
-
- ckcapi_lock_global();
-
- if(object_array && obj < object_array->len)
- ret = ckcapi_array_index(object_array, CkCapiObject*, obj);
-
- ckcapi_unlock_global();
-
- return ret;
-}
-
-CK_RV
-ckcapi_object_register(CkCapiSession* sess, CkCapiObject* obj)
-{
- CkCapiObject* prev;
- CK_RV ret = CKR_OK;
- void* key;
- size_t klen;
-
- ASSERT(sess);
- ASSERT(obj->id == 0);
- ASSERT(obj->unique_key);
- ASSERT(obj->unique_len > 0);
-
- DBG(("registering object"));
-
- ckcapi_lock_global();
-
- if(!object_array)
- {
- object_array = ckcapi_array_sized_new(0, 1, sizeof(CkCapiObject*), 16);
- if(object_array)
- {
- /* A blank entry for '0' */
- CkCapiObject* blank = NULL;
- ckcapi_array_append(object_array, blank);
- }
-
- object_hash = ckcapi_hash_new();
-
-
- if(!object_array || !object_hash)
- {
- /* Allocation failed above */
- ret = CKR_HOST_MEMORY;
- }
- }
-
- if(ret == CKR_OK)
- {
- ASSERT(object_array);
- ASSERT(object_hash);
-
- /* The type of object is part of the hash */
- key = obj->unique_key;
- klen = obj->unique_len;
-
- /* Sanity check, in case calcs went wrong somewhere */
- ASSERT(klen < 0xFFFFFF);
-
- /* Look in the hash and find a previous object */
- prev = ckcapi_hash_get(object_hash, key, klen);
- if(prev)
- {
- /* Register it in the previous object's place */
- obj->id = prev->id;
- ASSERT(prev->id < object_array->len);
- if(ckcapi_hash_set(object_hash, key, klen, obj))
- {
- ckcapi_array_index(object_array, CkCapiObject*, obj->id) = obj;
- object_free(prev);
- DBGO(obj, "found old object id");
- }
- else
- {
- ret = CKR_HOST_MEMORY;
- }
-
- }
- else
- {
- /* Register it at the end of the array */
- obj->id = object_array->len;
- ASSERT(obj->id > 0);
- if(ckcapi_hash_set(object_hash, key, klen, obj))
- {
- if(ckcapi_array_append(object_array, obj))
- {
- DBGO(obj, "registered new object id");
- }
- else
- {
- ret = CKR_HOST_MEMORY;
-
- /* Roll back our addition */
- ckcapi_hash_rem(object_hash, key, klen);
- }
- }
- else
- {
- ret = CKR_HOST_MEMORY;
- }
- }
- }
-
- ckcapi_unlock_global();
-
- return ret;
-
-}
-
enum
{
DATA_UNKNOWN = 0,