diff options
author | Stef Walter <stefw@gnome.org> | 2013-03-12 18:03:25 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-03-15 17:54:55 +0100 |
commit | ff009f8a671e6ddd02a684bb1707a2a797fe4600 (patch) | |
tree | 3f3d5162a64f0addb0ad2d1acba91eae46f8ef1e /trust/tests/test-token.c | |
parent | 3fc6365093ad07b2eb5ef859093c5c5eb56ee700 (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/tests/test-token.c')
-rw-r--r-- | trust/tests/test-token.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/trust/tests/test-token.c b/trust/tests/test-token.c index 96f7a6c..ad25da0 100644 --- a/trust/tests/test-token.c +++ b/trust/tests/test-token.c @@ -68,7 +68,7 @@ teardown (CuTest *cu) static void test_token_load (CuTest *cu) { - p11_dict *objects; + p11_index *index; int count; setup (cu, SRCDIR "/input"); @@ -77,8 +77,8 @@ test_token_load (CuTest *cu) CuAssertIntEquals (cu, 6, count); /* A certificate and trust object for each parsed object + builtin */ - objects = p11_token_objects (test.token); - CuAssertTrue (cu, ((count - 1) * 2) + 1 <= p11_dict_size (objects)); + index = p11_token_index (test.token); + CuAssertTrue (cu, ((count - 1) * 2) + 1 <= p11_index_size (index)); teardown (cu); } @@ -86,19 +86,25 @@ test_token_load (CuTest *cu) static bool check_object (CK_ATTRIBUTE *match) { + CK_OBJECT_HANDLE *handles; CK_ATTRIBUTE *attrs; - p11_dict *objects; - p11_dictiter iter; - - objects = p11_token_objects (test.token); - - p11_dict_iterate (objects, &iter); - while (p11_dict_next (&iter, NULL, (void **)&attrs)) { - if (p11_attrs_match (attrs, match)) - return true; + p11_index *index; + bool ret = false; + int i; + + index = p11_token_index (test.token); + handles = p11_index_snapshot (index, NULL, match, p11_attrs_count (match)); + + for (i = 0; handles[i] != 0; i++) { + attrs = p11_index_lookup (index, handles[i]); + if (p11_attrs_match (attrs, match)) { + ret = true; + break; + } } - return false; + free (handles); + return ret; } static void |