summaryrefslogtreecommitdiff
path: root/trust/token.c
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-03-12 18:03:25 +0100
committerStef Walter <stefw@gnome.org>2013-03-15 17:54:55 +0100
commitff009f8a671e6ddd02a684bb1707a2a797fe4600 (patch)
tree3f3d5162a64f0addb0ad2d1acba91eae46f8ef1e /trust/token.c
parent3fc6365093ad07b2eb5ef859093c5c5eb56ee700 (diff)
trust: Refactor to include concept of the index
* The index holds PKCS#11 objects whether for the token or for the session. * The index provides hook for a builder to expand or validate objects being added to the index. * In addition theres a change hook so that a builder can maintain state between objects, such as the compat NSS trust objects. https://bugs.freedesktop.org/show_bug.cgi?id=62329
Diffstat (limited to 'trust/token.c')
-rw-r--r--trust/token.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/trust/token.c b/trust/token.c
index 39bca04..558f374 100644
--- a/trust/token.c
+++ b/trust/token.c
@@ -58,7 +58,7 @@
struct _p11_token {
p11_parser *parser;
- p11_dict *objects;
+ p11_index *index;
const char *path;
CK_SLOT_ID slot;
int loaded;
@@ -68,18 +68,11 @@ static void
on_parser_object (CK_ATTRIBUTE *attrs,
void *user_data)
{
- CK_OBJECT_HANDLE object;
- CK_OBJECT_HANDLE *key;
p11_token *token = user_data;
return_if_fail (attrs != NULL);
- object = p11_module_next_id ();
-
- key = memdup (&object, sizeof (object));
- return_if_fail (key != NULL);
-
- if (!p11_dict_set (token->objects, key, attrs))
+ if (p11_index_take (token->index, attrs, NULL) != CKR_OK)
return_if_reached ();
}
@@ -395,19 +388,13 @@ p11_token_load (p11_token *token)
return count + builtins;
}
-p11_dict *
-p11_token_objects (p11_token *token)
-{
- return token->objects;
-}
-
void
p11_token_free (p11_token *token)
{
if (!token)
return;
- p11_dict_free (token->objects);
+ p11_index_free (token->index);
p11_parser_free (token->parser);
free (token);
}
@@ -424,10 +411,8 @@ p11_token_new (CK_SLOT_ID slot,
token->parser = p11_parser_new ();
return_val_if_fail (token->parser != NULL, NULL);
- token->objects = p11_dict_new (p11_dict_ulongptr_hash,
- p11_dict_ulongptr_equal,
- free, p11_attrs_free);
- return_val_if_fail (token->objects != NULL, NULL);
+ token->index = p11_index_new (NULL, NULL, NULL);
+ return_val_if_fail (token->index != NULL, NULL);
token->path = strdup (path);
return_val_if_fail (token->path != NULL, NULL);
@@ -451,3 +436,10 @@ p11_token_get_slot (p11_token *token)
return_val_if_fail (token != NULL, 0);
return token->slot;
}
+
+p11_index *
+p11_token_index (p11_token *token)
+{
+ return_val_if_fail (token != NULL, NULL);
+ return token->index;
+}