From 94c63a237d77654bab2ea34146b06fd4b0acfc99 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 9 Dec 2008 03:47:01 +0000 Subject: Use better and faster hashing of objects. --- ckcapi-builtin.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'ckcapi-builtin.c') diff --git a/ckcapi-builtin.c b/ckcapi-builtin.c index 1be3ccc..21115a3 100644 --- a/ckcapi-builtin.c +++ b/ckcapi-builtin.c @@ -73,12 +73,6 @@ static CK_ULONG num_builtins = 0; typedef struct _BuiltinObject { CkCapiObject obj; - - /* - * Together these form the unique key. Must be - * laid out together in memory. - */ - unsigned int otype; CK_ATTRIBUTE_PTR attr; } BuiltinObject; @@ -154,6 +148,18 @@ builtin_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** obj return CKR_OK; } +static unsigned int +builtin_hash_func(CkCapiObject* obj) +{ + return ckcapi_hash_pointer(((BuiltinObject*)obj)->attr); +} + +static int +builtin_equal_func(CkCapiObject* one, CkCapiObject* two) +{ + return ((BuiltinObject*)one)->attr == ((BuiltinObject*)two)->attr; +} + static void builtin_object_release(void* data) { @@ -164,6 +170,8 @@ builtin_object_release(void* data) static const CkCapiObjectVtable builtin_object_vtable = { builtin_load_data, + builtin_hash_func, + builtin_equal_func, builtin_object_release, }; @@ -177,13 +185,10 @@ register_builtin_object(CkCapiSession* sess, CK_ATTRIBUTE_PTR attr, CkCapiObject if(!bobj) return CKR_HOST_MEMORY; - bobj->otype = OBJECT_BUILTIN; bobj->attr = attr; bobj->obj.id = 0; bobj->obj.obj_funcs = &builtin_object_vtable; - bobj->obj.unique_key = UNIQUE_KEY_AT(bobj, otype); - bobj->obj.unique_len = UNIQUE_KEY_LEN(bobj, otype, attr); ret = ckcapi_token_register_object(sess->slot, &(bobj->obj)); if(ret != CKR_OK) -- cgit v1.2.3