diff options
author | Stef Walter <stef@memberwebs.com> | 2007-04-28 22:39:24 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2007-04-28 22:39:24 +0000 |
commit | 31366290fcfbb7b51332e41755ba3f0c4b01084f (patch) | |
tree | 00f34d27b7d610e11b1fc71d0a45ec5af8ade028 /ckcapi-session.c | |
parent | 0ba89ba85a58264e4b1b44a5593e84fb070126e3 (diff) |
A complete but slow implementation for certificate listing.
Diffstat (limited to 'ckcapi-session.c')
-rw-r--r-- | ckcapi-session.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ckcapi-session.c b/ckcapi-session.c index 1076fbd..ce7e9d2 100644 --- a/ckcapi-session.c +++ b/ckcapi-session.c @@ -359,6 +359,12 @@ gather_objects(CkCapiSession* sess, CK_ATTRIBUTE_PTR match, CK_OBJECT_CLASS ocls = CK_INVALID_HANDLE; CK_RV ret = CKR_OK; + /* TODO: Reenable this once we have trust worked out + ret = ckcapi_builtin_find_all(sess, match, count, arr); + if(ret != CKR_OK) + return ret; + */ + get_ulong_attribute(CKA_CLASS, match, count, &ocls); switch(ocls) { @@ -387,6 +393,36 @@ cleanup_find_operation(CkCapiSession* sess) sess->operation_cancel = NULL; } +void +purge_duplicate_ulongs(CkCapiArray* arr) +{ + CkCapiHash* checks; + CK_ULONG* v; + size_t i; + + checks = ckcapi_hash_new(); + if(!checks) + return; + + for(i = 0; i < arr->len; ) + { + v = &ckcapi_array_index(arr, CK_ULONG, i); + if(ckcapi_hash_get(checks, v, sizeof(CK_ULONG))) + { + ckcapi_array_remove_index(arr, i); + /* Look at same i again */ + } + else + { + if(!ckcapi_hash_set(checks, v, sizeof(CK_ULONG), v)) + break; + ++i; + } + } + + ckcapi_hash_free(checks); +} + CK_RV ckcapi_session_find_init(CkCapiSession* sess, CK_ATTRIBUTE_PTR match, CK_ULONG count) @@ -411,6 +447,9 @@ ckcapi_session_find_init(CkCapiSession* sess, CK_ATTRIBUTE_PTR match, return ret; } + /* Cleanup all duplicates in the array */ + purge_duplicate_ulongs(arr); + sess->operation_type = OPERATION_FIND; sess->operation_data = arr; sess->operation_cancel = cleanup_find_operation; @@ -459,3 +498,4 @@ ckcapi_session_find_final(CkCapiSession* sess) return CKR_OK; } + |