summaryrefslogtreecommitdiff
path: root/p11-kit/iter.c
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2016-08-10 16:09:31 +0200
committerStef Walter <stefw@redhat.com>2016-09-02 17:48:36 +0200
commite0c5d429df6ebe2cb88425edf42f65bfb33f0b77 (patch)
tree5e6d1fb165aee035bbc51ff28205f1bbf814c4c9 /p11-kit/iter.c
parent31fbc32c41518b93a7b9903d7840378bab55370c (diff)
downloadp11-kit-e0c5d429df6ebe2cb88425edf42f65bfb33f0b77.tar.gz
iter: Utilize slot info URI path attributes
https://bugs.freedesktop.org/show_bug.cgi?id=97245
Diffstat (limited to 'p11-kit/iter.c')
-rw-r--r--p11-kit/iter.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/p11-kit/iter.c b/p11-kit/iter.c
index aeee8ad..6032513 100644
--- a/p11-kit/iter.c
+++ b/p11-kit/iter.c
@@ -61,6 +61,7 @@ struct p11_kit_iter {
/* Iterator matching data */
CK_INFO match_module;
+ CK_SLOT_INFO match_slot;
CK_TOKEN_INFO match_token;
CK_ATTRIBUTE *match_attrs;
Callback *callbacks;
@@ -84,6 +85,7 @@ struct p11_kit_iter {
CK_SLOT_ID slot;
CK_SESSION_HANDLE session;
CK_OBJECT_HANDLE object;
+ CK_SLOT_INFO slot_info;
CK_TOKEN_INFO token_info;
/* And various flags */
@@ -164,6 +166,7 @@ p11_kit_iter_set_uri (P11KitIter *iter,
{
CK_ATTRIBUTE *attrs;
CK_TOKEN_INFO *tinfo;
+ CK_SLOT_INFO *sinfo;
CK_INFO *minfo;
CK_ULONG count;
@@ -182,6 +185,10 @@ p11_kit_iter_set_uri (P11KitIter *iter,
if (minfo != NULL)
memcpy (&iter->match_module, minfo, sizeof (CK_INFO));
+ sinfo = p11_kit_uri_get_slot_info (uri);
+ if (sinfo != NULL)
+ memcpy (&iter->match_slot, sinfo, sizeof (CK_SLOT_INFO));
+
tinfo = p11_kit_uri_get_token_info (uri);
if (tinfo != NULL)
memcpy (&iter->match_token, tinfo, sizeof (CK_TOKEN_INFO));
@@ -506,6 +513,9 @@ move_next_session (P11KitIter *iter)
iter->slot = iter->slots[iter->saw_slots++];
assert (iter->module != NULL);
+ rv = (iter->module->C_GetSlotInfo) (iter->slot, &iter->slot_info);
+ if (rv != CKR_OK || !p11_match_uri_slot_info (&iter->match_slot, &iter->slot_info))
+ continue;
rv = (iter->module->C_GetTokenInfo) (iter->slot, &iter->token_info);
if (rv != CKR_OK || !p11_match_uri_token_info (&iter->match_token, &iter->token_info))
continue;
@@ -675,6 +685,23 @@ p11_kit_iter_get_slot (P11KitIter *iter)
}
/**
+ * p11_kit_iter_get_slot_info:
+ * @iter: the iterator
+ *
+ * Get the slot info for the slot which the current matching object is on.
+ *
+ * This can only be called after p11_kit_iter_next() succeeds.
+ *
+ * Returns: the slot of the current matching object.
+ */
+CK_SLOT_INFO *
+p11_kit_iter_get_slot_info (P11KitIter *iter)
+{
+ return_val_if_fail (iter != NULL, NULL);
+ return &iter->slot_info;
+}
+
+/**
* p11_kit_iter_get_token:
* @iter: the iterator
*